diff --git a/.github/workflows/dotnet_develop.yml b/.github/workflows/dotnet_develop.yml new file mode 100644 index 00000000..9dda507b --- /dev/null +++ b/.github/workflows/dotnet_develop.yml @@ -0,0 +1,29 @@ +name: .NET + +on: + push: + branches: [ develop* ] + pull_request: + branches: [ develop* ] + +jobs: + build: + env: + BUILD_CONFIG: Debug + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + source-url: https://nuget.pkg.github.com/SSchulze1989/index.json + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build -c $BUILD_CONFIG --no-restore + - name: Test + run: dotnet test -c $BUILD_CONFIG --no-build --verbosity normal --filter FullyQualifiedName\!~IntegrationTests diff --git a/.github/workflows/dotnet_main_pr.yml b/.github/workflows/dotnet_main_pr.yml new file mode 100644 index 00000000..5e4d5e1e --- /dev/null +++ b/.github/workflows/dotnet_main_pr.yml @@ -0,0 +1,27 @@ +name: .NET + +on: + pull_request: + branches: [ main ] + +jobs: + build: + env: + BUILD_CONFIG: Release + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + source-url: https://nuget.pkg.github.com/SSchulze1989/index.json + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build -c $BUILD_CONFIG --no-restore + - name: Test + run: dotnet test -c $BUILD_CONFIG --no-build --verbosity normal diff --git a/.github/workflows/dotnet_main_push.yml b/.github/workflows/dotnet_main_push.yml new file mode 100644 index 00000000..f2a99bf1 --- /dev/null +++ b/.github/workflows/dotnet_main_push.yml @@ -0,0 +1,27 @@ +name: .NET + +on: + push: + branches: [ main ] + +jobs: + publish: + env: + BUILD_CONFIG: Release + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + source-url: https://nuget.pkg.github.com/SSchulze1989/index.json + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build -c $BUILD_CONFIG --no-restore + - name: Test + run: dotnet test -c $BUILD_CONFIG --no-build --verbosity normal diff --git a/.github/workflows/mkdocs_publish.yml b/.github/workflows/mkdocs_publish.yml index 5e80c096..d46da514 100644 --- a/.github/workflows/mkdocs_publish.yml +++ b/.github/workflows/mkdocs_publish.yml @@ -3,6 +3,7 @@ name: .NET on: push: branches: [ main ] + paths: [ docs/** ] jobs: build: diff --git a/iRLeagueManager.Web.sln b/iRLeagueManager.Web.sln index 4d83d15b..30153d13 100644 --- a/iRLeagueManager.Web.sln +++ b/iRLeagueManager.Web.sln @@ -5,6 +5,32 @@ VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueManager.Web", "src\iRLeagueManager.Web\iRLeagueManager.Web.csproj", "{0E1210B9-CB90-497D-9B67-D084D7DFE768}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueApiCore.Client", "src\iRLeagueApiCore.Client\iRLeagueApiCore.Client.csproj", "{44B24383-25F8-4257-9AAD-33709EA87297}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueApiCore.Server", "src\iRLeagueApiCore.Server\iRLeagueApiCore.Server.csproj", "{A2D07223-4EC9-4EF9-8C9F-5E60AD25D7BE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueApiCore.Services", "src\iRLeagueApiCore.Services\iRLeagueApiCore.Services.csproj", "{AC620517-78B1-4F01-B790-98167887F21D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueApiCore.TrackImport", "src\iRLeagueApiCore.TrackImport\iRLeagueApiCore.TrackImport.csproj", "{0BDB48B8-874E-4F72-AA4A-59842D613636}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueApiCore.Mocking", "test\iRLeagueApiCore.Mocking\iRLeagueApiCore.Mocking.csproj", "{1AAD7DAE-BA65-49A2-B9F9-C7355EF92252}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueApiCore.Services.Tests", "test\iRLeagueApiCore.Services.Tests\iRLeagueApiCore.Services.Tests.csproj", "{53F6E2DD-FED4-48B5-9208-3E77CF69BFA4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueApiCore.UnitTests", "test\iRLeagueApiCore.UnitTests\iRLeagueApiCore.UnitTests.csproj", "{C1BB891C-DB8A-470E-90E2-D7E5263AEAA7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueApiCore.Common", "src\iRLeagueApiCore.Common\iRLeagueApiCore.Common.csproj", "{FF70174F-5A5C-4885-A1D9-CE2E0294A0A7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueApiCore.Common.Tests", "test\iRLeagueApiCore.Common.Tests\iRLeagueApiCore.Common.Tests.csproj", "{00695048-6893-4A66-A490-4C845D244A03}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueDatabaseCore", "src\iRLeagueDatabaseCore\iRLeagueDatabaseCore.csproj", "{ED1D3D4D-9C2A-4D59-96AC-F58ABF4935DB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iRLeagueDatabaseCore.Migrations", "src\iRLeagueDatabaseCore.Migrations\iRLeagueDatabaseCore.Migrations.csproj", "{7712AE15-156D-4BA7-9CC6-42F71A0A5328}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DbIntegrationTests", "test\DbIntegrationTests\DbIntegrationTests.csproj", "{6F10B4B3-9737-4532-BACB-4247F78FA7C4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "test\UnitTests\UnitTests.csproj", "{951DD6F7-F6D6-4EB9-B53C-6F63998668F6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +41,58 @@ Global {0E1210B9-CB90-497D-9B67-D084D7DFE768}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E1210B9-CB90-497D-9B67-D084D7DFE768}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E1210B9-CB90-497D-9B67-D084D7DFE768}.Release|Any CPU.Build.0 = Release|Any CPU + {44B24383-25F8-4257-9AAD-33709EA87297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44B24383-25F8-4257-9AAD-33709EA87297}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44B24383-25F8-4257-9AAD-33709EA87297}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44B24383-25F8-4257-9AAD-33709EA87297}.Release|Any CPU.Build.0 = Release|Any CPU + {A2D07223-4EC9-4EF9-8C9F-5E60AD25D7BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A2D07223-4EC9-4EF9-8C9F-5E60AD25D7BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2D07223-4EC9-4EF9-8C9F-5E60AD25D7BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A2D07223-4EC9-4EF9-8C9F-5E60AD25D7BE}.Release|Any CPU.Build.0 = Release|Any CPU + {AC620517-78B1-4F01-B790-98167887F21D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC620517-78B1-4F01-B790-98167887F21D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC620517-78B1-4F01-B790-98167887F21D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC620517-78B1-4F01-B790-98167887F21D}.Release|Any CPU.Build.0 = Release|Any CPU + {0BDB48B8-874E-4F72-AA4A-59842D613636}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0BDB48B8-874E-4F72-AA4A-59842D613636}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0BDB48B8-874E-4F72-AA4A-59842D613636}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0BDB48B8-874E-4F72-AA4A-59842D613636}.Release|Any CPU.Build.0 = Release|Any CPU + {1AAD7DAE-BA65-49A2-B9F9-C7355EF92252}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1AAD7DAE-BA65-49A2-B9F9-C7355EF92252}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1AAD7DAE-BA65-49A2-B9F9-C7355EF92252}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1AAD7DAE-BA65-49A2-B9F9-C7355EF92252}.Release|Any CPU.Build.0 = Release|Any CPU + {53F6E2DD-FED4-48B5-9208-3E77CF69BFA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {53F6E2DD-FED4-48B5-9208-3E77CF69BFA4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {53F6E2DD-FED4-48B5-9208-3E77CF69BFA4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {53F6E2DD-FED4-48B5-9208-3E77CF69BFA4}.Release|Any CPU.Build.0 = Release|Any CPU + {C1BB891C-DB8A-470E-90E2-D7E5263AEAA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C1BB891C-DB8A-470E-90E2-D7E5263AEAA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C1BB891C-DB8A-470E-90E2-D7E5263AEAA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C1BB891C-DB8A-470E-90E2-D7E5263AEAA7}.Release|Any CPU.Build.0 = Release|Any CPU + {FF70174F-5A5C-4885-A1D9-CE2E0294A0A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF70174F-5A5C-4885-A1D9-CE2E0294A0A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF70174F-5A5C-4885-A1D9-CE2E0294A0A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF70174F-5A5C-4885-A1D9-CE2E0294A0A7}.Release|Any CPU.Build.0 = Release|Any CPU + {00695048-6893-4A66-A490-4C845D244A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00695048-6893-4A66-A490-4C845D244A03}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00695048-6893-4A66-A490-4C845D244A03}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00695048-6893-4A66-A490-4C845D244A03}.Release|Any CPU.Build.0 = Release|Any CPU + {ED1D3D4D-9C2A-4D59-96AC-F58ABF4935DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED1D3D4D-9C2A-4D59-96AC-F58ABF4935DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED1D3D4D-9C2A-4D59-96AC-F58ABF4935DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED1D3D4D-9C2A-4D59-96AC-F58ABF4935DB}.Release|Any CPU.Build.0 = Release|Any CPU + {7712AE15-156D-4BA7-9CC6-42F71A0A5328}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7712AE15-156D-4BA7-9CC6-42F71A0A5328}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7712AE15-156D-4BA7-9CC6-42F71A0A5328}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7712AE15-156D-4BA7-9CC6-42F71A0A5328}.Release|Any CPU.Build.0 = Release|Any CPU + {6F10B4B3-9737-4532-BACB-4247F78FA7C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F10B4B3-9737-4532-BACB-4247F78FA7C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F10B4B3-9737-4532-BACB-4247F78FA7C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F10B4B3-9737-4532-BACB-4247F78FA7C4}.Release|Any CPU.Build.0 = Release|Any CPU + {951DD6F7-F6D6-4EB9-B53C-6F63998668F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {951DD6F7-F6D6-4EB9-B53C-6F63998668F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {951DD6F7-F6D6-4EB9-B53C-6F63998668F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {951DD6F7-F6D6-4EB9-B53C-6F63998668F6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/iRLeagueApiCore.Client/Endpoints/Cars/CarsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Cars/CarsEndpoint.cs new file mode 100644 index 00000000..099e71f0 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Cars/CarsEndpoint.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Results; + +namespace iRLeagueApiCore.Client.Endpoints.Cars; +internal sealed class CarsEndpoint : GetEndpoint, ICarsEndpoint +{ + public CarsEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("Cars"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Cars/ICarsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Cars/ICarsEndpoint.cs new file mode 100644 index 00000000..450e2dd9 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Cars/ICarsEndpoint.cs @@ -0,0 +1,6 @@ +using iRLeagueApiCore.Common.Models.Results; + +namespace iRLeagueApiCore.Client.Endpoints.Cars; +public interface ICarsEndpoint : IGetEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampSeasonByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampSeasonByIdEndpoint.cs new file mode 100644 index 00000000..fe7058b6 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampSeasonByIdEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Endpoints.Results; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Championships; +internal class ChampSeasonByIdEndpoint : UpdateEndpoint, IChampSeasonByIdEndpoint +{ + public ChampSeasonByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long id) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(id); + } + + IPostEndpoint IChampSeasonByIdEndpoint.ResultConfigs() + { + return new ResultConfigsEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampSeasonsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampSeasonsEndpoint.cs new file mode 100644 index 00000000..3916413d --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampSeasonsEndpoint.cs @@ -0,0 +1,18 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Championships; +internal class ChampSeasonsEndpoint : GetAllEndpoint, IChampSeasonsEndpoint, ISeasonChampSeasonsEndpoint, IChampionshipChampSeasonsEndpoint +{ + public ChampSeasonsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("ChampSeasons"); + } + + IChampSeasonByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new ChampSeasonByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampionshipByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampionshipByIdEndpoint.cs new file mode 100644 index 00000000..caadf8a7 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampionshipByIdEndpoint.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Championships; +internal sealed class ChampionshipByIdEndpoint : UpdateEndpoint, IChampionshipByIdEndpoint, ISeasonChampionshipByIdEndpoint +{ + public ChampionshipByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long id) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(id); + } + + IChampionshipChampSeasonsEndpoint IChampionshipByIdEndpoint.ChampSeasons() + { + return new ChampSeasonsEndpoint(HttpClientWrapper, RouteBuilder); + } + + async Task> IGetEndpoint.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult(QueryUrl, cancellationToken); + } + + async Task> IPostEndpoint.Post(PostChampSeasonModel model, CancellationToken cancellationToken) + { + return await HttpClientWrapper.PostAsClientActionResult(QueryUrl, model, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampionshipsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampionshipsEndpoint.cs new file mode 100644 index 00000000..fb75a164 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/ChampionshipsEndpoint.cs @@ -0,0 +1,23 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Championships; +internal sealed class ChampionshipsEndpoint : PostGetAllEndpoint, IChampionshipsEndpoint, ISeasonChampionshipsEndpoint +{ + public ChampionshipsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Championships"); + } + + IChampionshipByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new ChampionshipByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } + + ISeasonChampionshipByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new ChampionshipByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampSeasonByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampSeasonByIdEndpoint.cs new file mode 100644 index 00000000..7ce570c9 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampSeasonByIdEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Client.Endpoints; +using iRLeagueApiCore.Common.Models; + +public interface IChampSeasonByIdEndpoint : IUpdateEndpoint +{ + public IPostEndpoint ResultConfigs(); +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampSeasonsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampSeasonsEndpoint.cs new file mode 100644 index 00000000..3a7db5f8 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampSeasonsEndpoint.cs @@ -0,0 +1,5 @@ +using iRLeagueApiCore.Client.Endpoints; + +public interface IChampSeasonsEndpoint : IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampionshipByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampionshipByIdEndpoint.cs new file mode 100644 index 00000000..42b4e407 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampionshipByIdEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Championships; + +public interface IChampionshipByIdEndpoint : IUpdateEndpoint +{ + public IChampionshipChampSeasonsEndpoint ChampSeasons(); +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampionshipChampSeasonsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampionshipChampSeasonsEndpoint.cs new file mode 100644 index 00000000..dc86ad46 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampionshipChampSeasonsEndpoint.cs @@ -0,0 +1,6 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Championships; +public interface IChampionshipChampSeasonsEndpoint : IGetAllEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampionshipsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampionshipsEndpoint.cs new file mode 100644 index 00000000..c482c37b --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/IChampionshipsEndpoint.cs @@ -0,0 +1,6 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Championships; +public interface IChampionshipsEndpoint : IPostGetAllEndpoint, IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/ISeasonChampSeasonsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/ISeasonChampSeasonsEndpoint.cs new file mode 100644 index 00000000..63d74f74 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/ISeasonChampSeasonsEndpoint.cs @@ -0,0 +1,6 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Championships; +public interface ISeasonChampSeasonsEndpoint : IGetAllEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/ISeasonChampionshipByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/ISeasonChampionshipByIdEndpoint.cs new file mode 100644 index 00000000..77184d40 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/ISeasonChampionshipByIdEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Championships; + +public interface ISeasonChampionshipByIdEndpoint : IPostEndpoint, IGetEndpoint +{ +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Client/Endpoints/Championships/ISeasonChampionshipsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Championships/ISeasonChampionshipsEndpoint.cs new file mode 100644 index 00000000..8348f841 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Championships/ISeasonChampionshipsEndpoint.cs @@ -0,0 +1,4 @@ +namespace iRLeagueApiCore.Client.Endpoints.Championships; +public interface ISeasonChampionshipsEndpoint : IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/CustomEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/CustomEndpoint.cs new file mode 100644 index 00000000..ce5bbca1 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/CustomEndpoint.cs @@ -0,0 +1,28 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +internal sealed class CustomEndpoint : UpdateEndpoint, ICustomEndpoint +{ + public CustomEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, string route) : base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint(route); + } + + async Task> IPostEndpoint.Post(object model, CancellationToken cancellationToken) + { + return await HttpClientWrapper.PostAsClientActionResult(QueryUrl, model, cancellationToken); + } + + async Task> IPostEndpoint.Post(CancellationToken cancellationToken) + { + return await HttpClientWrapper.PostAsClientActionResult(QueryUrl, null, cancellationToken); + } + + async Task>> ICustomEndpoint.GetAll(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult>(QueryUrl, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/DeleteEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/DeleteEndpoint.cs new file mode 100644 index 00000000..de3768d5 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/DeleteEndpoint.cs @@ -0,0 +1,18 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +internal class DeleteEndpoint : EndpointBase, IDeleteEndpoint +{ + public DeleteEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : + base(httpClient, routeBuilder) + { + } + + public async Task> Delete(CancellationToken cancellationToken = default) + { + return await HttpClientWrapper.DeleteAsClientActionResult(QueryUrl, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/EndpointBase.cs b/src/iRLeagueApiCore.Client/Endpoints/EndpointBase.cs new file mode 100644 index 00000000..cc59cc8e --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/EndpointBase.cs @@ -0,0 +1,33 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.Client.Endpoints; + +internal class EndpointBase : IEndpoint +{ + protected HttpClientWrapper HttpClientWrapper { get; } + protected RouteBuilder RouteBuilder { get; } + + public virtual string QueryUrl => RouteBuilder.Build(); + + public EndpointBase(HttpClientWrapper httpClient, RouteBuilder routeBuilder) + { + HttpClientWrapper = httpClient; + RouteBuilder = routeBuilder.Copy(); + } + + void IEndpoint.AddEndpoint(string endpoint) + { + RouteBuilder.AddEndpoint(endpoint); + } + + void IEndpoint.AddRouteParameter(T parameter) + { + RouteBuilder.AddParameter(parameter); + } + + void IEndpoint.WithParameters(Func parameterBuilder) + { + RouteBuilder.WithParameters(parameterBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/EndpointExtensions.cs b/src/iRLeagueApiCore.Client/Endpoints/EndpointExtensions.cs new file mode 100644 index 00000000..b79824dd --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/EndpointExtensions.cs @@ -0,0 +1,18 @@ +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +public static class EndpointExtensions +{ + /// + /// Extension for Post requests with empty request body + /// + /// + /// + /// + /// + public static Task> Post(this IPostEndpoint postEndpoint, CancellationToken cancellationToken = default) + { + return postEndpoint.Post(default, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/GetAllEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/GetAllEndpoint.cs new file mode 100644 index 00000000..2fc3dc5e --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/GetAllEndpoint.cs @@ -0,0 +1,18 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +internal class GetAllEndpoint : EndpointBase, IGetAllEndpoint +{ + public GetAllEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + } + + async Task>> IGetEndpoint>.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult>(QueryUrl, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/GetEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/GetEndpoint.cs new file mode 100644 index 00000000..5f19b974 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/GetEndpoint.cs @@ -0,0 +1,18 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +internal class GetEndpoint : EndpointBase, IGetEndpoint +{ + public GetEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : + base(httpClient, routeBuilder) + { + } + + async Task> IGetEndpoint.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult(QueryUrl, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/GetLatestEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/GetLatestEndpoint.cs new file mode 100644 index 00000000..0c63f2f3 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/GetLatestEndpoint.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.Client.Endpoints; +internal sealed class GetLatestEndpoint : GetEndpoint +{ + public GetLatestEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("Latest"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/ICustomEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/ICustomEndpoint.cs new file mode 100644 index 00000000..91012c05 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/ICustomEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +public interface ICustomEndpoint : IPostEndpoint, IPostEndpoint, IGetEndpoint, IPutEndpoint, IDeleteEndpoint +{ + Task>> GetAll(CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/IDeleteEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/IDeleteEndpoint.cs new file mode 100644 index 00000000..32f37513 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/IDeleteEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +public interface IDeleteEndpoint : IEndpoint +{ + Task> Delete(CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/IEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/IEndpoint.cs new file mode 100644 index 00000000..7dae2e7f --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/IEndpoint.cs @@ -0,0 +1,31 @@ +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.Client.Endpoints; +public interface IEndpoint +{ + string QueryUrl { get; } + internal void AddEndpoint(string endpoint); + internal void AddRouteParameter(T parameter); + internal void WithParameters(Func parameterBuilder); +} + +public static class IEndpointExtensions +{ + public static T AddQueryParameter(this T endpoint, Func parameterBuilder) where T : IEndpoint + { + endpoint.WithParameters(parameterBuilder); + return endpoint; + } + + public static T AddEndpoint(this T endpointImpl, string endpoint) where T : IEndpoint + { + endpointImpl.AddEndpoint(endpoint); + return endpointImpl; + } + + public static TEndpoint AddRouteParameter(this TEndpoint endpoint, TParam parameter) where TEndpoint : IEndpoint + { + endpoint.AddRouteParameter(parameter); + return endpoint; + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/IGetAllEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/IGetAllEndpoint.cs new file mode 100644 index 00000000..28e9425c --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/IGetAllEndpoint.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Client.Endpoints; + +public interface IGetAllEndpoint : IGetEndpoint> +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/IGetEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/IGetEndpoint.cs new file mode 100644 index 00000000..5c1ceff8 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/IGetEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +public interface IGetEndpoint : IEndpoint +{ + Task> Get(CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/IPostEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/IPostEndpoint.cs new file mode 100644 index 00000000..1f05122e --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/IPostEndpoint.cs @@ -0,0 +1,13 @@ +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +public interface IPostEndpoint : IEndpoint +{ + Task> Post(CancellationToken cancellationToken = default); +} + +public interface IPostEndpoint : IEndpoint +{ + Task> Post(TModel model, CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/IPostGetAllEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/IPostGetAllEndpoint.cs new file mode 100644 index 00000000..7385e8cd --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/IPostGetAllEndpoint.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Client.Endpoints; + +public interface IPostGetAllEndpoint : IPostEndpoint, IGetAllEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/IPutEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/IPutEndpoint.cs new file mode 100644 index 00000000..d7d607b8 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/IPutEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +public interface IPutEndpoint : IEndpoint +{ + Task> Put(TModel model, CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/IUpdateEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/IUpdateEndpoint.cs new file mode 100644 index 00000000..fee9ac03 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/IUpdateEndpoint.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Client.Endpoints; + +public interface IUpdateEndpoint : IGetEndpoint, IPutEndpoint, IDeleteEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/IWithIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/IWithIdEndpoint.cs new file mode 100644 index 00000000..5da4086d --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/IWithIdEndpoint.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Client.Endpoints.Teams; + +namespace iRLeagueApiCore.Client.Endpoints; + +public interface IWithIdEndpoint +{ + TEndpoint WithId(TId id); +} + +public interface IWithIdEndpoint : IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Leagues/ILeagueByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Leagues/ILeagueByIdEndpoint.cs new file mode 100644 index 00000000..49918157 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Leagues/ILeagueByIdEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Leagues; + +public interface ILeagueByIdEndpoint : IUpdateEndpoint +{ + IPostEndpoint Initialize(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Leagues/ILeagueByNameEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Leagues/ILeagueByNameEndpoint.cs new file mode 100644 index 00000000..14664736 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Leagues/ILeagueByNameEndpoint.cs @@ -0,0 +1,39 @@ +using iRLeagueApiCore.Client.Endpoints.Championships; +using iRLeagueApiCore.Client.Endpoints.Members; +using iRLeagueApiCore.Client.Endpoints.Penalties; +using iRLeagueApiCore.Client.Endpoints.Protests; +using iRLeagueApiCore.Client.Endpoints.Results; +using iRLeagueApiCore.Client.Endpoints.Reviews; +using iRLeagueApiCore.Client.Endpoints.Schedules; +using iRLeagueApiCore.Client.Endpoints.Scorings; +using iRLeagueApiCore.Client.Endpoints.Seasons; +using iRLeagueApiCore.Client.Endpoints.Sessions; +using iRLeagueApiCore.Client.Endpoints.Teams; +using iRLeagueApiCore.Client.Endpoints.Users; +using iRLeagueApiCore.Client.Endpoints.VoteCategories; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Leagues; + +public interface ILeagueByNameEndpoint : IGetEndpoint +{ + string Name { get; } + ISeasonsEndpoint Seasons(); + ISchedulesEndpoint Schedules(); + IEventsEndpoint Events(); + IResultsEndpoint Results(); + IResultConfigsEndpoint ResultConfigs(); + IPointRulesEndpoint PointRules(); + IProtestsEndpoint Protests(); + IReviewsEndpoint Reviews(); + IReviewCommentsEndpoint ReviewComments(); + ISessionsEndpoint Sessions(); + ILeagueUsersEndpoint Users(); + ITeamsEndpoint Teams(); + IMembersEndpoint Members(); + IVoteCategoriesEndpoint VoteCategories(); + IChampionshipsEndpoint Championships(); + IChampSeasonsEndpoint ChampSeasons(); + IPenaltiesEndpoint Penalties(); + ICustomEndpoint CustomEndpoint(string route); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Leagues/ILeaguesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Leagues/ILeaguesEndpoint.cs new file mode 100644 index 00000000..b82d9822 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Leagues/ILeaguesEndpoint.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Leagues; + +public interface ILeaguesEndpoint : IGetAllEndpoint +{ + Task> Post(PostLeagueModel model, CancellationToken cancellationToken = default); + ILeagueByIdEndpoint WithId(long leagueId); + ILeagueByNameEndpoint WithName(string name); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Leagues/LeagueByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Leagues/LeagueByIdEndpoint.cs new file mode 100644 index 00000000..2ff18fa5 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Leagues/LeagueByIdEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Leagues; + +internal sealed class LeagueByIdEndpoint : UpdateEndpoint, ILeagueByIdEndpoint +{ + public LeagueByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long leagueId) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(leagueId); + } + + IPostEndpoint ILeagueByIdEndpoint.Initialize() + { + return new PostEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Leagues/LeagueByNameEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Leagues/LeagueByNameEndpoint.cs new file mode 100644 index 00000000..36584486 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Leagues/LeagueByNameEndpoint.cs @@ -0,0 +1,120 @@ +using iRLeagueApiCore.Client.Endpoints.Championships; +using iRLeagueApiCore.Client.Endpoints.Members; +using iRLeagueApiCore.Client.Endpoints.Penalties; +using iRLeagueApiCore.Client.Endpoints.Protests; +using iRLeagueApiCore.Client.Endpoints.Results; +using iRLeagueApiCore.Client.Endpoints.Reviews; +using iRLeagueApiCore.Client.Endpoints.Schedules; +using iRLeagueApiCore.Client.Endpoints.Scorings; +using iRLeagueApiCore.Client.Endpoints.Seasons; +using iRLeagueApiCore.Client.Endpoints.Sessions; +using iRLeagueApiCore.Client.Endpoints.Teams; +using iRLeagueApiCore.Client.Endpoints.Users; +using iRLeagueApiCore.Client.Endpoints.VoteCategories; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Leagues; + +internal sealed class LeagueByNameEndpoint : GetEndpoint, ILeagueByNameEndpoint +{ + public string Name { get; } + + public LeagueByNameEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, string leagueName) : + base(httpClientWrapper, routeBuilder) + { + Name = leagueName; + RouteBuilder.AddParameter(leagueName); + } + + ISchedulesEndpoint ILeagueByNameEndpoint.Schedules() + { + return new SchedulesEndpoint(HttpClientWrapper, RouteBuilder); + } + + ISeasonsEndpoint ILeagueByNameEndpoint.Seasons() + { + return new SeasonsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IEventsEndpoint ILeagueByNameEndpoint.Events() + { + return new EventsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IResultConfigsEndpoint ILeagueByNameEndpoint.ResultConfigs() + { + return new ResultConfigsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IPointRulesEndpoint ILeagueByNameEndpoint.PointRules() + { + return new PointRulesEndpoint(HttpClientWrapper, RouteBuilder); + } + + IReviewsEndpoint ILeagueByNameEndpoint.Reviews() + { + return new ReviewsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IReviewCommentsEndpoint ILeagueByNameEndpoint.ReviewComments() + { + return new ReviewCommentsEndpoint(HttpClientWrapper, RouteBuilder); + } + + ISessionsEndpoint ILeagueByNameEndpoint.Sessions() + { + return new SessionsEndpoint(HttpClientWrapper, RouteBuilder); + } + + ILeagueUsersEndpoint ILeagueByNameEndpoint.Users() + { + return new UsersEndpoint(HttpClientWrapper, RouteBuilder); + } + + IVoteCategoriesEndpoint ILeagueByNameEndpoint.VoteCategories() + { + return new VoteCategoriesEndpoint(HttpClientWrapper, RouteBuilder); + } + + ITeamsEndpoint ILeagueByNameEndpoint.Teams() + { + return new TeamsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IMembersEndpoint ILeagueByNameEndpoint.Members() + { + return new MembersEndpoint(HttpClientWrapper, RouteBuilder); + } + + IProtestsEndpoint ILeagueByNameEndpoint.Protests() + { + return new ProtestsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IChampionshipsEndpoint ILeagueByNameEndpoint.Championships() + { + return new ChampionshipsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IChampSeasonsEndpoint ILeagueByNameEndpoint.ChampSeasons() + { + return new ChampSeasonsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IPenaltiesEndpoint ILeagueByNameEndpoint.Penalties() + { + return new PenaltiesEndpoint(HttpClientWrapper, RouteBuilder); + } + + ICustomEndpoint ILeagueByNameEndpoint.CustomEndpoint(string route) + { + return new CustomEndpoint(HttpClientWrapper, RouteBuilder, route); + } + + IResultsEndpoint ILeagueByNameEndpoint.Results() + { + return new ResultsEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Leagues/LeaguesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Leagues/LeaguesEndpoint.cs new file mode 100644 index 00000000..d524770a --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Leagues/LeaguesEndpoint.cs @@ -0,0 +1,36 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Leagues; + +internal sealed class LeaguesEndpoint : EndpointBase, ILeaguesEndpoint +{ + public LeaguesEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Leagues"); + } + + async Task>> IGetEndpoint>.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult>(QueryUrl, cancellationToken); + } + + async Task> ILeaguesEndpoint.Post(PostLeagueModel model, CancellationToken cancellationToken) + { + return await HttpClientWrapper.PostAsClientActionResult(QueryUrl, model, cancellationToken); + } + + ILeagueByIdEndpoint ILeaguesEndpoint.WithId(long leagueId) + { + return new LeagueByIdEndpoint(HttpClientWrapper, RouteBuilder, leagueId); + } + + ILeagueByNameEndpoint ILeaguesEndpoint.WithName(string leagueName) + { + var withNameBuilder = RouteBuilder.Copy(); + withNameBuilder.RemoveLast(); + return new LeagueByNameEndpoint(HttpClientWrapper, withNameBuilder, leagueName); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Members/IMembersEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Members/IMembersEndpoint.cs new file mode 100644 index 00000000..26fb02c8 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Members/IMembersEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Members; + +public interface IMembersEndpoint : IGetAllEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Members/MembersEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Members/MembersEndpoint.cs new file mode 100644 index 00000000..229786f1 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Members/MembersEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Members; + +internal sealed class MembersEndpoint : GetAllEndpoint, IMembersEndpoint +{ + public MembersEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Members"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Penalties/IPenaltiesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Penalties/IPenaltiesEndpoint.cs new file mode 100644 index 00000000..c1a95de1 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Penalties/IPenaltiesEndpoint.cs @@ -0,0 +1,6 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Penalties; +public interface IPenaltiesEndpoint : IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Penalties/IPenaltyByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Penalties/IPenaltyByIdEndpoint.cs new file mode 100644 index 00000000..f1326688 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Penalties/IPenaltyByIdEndpoint.cs @@ -0,0 +1,6 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Penalties; +public interface IPenaltyByIdEndpoint : IPutEndpoint, IDeleteEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Penalties/PenaltiesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Penalties/PenaltiesEndpoint.cs new file mode 100644 index 00000000..8391d3d5 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Penalties/PenaltiesEndpoint.cs @@ -0,0 +1,25 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Models; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Client.Endpoints.Penalties; +internal sealed class PenaltiesEndpoint : EndpointBase, IPenaltiesEndpoint, IGetAllEndpoint +{ + public PenaltiesEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) + : base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("Penalties"); + } + + public IPenaltyByIdEndpoint WithId(long id) + { + return new PenaltyByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } + + async Task>> IGetEndpoint>.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult>(QueryUrl, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Penalties/PenaltyByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Penalties/PenaltyByIdEndpoint.cs new file mode 100644 index 00000000..44b0a59e --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Penalties/PenaltyByIdEndpoint.cs @@ -0,0 +1,25 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Penalties; + +internal sealed class PenaltyByIdEndpoint : EndpointBase, IPenaltyByIdEndpoint +{ + public PenaltyByIdEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder, long id) + : base(httpClient, routeBuilder) + { + RouteBuilder.AddParameter(id); + } + + public async Task> Delete(CancellationToken cancellationToken = default) + { + return await HttpClientWrapper.DeleteAsClientActionResult(QueryUrl, cancellationToken); + } + + public async Task> Put(PutPenaltyModel model, CancellationToken cancellationToken = default) + { + return await HttpClientWrapper.PutAsClientActionResult(QueryUrl, model, cancellationToken); + } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Client/Endpoints/PostEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/PostEndpoint.cs new file mode 100644 index 00000000..244cfdf3 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/PostEndpoint.cs @@ -0,0 +1,30 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +internal class PostEndpoint : EndpointBase, IPostEndpoint +{ + public PostEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : + base(httpClient, routeBuilder) + { + } + + public async Task> Post(CancellationToken cancellationToken) + { + return await HttpClientWrapper.PostAsClientActionResult(QueryUrl, null, cancellationToken); + } +} + +internal class PostEndpoint : EndpointBase, IPostEndpoint where TModel : notnull +{ + public PostEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { } + + async Task> IPostEndpoint.Post(TModel model, CancellationToken cancellationToken) + { + return await HttpClientWrapper.PostAsClientActionResult(QueryUrl, model, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/PostGetAllEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/PostGetAllEndpoint.cs new file mode 100644 index 00000000..692aabaa --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/PostGetAllEndpoint.cs @@ -0,0 +1,22 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +internal class PostGetAllEndpoint : EndpointBase, IPostGetAllEndpoint where TPost : notnull +{ + public PostGetAllEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : base(httpClientWrapper, routeBuilder) + { + } + + async Task>> IGetEndpoint>.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult>(QueryUrl, cancellationToken); + } + + async Task> IPostEndpoint.Post(TPost model, CancellationToken cancellationToken) + { + return await HttpClientWrapper.PostAsClientActionResult(QueryUrl, model, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Protests/IProtestByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Protests/IProtestByIdEndpoint.cs new file mode 100644 index 00000000..3839c779 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Protests/IProtestByIdEndpoint.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Client.Endpoints.Protests; + +public interface IProtestByIdEndpoint : IDeleteEndpoint +{ +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Client/Endpoints/Protests/IProtestsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Protests/IProtestsEndpoint.cs new file mode 100644 index 00000000..78f6e75b --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Protests/IProtestsEndpoint.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Client.Endpoints.Protests; + +public interface IProtestsEndpoint : IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Protests/ProtestByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Protests/ProtestByIdEndpoint.cs new file mode 100644 index 00000000..da876b46 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Protests/ProtestByIdEndpoint.cs @@ -0,0 +1,13 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.Client.Endpoints.Protests; + +internal sealed class ProtestByIdEndpoint : DeleteEndpoint, IProtestByIdEndpoint +{ + public ProtestByIdEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder, long protestId) : + base(httpClient, routeBuilder) + { + RouteBuilder.AddParameter(protestId); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Protests/ProtestsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Protests/ProtestsEndpoint.cs new file mode 100644 index 00000000..64666c99 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Protests/ProtestsEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Protests; + +internal sealed class ProtestsEndpoint : PostGetAllEndpoint, IProtestsEndpoint +{ + public ProtestsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Protests"); + } + + IProtestByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new ProtestByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Register/AuthenticateEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Register/AuthenticateEndpoint.cs new file mode 100644 index 00000000..c61a575a --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Register/AuthenticateEndpoint.cs @@ -0,0 +1,17 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Register; +internal sealed class AuthenticateEndpoint : EndpointBase, IAuthenticateEndpoint +{ + public AuthenticateEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : base(httpClient, routeBuilder) + { + RouteBuilder.AddParameter("Authenticate"); + } + + public IPostEndpoint Register() + { + return new RegisterEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Register/IAuthenticateEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Register/IAuthenticateEndpoint.cs new file mode 100644 index 00000000..23ca3d9d --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Register/IAuthenticateEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Register; +public interface IAuthenticateEndpoint +{ + IPostEndpoint Register(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Register/RegisterEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Register/RegisterEndpoint.cs new file mode 100644 index 00000000..35d19f87 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Register/RegisterEndpoint.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Register; +internal sealed class RegisterEndpoint : PostEndpoint +{ + public RegisterEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Register"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/CalculateEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/CalculateEndpoint.cs new file mode 100644 index 00000000..1fc10a44 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/CalculateEndpoint.cs @@ -0,0 +1,13 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +internal class CalculateEndpoint : PostEndpoint +{ + public CalculateEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : + base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("Calculate"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/FetchEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/FetchEndpoint.cs new file mode 100644 index 00000000..83311671 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/FetchEndpoint.cs @@ -0,0 +1,16 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.Client.Endpoints.Results; +internal class FetchEndpoint : EndpointBase, IFetchResultsEndpoint +{ + public FetchEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("Fetch"); + } + + IPostEndpoint IFetchResultsEndpoint.FromIracingSubSession(int subSessionId) + { + return new PostEndpoint(HttpClientWrapper, RouteBuilder).AddRouteParameter(subSessionId); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/IEventResultsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/IEventResultsEndpoint.cs new file mode 100644 index 00000000..e0bf3143 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/IEventResultsEndpoint.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Client.ResultsParsing; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +public interface IEventResultsEndpoint : IGetAllEndpoint, IDeleteEndpoint +{ + IPostEndpoint Upload(); + IPostEndpoint Calculate(); + IFetchResultsEndpoint Fetch(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/IFetchResultsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/IFetchResultsEndpoint.cs new file mode 100644 index 00000000..c690b797 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/IFetchResultsEndpoint.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Client.Endpoints.Results; +public interface IFetchResultsEndpoint +{ + public IPostEndpoint FromIracingSubSession(int subSessionId); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/IResultByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/IResultByIdEndpoint.cs new file mode 100644 index 00000000..bacc203c --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/IResultByIdEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +public interface IResultByIdEndpoint : IGetEndpoint +{ + IGetAllEndpoint Penalties(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/IResultConfigByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/IResultConfigByIdEndpoint.cs new file mode 100644 index 00000000..7cfa948a --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/IResultConfigByIdEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +public interface IResultConfigByIdEndpoint : IUpdateEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/IResultConfigsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/IResultConfigsEndpoint.cs new file mode 100644 index 00000000..856fc77c --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/IResultConfigsEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +public interface IResultConfigsEndpoint : IGetAllEndpoint, IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/IResultsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/IResultsEndpoint.cs new file mode 100644 index 00000000..d3b30cd3 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/IResultsEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +public interface IResultsEndpoint : IWithIdEndpoint +{ + public IGetEndpoint> Latest(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/ISeasonResultsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/ISeasonResultsEndpoint.cs new file mode 100644 index 00000000..97208910 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/ISeasonResultsEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +public interface ISeasonResultsEndpoint : IGetAllEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/ResultByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/ResultByIdEndpoint.cs new file mode 100644 index 00000000..1e46ff00 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/ResultByIdEndpoint.cs @@ -0,0 +1,20 @@ +using iRLeagueApiCore.Client.Endpoints.Penalties; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +internal class ResultByIdEndpoint : GetEndpoint, IResultByIdEndpoint +{ + public ResultByIdEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder, long resultId) : + base(httpClient, routeBuilder) + { + RouteBuilder.AddParameter(resultId); + } + + public IGetAllEndpoint Penalties() + { + return new PenaltiesEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/ResultConfigByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/ResultConfigByIdEndpoint.cs new file mode 100644 index 00000000..aad71039 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/ResultConfigByIdEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +internal class ResultConfigByIdEndpoint : UpdateEndpoint, IResultConfigByIdEndpoint +{ + public ResultConfigByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long resultConfigId) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(resultConfigId); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/ResultConfigsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/ResultConfigsEndpoint.cs new file mode 100644 index 00000000..f4c89171 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/ResultConfigsEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +internal class ResultConfigsEndpoint : PostGetAllEndpoint, IResultConfigsEndpoint +{ + public ResultConfigsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("ResultConfigs"); + } + + public IResultConfigByIdEndpoint WithId(long id) + { + return new ResultConfigByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/ResultsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/ResultsEndpoint.cs new file mode 100644 index 00000000..284fd81f --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/ResultsEndpoint.cs @@ -0,0 +1,52 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Client.ResultsParsing; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +internal class ResultsEndpoint : GetAllEndpoint, + IResultsEndpoint, IWithIdEndpoint, IEventResultsEndpoint, ISeasonResultsEndpoint +{ + public ResultsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Results"); + } + + public IPostEndpoint Upload() + { + return new UploadResultEndpoint(HttpClientWrapper, RouteBuilder); + } + + public IResultByIdEndpoint WithId(long id) + { + return new ResultByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } + + IPostEndpoint IEventResultsEndpoint.Calculate() + { + return new CalculateEndpoint(HttpClientWrapper, RouteBuilder); + } + + async Task> IDeleteEndpoint.Delete(CancellationToken cancellationToken) + { + return await HttpClientWrapper.DeleteAsClientActionResult(QueryUrl, cancellationToken); + } + + IFetchResultsEndpoint IEventResultsEndpoint.Fetch() + { + return new FetchEndpoint(HttpClientWrapper, RouteBuilder); + } + + async Task>> IGetEndpoint>.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult>(QueryUrl, cancellationToken); + } + + IGetEndpoint> IResultsEndpoint.Latest() + { + return new GetLatestEndpoint>(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Results/UploadResultEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Results/UploadResultEndpoint.cs new file mode 100644 index 00000000..54133fd3 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Results/UploadResultEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.ResultsParsing; + +namespace iRLeagueApiCore.Client.Endpoints.Results; + +internal sealed class UploadResultEndpoint : PostEndpoint, IPostEndpoint +{ + public UploadResultEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Upload"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewByIdEndpoint.cs new file mode 100644 index 00000000..cf8f9ec3 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewByIdEndpoint.cs @@ -0,0 +1,9 @@ +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.Reviews; + +public interface IReviewByIdEndpoint : IUpdateEndpoint +{ + public IPostEndpoint ReviewComments(); + public IPostEndpoint MoveToSession(long sessionId); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewCommentByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewCommentByIdEndpoint.cs new file mode 100644 index 00000000..34ec8341 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewCommentByIdEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.Reviews; + +public interface IReviewCommentByIdEndpoint : IUpdateEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewCommentsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewCommentsEndpoint.cs new file mode 100644 index 00000000..09fe6e92 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewCommentsEndpoint.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Client.Endpoints.Reviews; + +public interface IReviewCommentsEndpoint : IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewsEndpoint.cs new file mode 100644 index 00000000..1981b9ad --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Reviews/IReviewsEndpoint.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Client.Endpoints.Reviews; + +public interface IReviewsEndpoint : IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Reviews/MoveToSessionEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Reviews/MoveToSessionEndpoint.cs new file mode 100644 index 00000000..5d960b56 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Reviews/MoveToSessionEndpoint.cs @@ -0,0 +1,15 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.Reviews; + +internal sealed class MoveToSessionEndpoint : PostEndpoint, IPostEndpoint +{ + public MoveToSessionEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder, long sessionId) : + base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("MoveToSession"); + RouteBuilder.AddParameter(sessionId); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewByIdEndpoint.cs new file mode 100644 index 00000000..a82432cb --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewByIdEndpoint.cs @@ -0,0 +1,24 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.Reviews; + +internal sealed class ReviewByIdEndpoint : UpdateEndpoint, IReviewByIdEndpoint +{ + public ReviewByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long id) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(id); + } + + public IPostEndpoint MoveToSession(long sessionId) + { + return new MoveToSessionEndpoint(HttpClientWrapper, RouteBuilder, sessionId); + } + + public IPostEndpoint ReviewComments() + { + return new ReviewCommentsEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewCommentByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewCommentByIdEndpoint.cs new file mode 100644 index 00000000..69a8db58 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewCommentByIdEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.Reviews; + +internal sealed class ReviewCommentByIdEndpoint : UpdateEndpoint, IReviewCommentByIdEndpoint +{ + public ReviewCommentByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long id) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewCommentsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewCommentsEndpoint.cs new file mode 100644 index 00000000..04b311db --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewCommentsEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.Reviews; + +internal sealed class ReviewCommentsEndpoint : PostEndpoint, IReviewCommentsEndpoint +{ + public ReviewCommentsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("ReviewComments"); + } + + public IReviewCommentByIdEndpoint WithId(long id) + { + return new ReviewCommentByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewsEndpoint.cs new file mode 100644 index 00000000..e31a3ef0 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Reviews/ReviewsEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.Reviews; + +internal sealed class ReviewsEndpoint : PostGetAllEndpoint, IReviewsEndpoint, IGetAllEndpoint, IPostEndpoint +{ + public ReviewsEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : + base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("Reviews"); + } + + public IReviewByIdEndpoint WithId(long id) + { + return new ReviewByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Schedules/IScheduleByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Schedules/IScheduleByIdEndpoint.cs new file mode 100644 index 00000000..9269c924 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Schedules/IScheduleByIdEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Schedules; + +public interface IScheduleByIdEndpoint : IUpdateEndpoint +{ + IPostGetAllEndpoint Events(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Schedules/ISchedulesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Schedules/ISchedulesEndpoint.cs new file mode 100644 index 00000000..1637426c --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Schedules/ISchedulesEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Schedules; + +public interface ISchedulesEndpoint : IPostGetAllEndpoint, IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Schedules/ScheduleByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Schedules/ScheduleByIdEndpoint.cs new file mode 100644 index 00000000..be9d136b --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Schedules/ScheduleByIdEndpoint.cs @@ -0,0 +1,20 @@ +using iRLeagueApiCore.Client.Endpoints.Sessions; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Schedules; + +internal class ScheduleByIdEndpoint : UpdateEndpoint, IScheduleByIdEndpoint +{ + public ScheduleByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long scheduleId) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(scheduleId); + } + + public IPostGetAllEndpoint Events() + { + return new EventsEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Schedules/SchedulesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Schedules/SchedulesEndpoint.cs new file mode 100644 index 00000000..f1b5f0e5 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Schedules/SchedulesEndpoint.cs @@ -0,0 +1,18 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Schedules; + +internal class SchedulesEndpoint : PostGetAllEndpoint, ISchedulesEndpoint +{ + public SchedulesEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Schedules"); + } + + IScheduleByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new ScheduleByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Scorings/IPointRuleByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Scorings/IPointRuleByIdEndpoint.cs new file mode 100644 index 00000000..091d9a00 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Scorings/IPointRuleByIdEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Scorings; + +public interface IPointRuleByIdEndpoint : IUpdateEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Scorings/IPointRulesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Scorings/IPointRulesEndpoint.cs new file mode 100644 index 00000000..f0626b0b --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Scorings/IPointRulesEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Scorings; + +public interface IPointRulesEndpoint : IPostEndpoint, IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Scorings/IScoringByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Scorings/IScoringByIdEndpoint.cs new file mode 100644 index 00000000..343e6d04 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Scorings/IScoringByIdEndpoint.cs @@ -0,0 +1,10 @@ +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Scorings; + +public interface IScoringByIdEndpoint : IUpdateEndpoint +{ + IPostEndpoint AddSession(long sessionId); + IPostEndpoint RemoveSession(long sessionId); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Scorings/IScoringsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Scorings/IScoringsEndpoint.cs new file mode 100644 index 00000000..bb05edfd --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Scorings/IScoringsEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Scorings; + +public interface IScoringsEndpoint : IPostGetAllEndpoint, IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Scorings/PointRuleByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Scorings/PointRuleByIdEndpoint.cs new file mode 100644 index 00000000..751c7976 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Scorings/PointRuleByIdEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Scorings; + +internal class PointRuleByIdEndpoint : UpdateEndpoint, IPointRuleByIdEndpoint +{ + public PointRuleByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long pointRuleId) : + base(httpClientWrapper, routeBuilder) + { + routeBuilder.AddParameter(pointRuleId); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Scorings/PointRulesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Scorings/PointRulesEndpoint.cs new file mode 100644 index 00000000..f1d878a9 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Scorings/PointRulesEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Scorings; + +internal class PointRulesEndpoint : PostEndpoint, IPointRulesEndpoint +{ + public PointRulesEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + routeBuilder.AddEndpoint("PointRules"); + } + + public IPointRuleByIdEndpoint WithId(long id) + { + return new PointRuleByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Scorings/ScoringByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Scorings/ScoringByIdEndpoint.cs new file mode 100644 index 00000000..1ba2984f --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Scorings/ScoringByIdEndpoint.cs @@ -0,0 +1,31 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Scorings; + +internal class ScoringByIdEndpoint : UpdateEndpoint, IScoringByIdEndpoint +{ + public ScoringByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long scoringId) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(scoringId); + } + + IPostEndpoint IScoringByIdEndpoint.AddSession(long sessionId) + { + var addSessionBuilder = RouteBuilder.Copy(); + addSessionBuilder.AddEndpoint("AddSession"); + addSessionBuilder.AddParameter(sessionId); + return new PostEndpoint(HttpClientWrapper, addSessionBuilder); + } + + IPostEndpoint IScoringByIdEndpoint.RemoveSession(long sessionId) + { + var removeSessionBuilder = RouteBuilder.Copy(); + removeSessionBuilder.AddEndpoint("RemoveSession"); + removeSessionBuilder.AddParameter(sessionId); + return new PostEndpoint(HttpClientWrapper, removeSessionBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Scorings/ScoringsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Scorings/ScoringsEndpoint.cs new file mode 100644 index 00000000..edfe8956 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Scorings/ScoringsEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Scorings; + +internal class ScoringsEndpoint : PostGetAllEndpoint, IScoringsEndpoint +{ + public ScoringsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Scorings"); + } + + IScoringByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new ScoringByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Seasons/CurrentSeasonEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Seasons/CurrentSeasonEndpoint.cs new file mode 100644 index 00000000..cab3c114 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Seasons/CurrentSeasonEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Seasons; + +internal sealed class CurrentSeasonEndpoint : GetEndpoint +{ + public CurrentSeasonEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : + base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("Current"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Seasons/ISeasonByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Seasons/ISeasonByIdEndpoint.cs new file mode 100644 index 00000000..66c40954 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Seasons/ISeasonByIdEndpoint.cs @@ -0,0 +1,18 @@ +using iRLeagueApiCore.Client.Endpoints.Championships; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Standings; + +namespace iRLeagueApiCore.Client.Endpoints.Seasons; + +public interface ISeasonByIdEndpoint : IUpdateEndpoint +{ + long Id { get; } + IPostGetAllEndpoint Schedules(); + IPostGetAllEndpoint Scorings(); + IGetAllEndpoint Results(); + IGetAllEndpoint Events(); + IGetAllEndpoint Standings(); + IGetAllEndpoint ResultsConfigs(); + ISeasonChampionshipsEndpoint Championships(); + ISeasonChampSeasonsEndpoint ChampSeasons(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Seasons/ISeasonsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Seasons/ISeasonsEndpoint.cs new file mode 100644 index 00000000..a3601be6 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Seasons/ISeasonsEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Seasons; + +public interface ISeasonsEndpoint : IPostEndpoint, IGetAllEndpoint, IWithIdEndpoint +{ + IGetEndpoint Current(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Seasons/SeasonByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Seasons/SeasonByIdEndpoint.cs new file mode 100644 index 00000000..e2ee9c3d --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Seasons/SeasonByIdEndpoint.cs @@ -0,0 +1,64 @@ +using iRLeagueApiCore.Client.Endpoints.Championships; +using iRLeagueApiCore.Client.Endpoints.Results; +using iRLeagueApiCore.Client.Endpoints.Schedules; +using iRLeagueApiCore.Client.Endpoints.Scorings; +using iRLeagueApiCore.Client.Endpoints.Sessions; +using iRLeagueApiCore.Client.Endpoints.Standings; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Standings; + +namespace iRLeagueApiCore.Client.Endpoints.Seasons; + +internal class SeasonByIdEndpoint : UpdateEndpoint, ISeasonByIdEndpoint +{ + public long Id { get; } + + public SeasonByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long seasonId) : + base(httpClientWrapper, routeBuilder) + { + Id = seasonId; + RouteBuilder.AddParameter(seasonId); + } + + IGetAllEndpoint ISeasonByIdEndpoint.Results() + { + return new ResultsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IGetAllEndpoint ISeasonByIdEndpoint.Events() + { + return new EventsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IPostGetAllEndpoint ISeasonByIdEndpoint.Schedules() + { + return new SchedulesEndpoint(HttpClientWrapper, RouteBuilder); + } + + IPostGetAllEndpoint ISeasonByIdEndpoint.Scorings() + { + return new ScoringsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IGetAllEndpoint ISeasonByIdEndpoint.Standings() + { + return new StandingsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IGetAllEndpoint ISeasonByIdEndpoint.ResultsConfigs() + { + return new ResultConfigsEndpoint(HttpClientWrapper, RouteBuilder); + } + + ISeasonChampionshipsEndpoint ISeasonByIdEndpoint.Championships() + { + return new ChampionshipsEndpoint(HttpClientWrapper, RouteBuilder); + } + + ISeasonChampSeasonsEndpoint ISeasonByIdEndpoint.ChampSeasons() + { + return new ChampSeasonsEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Seasons/SeasonsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Seasons/SeasonsEndpoint.cs new file mode 100644 index 00000000..1727e277 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Seasons/SeasonsEndpoint.cs @@ -0,0 +1,24 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Seasons; + +internal class SeasonsEndpoint : PostGetAllEndpoint, ISeasonsEndpoint +{ + public SeasonsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Seasons"); + } + + IGetEndpoint ISeasonsEndpoint.Current() + { + return new CurrentSeasonEndpoint(HttpClientWrapper, RouteBuilder); + } + + ISeasonByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new SeasonByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Sessions/EventByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Sessions/EventByIdEndpoint.cs new file mode 100644 index 00000000..9d3cfdd4 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Sessions/EventByIdEndpoint.cs @@ -0,0 +1,53 @@ +using iRLeagueApiCore.Client.Endpoints.Cars; +using iRLeagueApiCore.Client.Endpoints.Members; +using iRLeagueApiCore.Client.Endpoints.Protests; +using iRLeagueApiCore.Client.Endpoints.Results; +using iRLeagueApiCore.Client.Endpoints.Reviews; +using iRLeagueApiCore.Client.Endpoints.Standings; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Results; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Common.Models.Standings; + +namespace iRLeagueApiCore.Client.Endpoints.Sessions; + +internal class EventByIdEndpoint : UpdateEndpoint, IEventByIdEndpoint +{ + public EventByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long EventId) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(EventId); + } + + public IGetAllEndpoint Members() + { + return new MembersEndpoint(HttpClientWrapper, RouteBuilder); + } + + public IGetEndpoint Cars() + { + return new CarsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IGetAllEndpoint IEventByIdEndpoint.Protests() + { + return new ProtestsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IEventResultsEndpoint IEventByIdEndpoint.Results() + { + return new ResultsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IGetAllEndpoint IEventByIdEndpoint.Reviews() + { + return new ReviewsEndpoint(HttpClientWrapper, RouteBuilder); + } + + IGetAllEndpoint IEventByIdEndpoint.Standings() + { + return new StandingsEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Sessions/EventsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Sessions/EventsEndpoint.cs new file mode 100644 index 00000000..51891c5b --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Sessions/EventsEndpoint.cs @@ -0,0 +1,20 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Sessions; + +internal class EventsEndpoint : PostGetAllEndpoint, IEventsEndpoint, + IPostEndpoint, IGetAllEndpoint, IWithIdEndpoint +{ + public EventsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Events"); + } + + IEventByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new EventByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Sessions/IEventByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Sessions/IEventByIdEndpoint.cs new file mode 100644 index 00000000..90fdf4ed --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Sessions/IEventByIdEndpoint.cs @@ -0,0 +1,17 @@ +using iRLeagueApiCore.Client.Endpoints.Results; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Results; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Common.Models.Standings; + +namespace iRLeagueApiCore.Client.Endpoints.Sessions; + +public interface IEventByIdEndpoint : IUpdateEndpoint +{ + IEventResultsEndpoint Results(); + IGetAllEndpoint Reviews(); + IGetAllEndpoint Members(); + IGetAllEndpoint Standings(); + IGetAllEndpoint Protests(); + IGetEndpoint Cars(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Sessions/IEventsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Sessions/IEventsEndpoint.cs new file mode 100644 index 00000000..854c2ee5 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Sessions/IEventsEndpoint.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Client.Endpoints.Sessions; + +public interface IEventsEndpoint : IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Sessions/ISessionByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Sessions/ISessionByIdEndpoint.cs new file mode 100644 index 00000000..96a48d97 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Sessions/ISessionByIdEndpoint.cs @@ -0,0 +1,10 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.Sessions; + +public interface ISessionByIdEndpoint +{ + public IPostEndpoint Reviews(); + public IPostEndpoint Protests(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Sessions/ISessionsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Sessions/ISessionsEndpoint.cs new file mode 100644 index 00000000..5ade30ca --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Sessions/ISessionsEndpoint.cs @@ -0,0 +1,6 @@ + +namespace iRLeagueApiCore.Client.Endpoints.Sessions; + +public interface ISessionsEndpoint : IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Sessions/SessionByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Sessions/SessionByIdEndpoint.cs new file mode 100644 index 00000000..c5783dbe --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Sessions/SessionByIdEndpoint.cs @@ -0,0 +1,27 @@ +using iRLeagueApiCore.Client.Endpoints.Protests; +using iRLeagueApiCore.Client.Endpoints.Reviews; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.Sessions; + +internal sealed class SessionByIdEndpoint : EndpointBase, ISessionByIdEndpoint +{ + public SessionByIdEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder, long sessionId) : + base(httpClient, routeBuilder) + { + RouteBuilder.AddParameter(sessionId); + } + + public IPostEndpoint Reviews() + { + return new ReviewsEndpoint(HttpClientWrapper, RouteBuilder); + } + + public IPostEndpoint Protests() + { + return new ProtestsEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Sessions/SessionsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Sessions/SessionsEndpoint.cs new file mode 100644 index 00000000..aefb013d --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Sessions/SessionsEndpoint.cs @@ -0,0 +1,20 @@ + + +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.Client.Endpoints.Sessions; + +internal sealed class SessionsEndpoint : EndpointBase, ISessionsEndpoint +{ + public SessionsEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : + base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("Sessions"); + } + + public ISessionByIdEndpoint WithId(long id) + { + return new SessionByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Standings/IStandingsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Standings/IStandingsEndpoint.cs new file mode 100644 index 00000000..823aeab6 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Standings/IStandingsEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models.Standings; + +namespace iRLeagueApiCore.Client.Endpoints.Standings; + +public interface IStandingsEndpoint : IGetAllEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Standings/StandingsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Standings/StandingsEndpoint.cs new file mode 100644 index 00000000..1c7f4157 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Standings/StandingsEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Standings; + +namespace iRLeagueApiCore.Client.Endpoints.Standings; + +internal sealed class StandingsEndpoint : GetAllEndpoint, IStandingsEndpoint +{ + public StandingsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Standings"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Teams/ITeamByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Teams/ITeamByIdEndpoint.cs new file mode 100644 index 00000000..dfa666ad --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Teams/ITeamByIdEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Teams; + +public interface ITeamByIdEndpoint : IUpdateEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Teams/ITeamsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Teams/ITeamsEndpoint.cs new file mode 100644 index 00000000..488c931b --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Teams/ITeamsEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Teams; + +public interface ITeamsEndpoint : IPostGetAllEndpoint, IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Teams/TeamByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Teams/TeamByIdEndpoint.cs new file mode 100644 index 00000000..f8333cbb --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Teams/TeamByIdEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Teams; + +internal sealed class TeamByIdEndpoint : UpdateEndpoint, ITeamByIdEndpoint +{ + public TeamByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long teamId) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(teamId); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Teams/TeamsEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Teams/TeamsEndpoint.cs new file mode 100644 index 00000000..f1a86c4e --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Teams/TeamsEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Client.Endpoints.Teams; + +internal sealed class TeamsEndpoint : PostGetAllEndpoint, ITeamsEndpoint +{ + public TeamsEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Teams"); + } + + ITeamByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new TeamByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Tracks/ITracksEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Tracks/ITracksEndpoint.cs new file mode 100644 index 00000000..7202387c --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Tracks/ITracksEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models.Tracks; + +namespace iRLeagueApiCore.Client.Endpoints.Tracks; + +public interface ITracksEndpoint : IGetAllEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Tracks/TracksEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Tracks/TracksEndpoint.cs new file mode 100644 index 00000000..14f2d279 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Tracks/TracksEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Tracks; + +namespace iRLeagueApiCore.Client.Endpoints.Tracks; + +internal sealed class TracksEndpoint : GetAllEndpoint, ITracksEndpoint +{ + public TracksEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Tracks"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/UpdateEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/UpdateEndpoint.cs new file mode 100644 index 00000000..21f8ee00 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/UpdateEndpoint.cs @@ -0,0 +1,28 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; + +namespace iRLeagueApiCore.Client.Endpoints; + +internal class UpdateEndpoint : EndpointBase, IUpdateEndpoint where TModel : notnull +{ + public UpdateEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + } + + async Task> IDeleteEndpoint.Delete(CancellationToken cancellationToken) + { + return await HttpClientWrapper.DeleteAsClientActionResult(QueryUrl, cancellationToken); + } + + async Task> IGetEndpoint.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult(QueryUrl, cancellationToken); + } + + async Task> IPutEndpoint.Put(TModel model, CancellationToken cancellationToken) + { + return await HttpClientWrapper.PutAsClientActionResult(QueryUrl, model, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/AddRoleEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/AddRoleEndpoint.cs new file mode 100644 index 00000000..2b034e34 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/AddRoleEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Users; + +internal sealed class AddRoleEndpoint : PostEndpoint, IPostEndpoint +{ + public AddRoleEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("AddRole"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/ConfirmEmailEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/ConfirmEmailEndpoint.cs new file mode 100644 index 00000000..3f721769 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/ConfirmEmailEndpoint.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.Client.Endpoints.Users; +internal class ConfirmEmailEndpoint : PostEndpoint +{ + public ConfirmEmailEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder, string token) : base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("confirm"); + RouteBuilder.AddParameter(token); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/ILeagueUserByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/ILeagueUserByIdEndpoint.cs new file mode 100644 index 00000000..0c45cb97 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/ILeagueUserByIdEndpoint.cs @@ -0,0 +1,9 @@ +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Users; + +public interface ILeagueUserByIdEndpoint : IGetEndpoint +{ + IPostEndpoint AddRole(); + IPostEndpoint RemoveRole(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/ILeagueUsersEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/ILeagueUsersEndpoint.cs new file mode 100644 index 00000000..73722ff1 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/ILeagueUsersEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Users; + +public interface ILeagueUsersEndpoint : IGetAllEndpoint +{ + ILeagueUserByIdEndpoint WithId(string id); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/IUserByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/IUserByIdEndpoint.cs new file mode 100644 index 00000000..a58525ca --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/IUserByIdEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Users; + +public interface IUserByIdEndpoint : IGetEndpoint, IPutEndpoint +{ + IPostEndpoint ConfirmEmail(string token); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/IUsersEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/IUsersEndpoint.cs new file mode 100644 index 00000000..0d9f1256 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/IUsersEndpoint.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Users; + +public interface IUsersEndpoint +{ + IUserByIdEndpoint WithId(string id); + IPostEndpoint, SearchModel> Search(); + IPostEndpoint ResendConfirmation(); +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/RemoveRoleEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/RemoveRoleEndpoint.cs new file mode 100644 index 00000000..6a32a75a --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/RemoveRoleEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Users; + +internal sealed class RemoveRoleEndpoint : PostEndpoint, IPostEndpoint +{ + public RemoveRoleEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("RemoveRole"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/ResendConfirmationEmailEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/ResendConfirmationEmailEndpoint.cs new file mode 100644 index 00000000..c946c1c7 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/ResendConfirmationEmailEndpoint.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.Client.Endpoints.Users; +internal sealed class ResendConfirmationEmailEndpoint : PostEndpoint +{ + public ResendConfirmationEmailEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("ResendConfirmation"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/SearchEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/SearchEndpoint.cs new file mode 100644 index 00000000..7d3b7048 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/SearchEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Users; + +internal sealed class SearchEndpoint : PostEndpoint, SearchModel>, IPostEndpoint, SearchModel> +{ + public SearchEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("Search"); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/UserByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/UserByIdEndpoint.cs new file mode 100644 index 00000000..57e1f076 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/UserByIdEndpoint.cs @@ -0,0 +1,45 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Users; + +internal sealed class UserByIdEndpoint : EndpointBase, IUserByIdEndpoint, ILeagueUserByIdEndpoint +{ + public UserByIdEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder, string id) : + base(httpClient, routeBuilder) + { + RouteBuilder.AddParameter(id); + } + + IPostEndpoint ILeagueUserByIdEndpoint.AddRole() + { + return new AddRoleEndpoint(HttpClientWrapper, RouteBuilder); + } + + IPostEndpoint IUserByIdEndpoint.ConfirmEmail(string token) + { + return new ConfirmEmailEndpoint(HttpClientWrapper, RouteBuilder, token); + } + + async Task> IGetEndpoint.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult(QueryUrl, cancellationToken); + } + + async Task> IGetEndpoint.Get(CancellationToken cancellationToken) + { + return await HttpClientWrapper.GetAsClientActionResult(QueryUrl, cancellationToken); + } + + async Task> IPutEndpoint.Put(PutUserModel model, CancellationToken cancellationToken) + { + return await HttpClientWrapper.PutAsClientActionResult(QueryUrl, model, cancellationToken); + } + + IPostEndpoint ILeagueUserByIdEndpoint.RemoveRole() + { + return new RemoveRoleEndpoint(HttpClientWrapper, RouteBuilder); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/Users/UsersEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/Users/UsersEndpoint.cs new file mode 100644 index 00000000..9cb16a35 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/Users/UsersEndpoint.cs @@ -0,0 +1,34 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client.Endpoints.Users; + +internal sealed class UsersEndpoint : GetAllEndpoint, IUsersEndpoint, ILeagueUsersEndpoint +{ + public UsersEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : base(httpClient, routeBuilder) + { + RouteBuilder.AddEndpoint("Users"); + } + + public IUserByIdEndpoint WithId(string id) + { + return new UserByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } + + IPostEndpoint IUsersEndpoint.ResendConfirmation() + { + return new ResendConfirmationEmailEndpoint(HttpClientWrapper, RouteBuilder); + } + + IPostEndpoint, SearchModel> IUsersEndpoint.Search() + { + return new SearchEndpoint(HttpClientWrapper, RouteBuilder); + } + + ILeagueUserByIdEndpoint ILeagueUsersEndpoint.WithId(string id) + { + return new UserByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/IVoteCategoriesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/IVoteCategoriesEndpoint.cs new file mode 100644 index 00000000..d4d69755 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/IVoteCategoriesEndpoint.cs @@ -0,0 +1,7 @@ +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.VoteCategories; + +public interface IVoteCategoriesEndpoint : IPostGetAllEndpoint, IWithIdEndpoint +{ +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/IVoteCategoryByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/IVoteCategoryByIdEndpoint.cs new file mode 100644 index 00000000..8a5a3fe7 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/IVoteCategoryByIdEndpoint.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Client.Endpoints; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.VoteCategories; + +public interface IVoteCategoryByIdEndpoint : IUpdateEndpoint +{ +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/VoteCategoriesEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/VoteCategoriesEndpoint.cs new file mode 100644 index 00000000..904b4964 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/VoteCategoriesEndpoint.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.VoteCategories; + +internal sealed class VoteCategoriesEndpoint : PostGetAllEndpoint, IVoteCategoriesEndpoint +{ + public VoteCategoriesEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddEndpoint("VoteCategories"); + } + + IVoteCategoryByIdEndpoint IWithIdEndpoint.WithId(long id) + { + return new VoteCategoryByIdEndpoint(HttpClientWrapper, RouteBuilder, id); + } +} diff --git a/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/VoteCategoryByIdEndpoint.cs b/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/VoteCategoryByIdEndpoint.cs new file mode 100644 index 00000000..4eaaa878 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Endpoints/VoteCategories/VoteCategoryByIdEndpoint.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Client.Endpoints.VoteCategories; + +internal sealed class VoteCategoryByIdEndpoint : UpdateEndpoint, IVoteCategoryByIdEndpoint +{ + public VoteCategoryByIdEndpoint(HttpClientWrapper httpClientWrapper, RouteBuilder routeBuilder, long id) : + base(httpClientWrapper, routeBuilder) + { + RouteBuilder.AddParameter(id); + } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Client/Http/ApiServiceUnavailableException.cs b/src/iRLeagueApiCore.Client/Http/ApiServiceUnavailableException.cs new file mode 100644 index 00000000..e7634789 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Http/ApiServiceUnavailableException.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace iRLeagueApiCore.Client.Http; +public sealed class ApiServiceUnavailableException : Exception +{ + public ApiServiceUnavailableException() : this(null) + { + } + + public ApiServiceUnavailableException(Exception? innerException) : this("iRLeagueApi service is not available or did not respond to the request", innerException) + { + } + + public ApiServiceUnavailableException(string? message, Exception? innerException) : base(message, innerException) + { + } +} diff --git a/src/iRLeagueApiCore.Client/Http/DefaultTokenStore.cs b/src/iRLeagueApiCore.Client/Http/DefaultTokenStore.cs new file mode 100644 index 00000000..d7a931c1 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Http/DefaultTokenStore.cs @@ -0,0 +1,65 @@ +using Microsoft.Extensions.Logging; +using System.IdentityModel.Tokens.Jwt; +using System.Reflection.Metadata; + +namespace iRLeagueApiCore.Client.Http; +internal sealed class DefaultTokenStore : ITokenStore +{ + private string idToken = string.Empty; + private string accessToken = string.Empty; + + public bool IsLoggedIn => throw new NotImplementedException(); + + public DateTime AccessTokenExpires { get; private set; } + public bool AccessTokenExpired { get; set; } + + public event EventHandler? TokenChanged; + public event EventHandler? TokenExpired; + + public async Task ClearTokensAsync() + { + idToken = string.Empty; + accessToken = string.Empty; + TokenChanged?.Invoke(this, EventArgs.Empty); + await Task.CompletedTask; + } + + public async Task GetAccessTokenAsync() + { + if (AccessTokenExpires <= DateTime.UtcNow && string.IsNullOrEmpty(accessToken) == false && AccessTokenExpired == false) + { + AccessTokenExpired = true; + TokenExpired?.Invoke(this, EventArgs.Empty); + } + return await Task.FromResult(accessToken); + } + + public async Task GetIdTokenAsync() + { + return await Task.FromResult(idToken); + } + + public async Task SetAccessTokenAsync(string token) + { + accessToken = token; + AccessTokenExpired = false; + if (string.IsNullOrEmpty(accessToken) == false) + { + // set expiration date + var jwtToken = new JwtSecurityTokenHandler().ReadToken(accessToken); + AccessTokenExpires = jwtToken.ValidTo; + } + TokenChanged?.Invoke(this, EventArgs.Empty); + await Task.CompletedTask; + } + + public async Task SetIdTokenAsync(string token) + { + if (token != idToken) + { + idToken = token; + TokenChanged?.Invoke(this, EventArgs.Empty); + } + await Task.CompletedTask; + } +} diff --git a/src/iRLeagueApiCore.Client/Http/HttpClientWrapper.cs b/src/iRLeagueApiCore.Client/Http/HttpClientWrapper.cs new file mode 100644 index 00000000..7b2bc587 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Http/HttpClientWrapper.cs @@ -0,0 +1,143 @@ +using iRLeagueApiCore.Client.Results; +using Microsoft.Extensions.Logging; +using System.Diagnostics; +using System.Globalization; +using System.Net.Http.Headers; +using System.Text; +using System.Text.Json; + +namespace iRLeagueApiCore.Client.Http; + +public sealed class HttpClientWrapper +{ + private readonly HttpClient httpClient; + private readonly ILogger logger; + private readonly IAsyncTokenProvider tokenProvider; + private readonly ILeagueApiClient? apiClient; + private readonly JsonSerializerOptions? jsonOptions; + + public Uri? BaseAddress => httpClient.BaseAddress; + + public HttpClientWrapper(HttpClient httpClient, ILogger logger, IAsyncTokenProvider tokenProvider, ILeagueApiClient? apiClient = default, JsonSerializerOptions? jsonOptions = default) + { + this.httpClient = httpClient; + this.tokenProvider = tokenProvider; + this.apiClient = apiClient; + this.jsonOptions = jsonOptions; + this.logger = logger; + } + + public async Task Get(string uri, CancellationToken cancellationToken) + { + var request = new HttpRequestMessage(HttpMethod.Get, new Uri(uri, UriKind.RelativeOrAbsolute)); + return await SendRequest(request, cancellationToken); + } + + public async Task Post(string uri, object? data, CancellationToken cancellationToken) + { + var request = new HttpRequestMessage(HttpMethod.Post, new Uri(uri, UriKind.RelativeOrAbsolute)); + request.Content = new StringContent(JsonSerializer.Serialize(data, jsonOptions), Encoding.UTF8, "application/json"); + return await SendRequest(request, cancellationToken); + } + + public async Task Put(string uri, object? data, CancellationToken cancellationToken) + { + var request = new HttpRequestMessage(HttpMethod.Put, new Uri(uri, UriKind.RelativeOrAbsolute)); + request.Content = new StringContent(JsonSerializer.Serialize(data, jsonOptions), Encoding.UTF8, "application/json"); + return await SendRequest(request, cancellationToken); + } + + public async Task Delete(string uri, CancellationToken cancellationToken) + { + var request = new HttpRequestMessage(HttpMethod.Delete, new Uri(uri, UriKind.RelativeOrAbsolute)); + return await SendRequest(request, cancellationToken); + } + + public async Task SendRequest(HttpRequestMessage request, CancellationToken cancellationToken) + { + request.Options.TryGetValue(new HttpRequestOptionsKey("SkipAuth"), out bool skipAuth); + if (skipAuth == false) + { + if (apiClient is not null) + { + await apiClient.CheckLogin(cancellationToken); + } + await AddJWTTokenAsync(request); + } + + try + { +#if DEBUG + logger.LogDebug("Send request: [{Method}] {RequestUrl}", request.Method, request.RequestUri); +#endif + var result = await httpClient.SendAsync(request, cancellationToken); +#if DEBUG + logger.LogDebug("Returned: [StatusCode {StatusCode}]", result.StatusCode); +#endif + + if (result.StatusCode == System.Net.HttpStatusCode.Unauthorized && apiClient is not null) + { + logger.LogDebug("Logout on unauthorized response"); + // logout on unauthorized answer -> means something is wrong with our tokens + await apiClient.LogOut(); + } + return result; + } + catch (HttpRequestException ex) + { + throw new ApiServiceUnavailableException(ex); + } + } + + public HttpRequestMessage CreateRequest(HttpMethod method, string uri, object? content, HttpRequestOptions? options = default) + { + var request = new HttpRequestMessage(method, new Uri(uri, UriKind.RelativeOrAbsolute)); + if (options is not null) + { + foreach(var option in options) + { + request.Options.TryAdd(option.Key, option.Value); + } + } + if (content is not null) + { + request.Content = new StringContent(JsonSerializer.Serialize(content, jsonOptions), Encoding.UTF8, "application/json"); + } + return request; + } + + public async Task> ConvertToClientActionResult(HttpResponseMessage message, CancellationToken cancellationToken) + { + return await message.ToClientActionResultAsync(jsonOptions, cancellationToken); + } + + private async Task AddJWTTokenAsync(HttpRequestMessage request) + { + var token = await tokenProvider.GetAccessTokenAsync(); + + if (string.IsNullOrEmpty(token) == false) + { + request.Headers.Authorization = new AuthenticationHeaderValue("bearer", token); + } + } + + public async Task> GetAsClientActionResult(string query, CancellationToken cancellationToken = default) + { + return await Get(query, cancellationToken).AsClientActionResultAsync(jsonOptions, cancellationToken); + } + + public async Task> PostAsClientActionResult(string query, object? body, CancellationToken cancellationToken = default) + { + return await Post(query, body, cancellationToken).AsClientActionResultAsync(jsonOptions, cancellationToken); + } + + public async Task> PutAsClientActionResult(string query, object? body, CancellationToken cancellationToken = default) + { + return await Put(query, body, cancellationToken).AsClientActionResultAsync(jsonOptions, cancellationToken); + } + + public async Task> DeleteAsClientActionResult(string query, CancellationToken cancellationToken = default) + { + return await Delete(query, cancellationToken).AsClientActionResultAsync(jsonOptions, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Http/HttpClientWrapperFactory.cs b/src/iRLeagueApiCore.Client/Http/HttpClientWrapperFactory.cs new file mode 100644 index 00000000..4aa6911c --- /dev/null +++ b/src/iRLeagueApiCore.Client/Http/HttpClientWrapperFactory.cs @@ -0,0 +1,20 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; + +namespace iRLeagueApiCore.Client.Http; +public sealed class HttpClientWrapperFactory +{ + private readonly ILoggerFactory loggerFactory; + private readonly JsonSerializerOptions? jsonOptions; + + public HttpClientWrapperFactory(ILoggerFactory loggerFactory, JsonSerializerOptions? jsonOptions = null) + { + this.loggerFactory = loggerFactory; + this.jsonOptions = jsonOptions; + } + + public HttpClientWrapper Create(HttpClient httpClient, IAsyncTokenProvider tokenProvider, LeagueApiClient? apiClient = null) + { + return new(httpClient, loggerFactory.CreateLogger(), tokenProvider, apiClient, jsonOptions); + } +} diff --git a/src/iRLeagueApiCore.Client/Http/IAsyncTokenProvider.cs b/src/iRLeagueApiCore.Client/Http/IAsyncTokenProvider.cs new file mode 100644 index 00000000..057c0ea6 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Http/IAsyncTokenProvider.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Client.Http; + +public interface IAsyncTokenProvider +{ + event EventHandler TokenChanged; + event EventHandler TokenExpired; + + Task GetIdTokenAsync(); + Task GetAccessTokenAsync(); +} diff --git a/src/iRLeagueApiCore.Client/Http/ITokenStore.cs b/src/iRLeagueApiCore.Client/Http/ITokenStore.cs new file mode 100644 index 00000000..6893dac4 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Http/ITokenStore.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Client.Http; + +public interface ITokenStore : IAsyncTokenProvider +{ + bool IsLoggedIn { get; } + DateTime AccessTokenExpires { get; } + Task SetIdTokenAsync(string token); + Task SetAccessTokenAsync(string token); + Task ClearTokensAsync(); +} diff --git a/src/iRLeagueApiCore.Client/ILeagueApiClient.cs b/src/iRLeagueApiCore.Client/ILeagueApiClient.cs new file mode 100644 index 00000000..383d9a11 --- /dev/null +++ b/src/iRLeagueApiCore.Client/ILeagueApiClient.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Client.Endpoints; +using iRLeagueApiCore.Client.Endpoints.Leagues; +using iRLeagueApiCore.Client.Endpoints.Register; +using iRLeagueApiCore.Client.Endpoints.Seasons; +using iRLeagueApiCore.Client.Endpoints.Tracks; +using iRLeagueApiCore.Client.Endpoints.Users; +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.Client; + +public interface ILeagueApiClient +{ + bool IsLoggedIn { get; } + Uri? BaseAddress { get; } + ILeagueByNameEndpoint? CurrentLeague { get; } + ISeasonByIdEndpoint? CurrentSeason { get; } + ILeaguesEndpoint Leagues(); + IUsersEndpoint Users(); + ITracksEndpoint Tracks(); + ICustomEndpoint CustomEndpoint(string route); + Task> LogIn(string username, string password, CancellationToken cancellationToken = default); + Task Reauthorize(CancellationToken cancellationToken = default); + Task CheckLogin(CancellationToken cancellationToken = default); + Task LogOut(); + IAuthenticateEndpoint Authenticate(); + void SetCurrentLeague(string leagueName); + void SetCurrentSeason(string leagueName, long seasonId); +} diff --git a/src/iRLeagueApiCore.Client/LeagueApiClient.cs b/src/iRLeagueApiCore.Client/LeagueApiClient.cs new file mode 100644 index 00000000..fc46491e --- /dev/null +++ b/src/iRLeagueApiCore.Client/LeagueApiClient.cs @@ -0,0 +1,246 @@ +using iRLeagueApiCore.Client.Endpoints; +using iRLeagueApiCore.Client.Endpoints.Leagues; +using iRLeagueApiCore.Client.Endpoints.Register; +using iRLeagueApiCore.Client.Endpoints.Seasons; +using iRLeagueApiCore.Client.Endpoints.Tracks; +using iRLeagueApiCore.Client.Endpoints.Users; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Client.Results; +using Microsoft.Extensions.Logging; +using System.Net.Http.Headers; + +namespace iRLeagueApiCore.Client; + +public sealed class LeagueApiClient : ILeagueApiClient +{ + private readonly ILogger logger; + private readonly HttpClientWrapper httpClientWrapper; + private readonly ITokenStore tokenStore; + private bool isAuthorizing; + + private string? CurrentLeagueName { get; set; } + + public Uri? BaseAddress => httpClientWrapper.BaseAddress; + + public LeagueApiClient(ILogger logger, HttpClient httpClient, HttpClientWrapperFactory clientWrapperFactory, ITokenStore tokenStore) + { + this.logger = logger; + httpClientWrapper = clientWrapperFactory.Create(httpClient, tokenStore, this); + httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + this.tokenStore = tokenStore; + tokenStore.TokenChanged += TokenStore_TokenChanged; + //tokenStore.TokenExpired += TokenStore_TokenExpired; + TokenStore_TokenChanged(this, EventArgs.Empty); + } + + ///// + ///// Automatically reauthorize if token has expired + ///// + ///// + ///// + //private async void TokenStore_TokenExpired(object? sender, EventArgs e) + //{ + // await Reauthorize(); + //} + + /// + /// Reauthorize (if required) if the token has changed (e.g. when the token has been read from browser storage) + /// + /// + /// + private async void TokenStore_TokenChanged(object? sender, EventArgs e) + { + var idToken = await tokenStore.GetIdTokenAsync(); + var accessToken = await tokenStore.GetAccessTokenAsync(); + if (string.IsNullOrEmpty(idToken) == false && string.IsNullOrEmpty(accessToken)) + { + try + { + await Reauthorize(); + } + catch (Exception ex) when ( + ex is InvalidOperationException || + ex is ApiServiceUnavailableException || + ex is HttpRequestException) + { + // do not throw any non system critical Exceptions in async void + // this will silently fail the reathorization when the service is unavailable + // TODO: find a way to inform the client consumer about the service state + } + } + } + + public bool IsLoggedIn => tokenStore.IsLoggedIn; + + public ILeagueByNameEndpoint? CurrentLeague { get; private set; } + public ISeasonByIdEndpoint? CurrentSeason { get; private set; } + + public ILeaguesEndpoint Leagues() + { + return new LeaguesEndpoint(httpClientWrapper, new RouteBuilder()); + } + + public IUsersEndpoint Users() + { + return new UsersEndpoint(httpClientWrapper, new RouteBuilder()); + } + + public ITracksEndpoint Tracks() + { + return new TracksEndpoint(httpClientWrapper, new RouteBuilder()); + } + + /// + /// Login with username and password + /// + /// + /// + /// + /// Response with id and access token + public async Task> LogIn(string username, string password, CancellationToken cancellationToken = default) + { + // request to login endpoint + await LogOut(); + + logger.LogInformation("Log in for {User} ...", username); + var requestUrl = "Authenticate/Login"; + var body = new + { + username = username, + password = password + }; + + var result = await httpClientWrapper.PostAsClientActionResult(requestUrl, body, cancellationToken); + + if (result.Success) + { + logger.LogInformation("Log in successful!"); + // set authorization header + string idToken = result.Content.IdToken; + string accessToken = result.Content.AccessToken; + await tokenStore.SetIdTokenAsync(idToken); + await tokenStore.SetAccessTokenAsync(accessToken); + return result; + } + + logger.LogError("Login failed: {Status}", result.Status); + return result; + } + + /// + /// Get access token using a valid idToken + /// + /// + /// + /// Response containing access token + public async Task Reauthorize(CancellationToken cancellationToken = default) + { + try + { + isAuthorizing = true; + + logger.LogInformation("Request access token using id token"); + + var requestUrl = "Authenticate/authorize"; + var idToken = await tokenStore.GetIdTokenAsync(); + var body = new + { + idToken + }; + var options = new HttpRequestOptions(); + options.TryAdd("SkipAuth", true); + var request = httpClientWrapper.CreateRequest(HttpMethod.Post, requestUrl, body, options); + var response = await httpClientWrapper.SendRequest(request, cancellationToken); + var result = await httpClientWrapper.ConvertToClientActionResult(response, cancellationToken); + + if (result.Success) + { + string token = result.Content.AccessToken; + await tokenStore.SetAccessTokenAsync(token); + return; + } + + logger.LogError("Access request failed: {Status}", result.Status); + await LogOut(); + return; + } + finally + { + isAuthorizing = false; + } + } + + /// + /// Check the current login state and reauthorize if required + /// + /// + public async Task CheckLogin(CancellationToken cancellationToken = default) + { + var idToken = await tokenStore.GetIdTokenAsync(); + if (string.IsNullOrWhiteSpace(idToken)) + { + // user not logged in + return; + } + + if (isAuthorizing) + { + // wait until authorizing finished + var timeout = 5000; + await Task.WhenAny(Task.Run(() => { while (isAuthorizing) ; }), Task.Delay(timeout, cancellationToken)); + } + // user logged in but has no access token -> get access through reauthorization + var accessToken = await tokenStore.GetAccessTokenAsync(); + if (string.IsNullOrWhiteSpace(accessToken)) + { + await Reauthorize(cancellationToken); + } + + if (DateTime.UtcNow >= tokenStore.AccessTokenExpires) + { + // access token has expired -> reauthoriza + await Reauthorize(cancellationToken); + } + + // Do nothing because login is valid + } + + public async Task LogOut() + { + await tokenStore.ClearTokensAsync(); + logger.LogInformation("User logged out"); + } + + public void SetCurrentLeague(string leagueName) + { + CurrentLeagueName = leagueName; + if (string.IsNullOrEmpty(CurrentLeagueName)) + { + CurrentLeague = null; + return; + } + + CurrentLeague = Leagues().WithName(leagueName); + } + + public void SetCurrentSeason(string leagueName, long seasonId) + { + SetCurrentLeague(leagueName); + if (CurrentLeague == null) + { + throw new InvalidOperationException("Could not set current season: current league was null"); + } + CurrentSeason = CurrentLeague.Seasons().WithId(seasonId); + } + + ICustomEndpoint ILeagueApiClient.CustomEndpoint(string route) + { + return new CustomEndpoint(httpClientWrapper, new(), route); + } + + IAuthenticateEndpoint ILeagueApiClient.Authenticate() + { + return new AuthenticateEndpoint(httpClientWrapper, new()); + } +} diff --git a/src/iRLeagueApiCore.Client/LeagueApiClientFactory.cs b/src/iRLeagueApiCore.Client/LeagueApiClientFactory.cs new file mode 100644 index 00000000..248cf86c --- /dev/null +++ b/src/iRLeagueApiCore.Client/LeagueApiClientFactory.cs @@ -0,0 +1,35 @@ +using iRLeagueApiCore.Client.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using System.Text.Json; + +namespace iRLeagueApiCore.Client; + +internal sealed class LeagueApiClientFactory +{ + private readonly ILoggerFactory loggerFactory; + private readonly IHttpClientFactory httpClientFactory; + private readonly ITokenStore tokenStore; + private readonly HttpClientWrapperFactory clientWrapperFactory; + + private readonly string baseAddress; + + public LeagueApiClientFactory(string baseAddress, ILoggerFactory loggerFactory, IHttpClientFactory httpClientFactory, + ITokenStore tokenStore, HttpClientWrapperFactory clientWrapperFactory) + { + this.baseAddress = baseAddress; + this.loggerFactory = loggerFactory; + this.httpClientFactory = httpClientFactory; + this.tokenStore = tokenStore; + this.clientWrapperFactory = clientWrapperFactory; + } + + public ILeagueApiClient CreateClient() + { + var httpClient = httpClientFactory.CreateClient(); + httpClient.BaseAddress = new Uri(baseAddress); + var client = new LeagueApiClient(loggerFactory.CreateLogger(), httpClient, clientWrapperFactory, tokenStore); + + return client; + } +} diff --git a/src/iRLeagueApiCore.Client/QueryBuilder/IParameterBuilder.cs b/src/iRLeagueApiCore.Client/QueryBuilder/IParameterBuilder.cs new file mode 100644 index 00000000..07004d3d --- /dev/null +++ b/src/iRLeagueApiCore.Client/QueryBuilder/IParameterBuilder.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Client.QueryBuilder; + +public interface IParameterBuilder +{ + IParameterBuilder Add(string name, T value); + IParameterBuilder AddArray(string name, IEnumerable values); + string Build(); +} diff --git a/src/iRLeagueApiCore.Client/QueryBuilder/IRouteBuilder.cs b/src/iRLeagueApiCore.Client/QueryBuilder/IRouteBuilder.cs new file mode 100644 index 00000000..a3eb7c8d --- /dev/null +++ b/src/iRLeagueApiCore.Client/QueryBuilder/IRouteBuilder.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Client.QueryBuilder; + +public interface IRouteBuilder +{ + IRouteBuilder AddEndpoint(string name); + IRouteBuilder AddParameter(T value); + IRouteBuilder WithParameters(Func parameterBuilder); + IRouteBuilder RemoveLast(); + string Build(); +} diff --git a/src/iRLeagueApiCore.Client/QueryBuilder/ParameterBuilder.cs b/src/iRLeagueApiCore.Client/QueryBuilder/ParameterBuilder.cs new file mode 100644 index 00000000..348358de --- /dev/null +++ b/src/iRLeagueApiCore.Client/QueryBuilder/ParameterBuilder.cs @@ -0,0 +1,36 @@ +namespace iRLeagueApiCore.Client.QueryBuilder; + +public sealed class ParameterBuilder : IParameterBuilder +{ + private List _parameters; + + public ParameterBuilder() + { + _parameters = new List(); + } + + public IParameterBuilder Add(string name, T value) + { + _parameters.Add(ParameterString(name, value)); + return this; + } + + public IParameterBuilder AddArray(string name, IEnumerable values) + { + foreach (var value in values) + { + _parameters.Add(ParameterString(name, value)); + } + return this; + } + + public string Build() + { + return string.Join("&", _parameters); + } + + private string ParameterString(string name, T value) + { + return string.Format("{0}={1}", name, value); + } +} diff --git a/src/iRLeagueApiCore.Client/QueryBuilder/RouteBuilder.cs b/src/iRLeagueApiCore.Client/QueryBuilder/RouteBuilder.cs new file mode 100644 index 00000000..23118aaa --- /dev/null +++ b/src/iRLeagueApiCore.Client/QueryBuilder/RouteBuilder.cs @@ -0,0 +1,66 @@ +using System.Text; + +namespace iRLeagueApiCore.Client.QueryBuilder; + +public sealed class RouteBuilder : IRouteBuilder +{ + private readonly List parts; + + private IParameterBuilder? ParameterBuilder { get; set; } + + public RouteBuilder() + { + parts = new List(); + } + + public RouteBuilder(List parts) + { + this.parts = parts; + } + + public IRouteBuilder AddEndpoint(string name) + { + parts.Add(name); + return this; + } + + public IRouteBuilder AddParameter(T value) + { + parts.Add(value?.ToString() ?? string.Empty); + return this; + } + + public string Build() + { + var builder = new StringBuilder(); + var joinedString = string.Join("/", parts); + builder.Append(joinedString); + if (ParameterBuilder != null) + { + var parameterString = ParameterBuilder.Build(); + if (string.IsNullOrEmpty(parameterString) == false) + { + builder.AppendFormat("?{0}", parameterString); + } + } + return builder.ToString(); + } + + public IRouteBuilder WithParameters(Func parameterBuilder) + { + ParameterBuilder = parameterBuilder.Invoke(new ParameterBuilder()); + return this; + } + + public RouteBuilder Copy() + { + return new RouteBuilder(new List(parts)); + } + + public IRouteBuilder RemoveLast() + { + if (parts.Count > 0) + parts.RemoveAt(parts.Count - 1); + return this; + } +} diff --git a/src/iRLeagueApiCore.Client/Results/AuthorizeResponse.cs b/src/iRLeagueApiCore.Client/Results/AuthorizeResponse.cs new file mode 100644 index 00000000..e14319d8 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Results/AuthorizeResponse.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Client.Results; +public struct AuthorizeResponse +{ + public string AccessToken { get; set; } + public DateTime Expires { get; set; } +} diff --git a/src/iRLeagueApiCore.Client/Results/ClientActionResult.cs b/src/iRLeagueApiCore.Client/Results/ClientActionResult.cs new file mode 100644 index 00000000..57e253e2 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Results/ClientActionResult.cs @@ -0,0 +1,33 @@ +using System.Net; + +namespace iRLeagueApiCore.Client.Results; + +public struct ClientActionResult +{ + public ClientActionResult(T? content, HttpStatusCode httpStatusCode, string requestUrl = "") : this(true, "Success", "", content, httpStatusCode, requestUrl) + { } + + public ClientActionResult(bool success, string status, string message, T? content, HttpStatusCode httpStatusCode, string requestUrl = "", IEnumerable? errors = null) + { + Success = success; + Status = status; + Message = message; + Content = content; + HttpStatusCode = httpStatusCode; + RequestUrl = requestUrl; + Errors = errors ?? Array.Empty(); + } + + public bool Success { get; } + public string Status { get; } + public string Message { get; } + public T? Content { get; } + public HttpStatusCode HttpStatusCode { get; } + public string RequestUrl { get; } + public IEnumerable Errors { get; } +} + +public struct NoContent +{ + public static NoContent Value => new(); +} diff --git a/src/iRLeagueApiCore.Client/Results/HttpExtensions.cs b/src/iRLeagueApiCore.Client/Results/HttpExtensions.cs new file mode 100644 index 00000000..206364a6 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Results/HttpExtensions.cs @@ -0,0 +1,121 @@ +using iRLeagueApiCore.Common.Responses; +using System.Net; +#if NETCOREAPP +using System.Net.Http.Json; +using System.Text.Json; +#endif + +namespace iRLeagueApiCore.Client.Results; + +public static class HttpExtensions +{ + public static async Task> ToClientActionResultAsync(this HttpResponseMessage httpResponse, JsonSerializerOptions? jsonOptions, CancellationToken cancellationToken = default) + { + string requestUrl = httpResponse.RequestMessage?.RequestUri?.AbsoluteUri ?? string.Empty; + try + { + if (httpResponse.IsSuccessStatusCode) + { + var content = httpResponse.StatusCode != HttpStatusCode.NoContent ? + await httpResponse.Content.ReadFromJsonAsync(options: jsonOptions, cancellationToken: cancellationToken) : default; + return new ClientActionResult(content, httpResponse.StatusCode, requestUrl); + } + + string status = ""; + string message = ""; + IEnumerable errors; + switch (httpResponse.StatusCode) + { + case HttpStatusCode.BadRequest: + { + var response = await httpResponse.Content.ReadFromJsonAsync(options: jsonOptions, cancellationToken: cancellationToken); + status = response.Status; + errors = response.Errors.Cast(); + break; + } + case HttpStatusCode.Unauthorized: + { + var response = await httpResponse.Content.ReadFromJsonAsync(options: jsonOptions, cancellationToken: cancellationToken); + status = "Unauthorized"; + message = response.Status ?? string.Empty; + errors = response.Errors ?? Array.Empty(); + break; + } + case HttpStatusCode.Forbidden: + { + status = "Forbidden"; + errors = Array.Empty(); + break; + } + case HttpStatusCode.NotFound: + { + status = "Not Found"; + errors = Array.Empty(); + break; + } + case HttpStatusCode.MethodNotAllowed: + { + status = "Method Not Allowed"; + message = $"Method {httpResponse.RequestMessage?.Method.Method} not allowed on {httpResponse.RequestMessage?.RequestUri}"; + errors = Array.Empty(); + break; + } + case HttpStatusCode.InternalServerError: + { + var response = await httpResponse.Content.ReadAsStringAsync(cancellationToken: cancellationToken); + status = "Internal server Error"; + message = response; + errors = new object[] { "Internal server Error " }; + break; + } + default: + status = "Unknown Response"; + message = ""; + errors = Array.Empty(); + break; + } + return new ClientActionResult(false, status, message, default, httpResponse.StatusCode, requestUrl, errors); + } + catch (Exception ex) when (ex is InvalidOperationException || ex is JsonException) + { + var errors = new object[] { ex }; + return new ClientActionResult(false, "Error", ex.Message, default, 0, requestUrl, errors); + } + } + + public static async Task> AsClientActionResultAsync(this Task request, JsonSerializerOptions? jsonOptions, CancellationToken cancellationToken = default) + { + string requestUrl = ""; + try + { + var result = await request; + requestUrl = result.RequestMessage?.RequestUri?.AbsoluteUri ?? string.Empty; + return await result.ToClientActionResultAsync(jsonOptions, cancellationToken); + } + catch (Exception ex) when (ex is InvalidOperationException || ex is HttpRequestException) + { + var errors = new object[] { ex }; + return new ClientActionResult(false, "Error", "Exception: " + ex, default, 0, requestUrl, errors); + } + } + + public static async Task> GetAsClientActionResult(this HttpClient httpClient, string query, JsonSerializerOptions jsonOptions, CancellationToken cancellationToken = default) + { + return await httpClient.GetAsync(query, cancellationToken).AsClientActionResultAsync(jsonOptions, cancellationToken); + } + + public static async Task> PostAsClientActionResult(this HttpClient httpClient, string query, TPost body, JsonSerializerOptions jsonOptions, CancellationToken cancellationToken = default) + { + return await httpClient.PostAsJsonAsync(query, body, cancellationToken).AsClientActionResultAsync(jsonOptions, cancellationToken); + } + + public static async Task> PutAsClientActionResult(this HttpClient httpClient, string query, TPut body, JsonSerializerOptions jsonOptions, CancellationToken cancellationToken = default) + { + return await httpClient.PutAsJsonAsync(query, body, cancellationToken).AsClientActionResultAsync(jsonOptions, cancellationToken); + } + + public static async Task> DeleteAsClientActionResult(this HttpClient httpClient, string query, JsonSerializerOptions jsonOptions, CancellationToken cancellationToken = default) + { + return await httpClient.DeleteAsync(query, cancellationToken).AsClientActionResultAsync(jsonOptions, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Client/Results/LoginResponse.cs b/src/iRLeagueApiCore.Client/Results/LoginResponse.cs new file mode 100644 index 00000000..214e14da --- /dev/null +++ b/src/iRLeagueApiCore.Client/Results/LoginResponse.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Client.Results; + +public struct LoginResponse +{ + public string IdToken { get; set; } + public string AccessToken { get; set; } + public DateTime Expires { get; set; } +} diff --git a/src/iRLeagueApiCore.Client/ResultsParsing/ParseCarClass.cs b/src/iRLeagueApiCore.Client/ResultsParsing/ParseCarClass.cs new file mode 100644 index 00000000..60115ad3 --- /dev/null +++ b/src/iRLeagueApiCore.Client/ResultsParsing/ParseCarClass.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Client.ResultsParsing; + +#pragma warning disable IDE1006 // Benennungsstile +public sealed class ParseCarClass +{ + public int car_class_id { get; set; } + public ParseCarInClass[] cars_in_class { get; set; } = Array.Empty(); + public string? name { get; set; } + public string? short_name { get; set; } +} diff --git a/src/iRLeagueApiCore.Client/ResultsParsing/ParseCarInClass.cs b/src/iRLeagueApiCore.Client/ResultsParsing/ParseCarInClass.cs new file mode 100644 index 00000000..92a57c99 --- /dev/null +++ b/src/iRLeagueApiCore.Client/ResultsParsing/ParseCarInClass.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.Client.ResultsParsing; + +#pragma warning disable IDE1006 // Benennungsstile +public sealed class ParseCarInClass +{ + public int car_id { get; set; } +} diff --git a/src/iRLeagueApiCore.Client/ResultsParsing/ParseLivery.cs b/src/iRLeagueApiCore.Client/ResultsParsing/ParseLivery.cs new file mode 100644 index 00000000..c4fc677a --- /dev/null +++ b/src/iRLeagueApiCore.Client/ResultsParsing/ParseLivery.cs @@ -0,0 +1,21 @@ +namespace iRLeagueApiCore.Client.ResultsParsing; + +#pragma warning disable IDE1006 // Benennungsstile +public sealed class ParseLivery +{ + public int car_id { get; set; } + public int pattern { get; set; } + public string? color1 { get; set; } + public string? color2 { get; set; } + public string? color3 { get; set; } + public int number_font { get; set; } + public string? number_color1 { get; set; } + public string? number_color2 { get; set; } + public string? number_color3 { get; set; } + public int number_slant { get; set; } + public int sponsor1 { get; set; } + public int sponsor2 { get; set; } + public string? car_number { get; set; } + public string? wheel_color { get; set; } + public int rim_type { get; set; } +} diff --git a/src/iRLeagueApiCore.Client/ResultsParsing/ParseSessionResult.cs b/src/iRLeagueApiCore.Client/ResultsParsing/ParseSessionResult.cs new file mode 100644 index 00000000..014fe225 --- /dev/null +++ b/src/iRLeagueApiCore.Client/ResultsParsing/ParseSessionResult.cs @@ -0,0 +1,12 @@ +namespace iRLeagueApiCore.Client.ResultsParsing; + +#pragma warning disable IDE1006 // Benennungsstile +public sealed class ParseSessionResult +{ + public int simsession_number { get; set; } + public int simsession_type { get; set; } + public string? simsession_type_name { get; set; } + public int simsession_subtype { get; set; } + public string? simsession_name { get; set; } + public ParseSessionResultRow[] results { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Client/ResultsParsing/ParseSessionResultRow.cs b/src/iRLeagueApiCore.Client/ResultsParsing/ParseSessionResultRow.cs new file mode 100644 index 00000000..510eaf3b --- /dev/null +++ b/src/iRLeagueApiCore.Client/ResultsParsing/ParseSessionResultRow.cs @@ -0,0 +1,66 @@ +namespace iRLeagueApiCore.Client.ResultsParsing; + +#pragma warning disable IDE1006 // Benennungsstile +public sealed class ParseSessionResultRow +{ + public long? team_id { get; set; } + public long cust_id { get; set; } + public string? display_name { get; set; } + public int finish_position { get; set; } + public int finish_position_in_class { get; set; } + public int laps_lead { get; set; } + public int laps_complete { get; set; } + public int opt_laps_complete { get; set; } + public int interval { get; set; } + public int class_interval { get; set; } + public long average_lap { get; set; } + public int best_lap_num { get; set; } + public long best_lap_time { get; set; } + public int best_nlaps_num { get; set; } + public long best_nlaps_time { get; set; } + public DateTime best_qual_lap_at { get; set; } + public int best_qual_lap_num { get; set; } + public long best_qual_lap_time { get; set; } + public int reason_out_id { get; set; } + public string? reason_out { get; set; } + public int champ_points { get; set; } + public bool drop_race { get; set; } + public int club_points { get; set; } + public int position { get; set; } + public long qual_lap_time { get; set; } + public int starting_position { get; set; } + public int starting_position_in_class { get; set; } + public int car_class_id { get; set; } + public string? car_class_name { get; set; } + public string? car_class_short_name { get; set; } + public int club_id { get; set; } + public string? club_name { get; set; } + public string? club_shortname { get; set; } + public int division { get; set; } + public int old_license_level { get; set; } + public int old_sub_level { get; set; } + public double old_cpi { get; set; } + public int oldi_rating { get; set; } + public int old_ttrating { get; set; } + public int new_license_level { get; set; } + public int new_sub_level { get; set; } + public double new_cpi { get; set; } + public int newi_rating { get; set; } + public int new_ttrating { get; set; } + public int multiplier { get; set; } + public int license_change_oval { get; set; } + public int license_change_road { get; set; } + public int incidents { get; set; } + public int max_pct_fuel_fill { get; set; } + public int weight_penalty_kg { get; set; } + public int league_points { get; set; } + public int league_agg_points { get; set; } + public int car_id { get; set; } + public string? car_name { get; set; } + public int aggregate_champ_points { get; set; } + public ParseLivery livery { get; set; } = new(); + public bool watched { get; set; } + public bool friend { get; set; } + public ParseSessionResultRow[] driver_results { get; set; } = Array.Empty(); + public bool ai { get; set; } +} diff --git a/src/iRLeagueApiCore.Client/ResultsParsing/ParseSimSessionResult.cs b/src/iRLeagueApiCore.Client/ResultsParsing/ParseSimSessionResult.cs new file mode 100644 index 00000000..4814f3bc --- /dev/null +++ b/src/iRLeagueApiCore.Client/ResultsParsing/ParseSimSessionResult.cs @@ -0,0 +1,61 @@ +namespace iRLeagueApiCore.Client.ResultsParsing; + +#pragma warning disable IDE1006 // Benennungsstile +public sealed class ParseSimSessionResult +{ + public long subsession_id { get; set; } + public long season_id { get; set; } + public string? season_name { get; set; } + public string? season_short_name { get; set; } + public int season_year { get; set; } + public int season_quarter { get; set; } + public int series_id { get; set; } + public string? series_name { get; set; } + public string? series_short_name { get; set; } + public int race_week_num { get; set; } + public long session_id { get; set; } + public int license_category_id { get; set; } + public string? license_category { get; set; } + public long private_session_id { get; set; } + public long host_id { get; set; } + public string? session_name { get; set; } + public long league_id { get; set; } + public string? league_name { get; set; } + public long league_season_id { get; set; } + public string? league_season_name { get; set; } + public bool restrict_results { get; set; } + public DateTime start_time { get; set; } + public DateTime end_time { get; set; } + public int num_laps_for_qual_average { get; set; } + public int num_laps_for_solo_average { get; set; } + public int corners_per_lap { get; set; } + public int caution_type { get; set; } + public int event_type { get; set; } + public string? event_type_name { get; set; } + public bool driver_changes { get; set; } + public int min_team_drivers { get; set; } + public int max_team_drivers { get; set; } + public int driver_change_rule { get; set; } + public int driver_change_param1 { get; set; } + public int driver_change_param2 { get; set; } + public int max_weeks { get; set; } + public string? points_type { get; set; } + public int event_strength_of_field { get; set; } + public int event_average_lap { get; set; } + public int event_laps_complete { get; set; } + public int num_cautions { get; set; } + public int num_caution_laps { get; set; } + public int num_lead_changes { get; set; } + public bool official_session { get; set; } + public int heat_info_id { get; set; } + public int special_event_type { get; set; } + public int damage_model { get; set; } + public bool can_protest { get; set; } + public int cooldown_minutes { get; set; } + public int limit_minutes { get; set; } + public ParseTrack track { get; set; } = new(); + public ParseWeather weather { get; set; } = new(); + public ParseTrackState track_state { get; set; } = new(); + public ParseSessionResult[] session_results { get; set; } = Array.Empty(); + public ParseCarClass[] car_classes { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Client/ResultsParsing/ParseTrack.cs b/src/iRLeagueApiCore.Client/ResultsParsing/ParseTrack.cs new file mode 100644 index 00000000..2ef76349 --- /dev/null +++ b/src/iRLeagueApiCore.Client/ResultsParsing/ParseTrack.cs @@ -0,0 +1,11 @@ +namespace iRLeagueApiCore.Client.ResultsParsing; + +#pragma warning disable IDE1006 // Benennungsstile +public sealed class ParseTrack +{ + public int track_id { get; set; } + public string? track_name { get; set; } + public string? config_name { get; set; } + public int category_id { get; set; } + public string? category { get; set; } +} diff --git a/src/iRLeagueApiCore.Client/ResultsParsing/ParseTrackState.cs b/src/iRLeagueApiCore.Client/ResultsParsing/ParseTrackState.cs new file mode 100644 index 00000000..3b04b4ed --- /dev/null +++ b/src/iRLeagueApiCore.Client/ResultsParsing/ParseTrackState.cs @@ -0,0 +1,15 @@ +namespace iRLeagueApiCore.Client.ResultsParsing; + +#pragma warning disable IDE1006 // Benennungsstile +public sealed class ParseTrackState +{ + public bool leave_marbles { get; set; } + public int practice_rubber { get; set; } + public int qualify_rubber { get; set; } + public int warmup_rubber { get; set; } + public int race_rubber { get; set; } + public int practice_grip_compound { get; set; } + public int qualify_grip_compound { get; set; } + public int warmup_grip_compound { get; set; } + public int race_grip_compound { get; set; } +} diff --git a/src/iRLeagueApiCore.Client/ResultsParsing/ParseWeather.cs b/src/iRLeagueApiCore.Client/ResultsParsing/ParseWeather.cs new file mode 100644 index 00000000..d607e360 --- /dev/null +++ b/src/iRLeagueApiCore.Client/ResultsParsing/ParseWeather.cs @@ -0,0 +1,20 @@ +namespace iRLeagueApiCore.Client.ResultsParsing; + +#pragma warning disable IDE1006 // Benennungsstile +public sealed class ParseWeather +{ + public int type { get; set; } + public int temp_units { get; set; } + public int temp_value { get; set; } + public int rel_humidity { get; set; } + public int fog { get; set; } + public int wind_dir { get; set; } + public int wind_units { get; set; } + public int wind_value { get; set; } + public int skies { get; set; } + public int weather_var_initial { get; set; } + public int weather_var_ongoing { get; set; } + public int time_of_day { get; set; } + public DateTime simulated_start_utc_time { get; set; } + public long simulated_start_utc_offset { get; set; } +} diff --git a/src/iRLeagueApiCore.Client/Service/LeagueApiClientConfiguration.cs b/src/iRLeagueApiCore.Client/Service/LeagueApiClientConfiguration.cs new file mode 100644 index 00000000..66df0478 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Service/LeagueApiClientConfiguration.cs @@ -0,0 +1,42 @@ +using iRLeagueApiCore.Client.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace iRLeagueApiCore.Client.Service; +public sealed class LeagueApiClientConfiguration +{ + const string defaultBaseAddress = "https://irleaguemanager.net/api/"; + private readonly IServiceCollection services; + + public string BaseAddress { get; set; } = defaultBaseAddress; + + public LeagueApiClientConfiguration(IServiceCollection services) + { + this.services = services; + } + + public LeagueApiClientConfiguration UseBaseAddress(string baseAddress) + { + BaseAddress = baseAddress; + return this; + } + + public LeagueApiClientConfiguration UseDefaultTokenStore() + { + services.Replace(ServiceDescriptor.Scoped()); + return this; + } + + public LeagueApiClientConfiguration UseTokenStore() where T : class, ITokenStore + { + services.Replace(ServiceDescriptor.Scoped()); + return this; + } + + public LeagueApiClientConfiguration UseTokenStore(Func factory) where T : class, ITokenStore + { + services.Replace(ServiceDescriptor.Scoped(factory)); + return this; + } +} diff --git a/src/iRLeagueApiCore.Client/Service/LeagueClientServiceCollectionExtensions.cs b/src/iRLeagueApiCore.Client/Service/LeagueClientServiceCollectionExtensions.cs new file mode 100644 index 00000000..20ee20c1 --- /dev/null +++ b/src/iRLeagueApiCore.Client/Service/LeagueClientServiceCollectionExtensions.cs @@ -0,0 +1,32 @@ +using iRLeagueApiCore.Client; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.Service; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Logging; + +namespace Microsoft.Extensions.DependencyInjection; +public static class IRLeagueApiClientServiceExtensions +{ + public static IServiceCollection AddLeagueApiClient(this IServiceCollection services, Action? configure = null) + { + services.AddHttpClient(); + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(sp => sp.GetRequiredService()); + + // run configuration + var configuration = new LeagueApiClientConfiguration(services); + configure?.Invoke(configuration); + + services.TryAddScoped(sp => new( + configuration.BaseAddress, + sp.GetRequiredService(), + sp.GetRequiredService(), + sp.GetRequiredService(), + sp.GetRequiredService() + )); + services.TryAddScoped(sp => sp.GetRequiredService().CreateClient()); + + return services; + } +} diff --git a/src/iRLeagueApiCore.Client/iRLeagueApiCore.Client.csproj b/src/iRLeagueApiCore.Client/iRLeagueApiCore.Client.csproj new file mode 100644 index 00000000..f739fc34 --- /dev/null +++ b/src/iRLeagueApiCore.Client/iRLeagueApiCore.Client.csproj @@ -0,0 +1,36 @@ + + + + + + + + + + + + Library + net6.0 + iRLeagueApiCore.Client + 0.11.4 + Simon Schulze + Simon Schulze + This package contains shared objects for all members of the iRLeagueDatabase-iRLeagueApi stack + https://github.com/SSchulze1989/iRLeagueApiCore + true + enable + enable + + + + + <_Parameter1>iRLeagueApiCore.UnitTests + + + + + + + + + \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Converters/JsonTimeSpanConverter.cs b/src/iRLeagueApiCore.Common/Converters/JsonTimeSpanConverter.cs new file mode 100644 index 00000000..79a3fb30 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Converters/JsonTimeSpanConverter.cs @@ -0,0 +1,41 @@ +#if NETCOREAPP +using System.Text.Json; + +namespace iRLeagueApiCore.Common.Converters; + +public class JsonTimeSpanConverter : JsonConverter +{ + public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (typeof(long).IsAssignableFrom(typeToConvert)) + { + var longValue = reader.GetInt64(); + return new TimeSpan(longValue); + } + else + { + var timeSpanString = reader.GetString(); + if (string.IsNullOrWhiteSpace(timeSpanString)) + { + return TimeSpan.Zero; + } + var hasDays = timeSpanString.Count(c => c == '.') > 1; + if (hasDays) + { + return TimeSpan.ParseExact(timeSpanString, @"dd\.hh\:mm\:ss\.fffff", null); + } + return TimeSpan.ParseExact(timeSpanString, @"hh\:mm\:ss\.fffff", null); + } + } + + public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options) + { + if (value.Days > 0) + { + writer.WriteStringValue(value.ToString(@"dd\.hh\:mm\:ss\.fffff")); + return; + } + writer.WriteStringValue(value.ToString(@"hh\:mm\:ss\.fffff")); + } +} +#endif diff --git a/src/iRLeagueApiCore.Common/Converters/JsonTimeSpanToTicksConverter.cs b/src/iRLeagueApiCore.Common/Converters/JsonTimeSpanToTicksConverter.cs new file mode 100644 index 00000000..0935d55b --- /dev/null +++ b/src/iRLeagueApiCore.Common/Converters/JsonTimeSpanToTicksConverter.cs @@ -0,0 +1,21 @@ +using System.Text.Json; + +namespace iRLeagueApiCore.Common.Converters; + +public sealed class JsonTimeSpanToTicksConverter : JsonConverter +{ + public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (typeof(long).IsAssignableFrom(typeToConvert)) + { + var longValue = reader.GetInt64(); + return new TimeSpan(longValue); + } + return TimeSpan.Zero; + } + + public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options) + { + writer.WriteNumberValue(value.Ticks); + } +} diff --git a/src/iRLeagueApiCore.Common/Enums/AccumulateByOption.cs b/src/iRLeagueApiCore.Common/Enums/AccumulateByOption.cs new file mode 100644 index 00000000..865747af --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/AccumulateByOption.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Enums; + +/// +/// Select the column for identifying rows that belong together +/// +public enum AccumulateByOption +{ + Member, + Team +} diff --git a/src/iRLeagueApiCore.Common/Enums/AccumulateResultsOption.cs b/src/iRLeagueApiCore.Common/Enums/AccumulateResultsOption.cs new file mode 100644 index 00000000..005240fd --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/AccumulateResultsOption.cs @@ -0,0 +1,14 @@ +namespace iRLeagueApiCore.Common.Enums; + +/// +/// Select the method to accumulate scorings +/// +public enum AccumulateResultsOption +{ + None = 0, + Sum, + Best, + Worst, + Average, + WeightedAverage +} diff --git a/src/iRLeagueApiCore.Common/Enums/AdminRights.cs b/src/iRLeagueApiCore.Common/Enums/AdminRights.cs new file mode 100644 index 00000000..76d0492a --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/AdminRights.cs @@ -0,0 +1,37 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +[Flags] +public enum AdminRights +{ + Member = 0b00000000, + EditMemberData = 0b00000001, + EditLeagueData = 0b00000010, + DeleteMemberData = 0b00000100, + DeleteLeagueData = 0b00001000, + EditDeleteMemberData = 0b00000101, + EditDeleteLeagueData = 0b00001010, + RightManager = 0b00010001, + Owner = 0b11111111 +} diff --git a/src/iRLeagueApiCore.Common/Enums/BonusPointType.cs b/src/iRLeagueApiCore.Common/Enums/BonusPointType.cs new file mode 100644 index 00000000..6eb185f8 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/BonusPointType.cs @@ -0,0 +1,14 @@ +public enum BonusPointType +{ + Position, + QualyPosition, + FastestLap, + FastestAverageLap, + CleanestDriver, + NoIncidents, + MostPositionsGained, + MostPositionsLost, + LeadOneLap, + LeadMostLaps, + Custom = 999, +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Enums/ComparatorType.cs b/src/iRLeagueApiCore.Common/Enums/ComparatorType.cs new file mode 100644 index 00000000..c9d59652 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/ComparatorType.cs @@ -0,0 +1,13 @@ +namespace iRLeagueApiCore.Common.Enums; + +public enum ComparatorType +{ + IsSmaller, + IsSmallerOrEqual, + IsEqual, + IsBiggerOrEqual, + IsBigger, + NotEqual, + InList, + ForEach, // special comparator that multiplies the configured bonus/penalty for each multiple of the provided value +} diff --git a/src/iRLeagueApiCore.Common/Enums/ConfigType.cs b/src/iRLeagueApiCore.Common/Enums/ConfigType.cs new file mode 100644 index 00000000..73212bfe --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/ConfigType.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Enums; + +public enum ConfigType +{ + Unknown, + Road, + Oval, + DirtRoad, + DirtOval +} diff --git a/src/iRLeagueApiCore.Common/Enums/ConnectionStatus.cs b/src/iRLeagueApiCore.Common/Enums/ConnectionStatus.cs new file mode 100644 index 00000000..2e892d47 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/ConnectionStatus.cs @@ -0,0 +1,33 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +public enum ConnectionStatus +{ + Disconnected = 0, + Connected = 1, + Connecting = 2, + DatabaseUnavailable = 3, + NoConnection = 4, + ConnectionError = 99 +} diff --git a/src/iRLeagueApiCore.Common/Enums/DatabaseStatus.cs b/src/iRLeagueApiCore.Common/Enums/DatabaseStatus.cs new file mode 100644 index 00000000..34bd5916 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/DatabaseStatus.cs @@ -0,0 +1,32 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +public enum DatabaseStatus +{ + Idle = 0, + Loading = 1, + Saving = 2, + Updating = 3, + Error = 99 +} diff --git a/src/iRLeagueApiCore.Common/Enums/DropRacesOption.cs b/src/iRLeagueApiCore.Common/Enums/DropRacesOption.cs new file mode 100644 index 00000000..090e78a5 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/DropRacesOption.cs @@ -0,0 +1,29 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +public enum DropRacesOption +{ + PerTeamResults = 0, + PerDriverResults = 1 +} diff --git a/src/iRLeagueApiCore.Common/Enums/EventType.cs b/src/iRLeagueApiCore.Common/Enums/EventType.cs new file mode 100644 index 00000000..ddf98572 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/EventType.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Enums; + +public enum EventType +{ + Undefined, + Practice, + Qualifying, + SingleRace, + MultiRace +} diff --git a/src/iRLeagueApiCore.Common/Enums/FilterType.cs b/src/iRLeagueApiCore.Common/Enums/FilterType.cs new file mode 100644 index 00000000..0347533a --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/FilterType.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Common.Enums; + +public enum FilterType +{ + ColumnProperty, + Member, + Team, +} diff --git a/src/iRLeagueApiCore.Common/Enums/GetBestOption.cs b/src/iRLeagueApiCore.Common/Enums/GetBestOption.cs new file mode 100644 index 00000000..0dc8b7fb --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/GetBestOption.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.Common.Enums; + +public enum GetBestOption +{ + MaxValue, + MinValue +} diff --git a/src/iRLeagueApiCore.Common/Enums/LeaguePublicSetting.cs b/src/iRLeagueApiCore.Common/Enums/LeaguePublicSetting.cs new file mode 100644 index 00000000..b1b9d2b7 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/LeaguePublicSetting.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Enums; +public enum LeaguePublicSetting +{ + PublicListed, + PublicHidden, +} diff --git a/src/iRLeagueApiCore.Common/Enums/MatchedValueAction.cs b/src/iRLeagueApiCore.Common/Enums/MatchedValueAction.cs new file mode 100644 index 00000000..80777362 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/MatchedValueAction.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.Common.Enums; + +public enum MatchedValueAction +{ + Keep, + Remove, +} diff --git a/src/iRLeagueApiCore.Common/Enums/PenaltyType.cs b/src/iRLeagueApiCore.Common/Enums/PenaltyType.cs new file mode 100644 index 00000000..b0903da5 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/PenaltyType.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Common.Enums; +public enum PenaltyType +{ + Points, + Position, + Time, + Disqualification, +} diff --git a/src/iRLeagueApiCore.Common/Enums/PointRuleType.cs b/src/iRLeagueApiCore.Common/Enums/PointRuleType.cs new file mode 100644 index 00000000..b32fb1ed --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/PointRuleType.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.Common.Enums; +public enum PointRuleType +{ + PointList, + MaxPointsDropOff, + Formula, +}; diff --git a/src/iRLeagueApiCore.Common/Enums/ProtestFormAccess.cs b/src/iRLeagueApiCore.Common/Enums/ProtestFormAccess.cs new file mode 100644 index 00000000..b08cc51e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/ProtestFormAccess.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Enums; + +[Flags] +public enum ProtestFormAccess +{ + Public = 1, + Participants = 2, + LeagueMembers = 4, + Password = 8, +} diff --git a/src/iRLeagueApiCore.Common/Enums/ProtestPublicSetting.cs b/src/iRLeagueApiCore.Common/Enums/ProtestPublicSetting.cs new file mode 100644 index 00000000..a7b7271b --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/ProtestPublicSetting.cs @@ -0,0 +1,17 @@ +namespace iRLeagueApiCore.Common.Enums; + +public enum ProtestPublicSetting +{ + /// + /// Hide protests so that the can only be seen by stewards + /// + Hidden = 0, + /// + /// Show protests in public but hide the name of the protester + /// + WithoutProtester = 1, + /// + /// Show both protest and name of protester in public + /// + WithProtester = 2, +} diff --git a/src/iRLeagueApiCore.Common/Enums/RaceStatus.cs b/src/iRLeagueApiCore.Common/Enums/RaceStatus.cs new file mode 100644 index 00000000..3b9cfcaa --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/RaceStatus.cs @@ -0,0 +1,31 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +public enum RaceStatus +{ + Running, + Disconnected = 32, + Disqualified = 29, + Unknown +} diff --git a/src/iRLeagueApiCore.Common/Enums/ResultKind.cs b/src/iRLeagueApiCore.Common/Enums/ResultKind.cs new file mode 100644 index 00000000..52afabc2 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/ResultKind.cs @@ -0,0 +1,29 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +public enum ResultKind +{ + Member = 0, + Team = 1 +} diff --git a/src/iRLeagueApiCore.Common/Enums/ResultSortOption.cs b/src/iRLeagueApiCore.Common/Enums/ResultSortOption.cs new file mode 100644 index 00000000..011e05c1 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/ResultSortOption.cs @@ -0,0 +1,15 @@ +namespace iRLeagueDatabase.Enums; + +public enum ResultSortOption +{ + None = 0, + FinishPosition, + StartPosition, + FastestLap, + AverageLap, + Interval, + RacePoints, + BonusPoints, + PenaltyPoints, + TotalPoints +} diff --git a/src/iRLeagueApiCore.Common/Enums/SaveSelect.cs b/src/iRLeagueApiCore.Common/Enums/SaveSelect.cs new file mode 100644 index 00000000..e077ee9d --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/SaveSelect.cs @@ -0,0 +1,35 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +[Flags] +public enum SaveSelect +{ + LeagueMembers = 0b00000001, + Admins = 0b00000010, + Results = 0b00000100, + Scorings = 0b00001000, + Schedules = 0b00010000, + Seasons = 0b00100000, + Teams = 0b01000000 +} diff --git a/src/iRLeagueApiCore.Common/Enums/ScoringSessionSelection.cs b/src/iRLeagueApiCore.Common/Enums/ScoringSessionSelection.cs new file mode 100644 index 00000000..8184890e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/ScoringSessionSelection.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Enums; + +/// +/// Defines how the sessions for this scoring are selected +/// +public enum ScoringSessionSelectionType +{ + SelectSchedule, + SelectSessions +} diff --git a/src/iRLeagueApiCore.Common/Enums/SessionType.cs b/src/iRLeagueApiCore.Common/Enums/SessionType.cs new file mode 100644 index 00000000..0e86f632 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/SessionType.cs @@ -0,0 +1,34 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +/// +/// Selected session type +/// +public enum SessionType +{ + Undefined, + Practice, + Qualifying, + Race, +} diff --git a/src/iRLeagueApiCore.Common/Enums/SimSessionType.cs b/src/iRLeagueApiCore.Common/Enums/SimSessionType.cs new file mode 100644 index 00000000..971ad877 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/SimSessionType.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Enums; + +public enum SimSessionType +{ + Unknown, + OpenPractice = 3, + LoneQualifying = 4, + OpenQualifying = 5, + Race = 6 +} diff --git a/src/iRLeagueApiCore.Common/Enums/SortOptions.cs b/src/iRLeagueApiCore.Common/Enums/SortOptions.cs new file mode 100644 index 00000000..d6c7754c --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/SortOptions.cs @@ -0,0 +1,57 @@ +namespace iRLeagueApiCore.Common.Enums; + +public enum SortOptions +{ + PosAsc, + PosDesc, + PosChgAsc, + PosChgDesc, + FinPosAsc, + FinPosDesc, + FinPosChgAsc, + FinPosChgDesc, + StartPosAsc, + StartPosDesc, + RacePtsAsc, + RacePtsDesc, + PenPtsAsc, + PenPtsDesc, + BonusPtsAsc, + BonusPtsDesc, + TotalPtsAsc, + TotalPtsDesc, + IntvlAsc, + IntvlDesc, + ComplLapsAsc, + ComplLapsDesc, + LeadLapsAsc, + LeadLapsDesc, + IncsAsc, + IncsDesc, + FastLapAsc, + FastLapDesc, + QualLapAsc, + QualLapDesc, + TotalPtsWoBonusAsc, + TotalPtsWoBonusDesc, + TotalPtsWoPenaltyAsc, + TotalPtsWoPenaltyDesc, + LastRaceOrderAsc, + LastRaceOrderDesc, + WinsAsc, + WinsDesc, + Top3Asc, + Top3Desc, + Top5Asc, + Top5Desc, + Top10Asc, + Top10Desc, + RacesAsc, + RacesDesc, + RacesCountedAsc, + RacesCountedDesc, + RacesScoredAsc, + RacesScoredDesc, + RacesInPointsAsc, + RacesInPointsDesc, +} diff --git a/src/iRLeagueApiCore.Common/Enums/StewardVote.cs b/src/iRLeagueApiCore.Common/Enums/StewardVote.cs new file mode 100644 index 00000000..3e1774f2 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/StewardVote.cs @@ -0,0 +1,33 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +public enum StewardVote +{ + NoVote, + Kat0, + Kat1, + Kat2, + Kat3, + Indecisive +} diff --git a/src/iRLeagueApiCore.Common/Enums/StewardVoteState.cs b/src/iRLeagueApiCore.Common/Enums/StewardVoteState.cs new file mode 100644 index 00000000..06d2ff27 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/StewardVoteState.cs @@ -0,0 +1,34 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +public enum StewardVoteState +{ + NoVote, + Open, + VotesNeeded, + Conflict, + MajorityVote, + Agreed, + Closed +} diff --git a/src/iRLeagueApiCore.Common/Enums/SubscriptionStatus.cs b/src/iRLeagueApiCore.Common/Enums/SubscriptionStatus.cs new file mode 100644 index 00000000..4a26cbb6 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/SubscriptionStatus.cs @@ -0,0 +1,9 @@ +namespace iRLeagueApiCore.Common.Enums; +public enum SubscriptionStatus +{ + Expired = -1, + Unknown = 0, + FreeTrial, + PaidPlan, + Lifetime, +} diff --git a/src/iRLeagueApiCore.Common/Enums/TimingComponents.cs b/src/iRLeagueApiCore.Common/Enums/TimingComponents.cs new file mode 100644 index 00000000..fc9e258e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/TimingComponents.cs @@ -0,0 +1,33 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +[Flags] +public enum TimingComponents +{ + Milliseconds = 0b00000001, + Seconds = 0b00000010, + Minutes = 0b00000100, + Hours = 0b00001000, + Days = 0b00010000 +} diff --git a/src/iRLeagueApiCore.Common/Enums/UpdateKind.cs b/src/iRLeagueApiCore.Common/Enums/UpdateKind.cs new file mode 100644 index 00000000..b22b6226 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/UpdateKind.cs @@ -0,0 +1,30 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +public enum UpdateKind +{ + Loading, + Saving, + Updating +} diff --git a/src/iRLeagueApiCore.Common/Enums/WeekDaysFlag.cs b/src/iRLeagueApiCore.Common/Enums/WeekDaysFlag.cs new file mode 100644 index 00000000..4517478a --- /dev/null +++ b/src/iRLeagueApiCore.Common/Enums/WeekDaysFlag.cs @@ -0,0 +1,35 @@ +// MIT License + +// Copyright (c) 2020 Simon Schulze + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace iRLeagueApiCore.Common.Enums; + +[Flags] +public enum WeekDaysFlag +{ + Sunday = 1 << DayOfWeek.Sunday, + Monday = 1 << DayOfWeek.Monday, + Tuesday = 1 << DayOfWeek.Tuesday, + Wednesday = 1 << DayOfWeek.Wednesday, + Thursday = 1 << DayOfWeek.Thursday, + Friday = 1 << DayOfWeek.Friday, + Saturday = 1 << DayOfWeek.Saturday +} diff --git a/src/iRLeagueApiCore.Common/LeagueRoleValue.cs b/src/iRLeagueApiCore.Common/LeagueRoleValue.cs new file mode 100644 index 00000000..baf5026f --- /dev/null +++ b/src/iRLeagueApiCore.Common/LeagueRoleValue.cs @@ -0,0 +1,83 @@ +namespace iRLeagueApiCore.Common; + +public class LeagueRoleValue : IEquatable, IEquatable +{ + private readonly string value; + private readonly LeagueRoleValue[] implicitRoles; + + internal LeagueRoleValue(string value) + { + this.value = value; + implicitRoles = Array.Empty(); + } + + internal LeagueRoleValue(string value, IEnumerable implicitRoles) + { + this.value = value; + this.implicitRoles = implicitRoles + .SelectMany(x => new[] { x }.Concat(x.GetImplicitRoles())) + .ToArray(); + } + + public static implicit operator string(LeagueRoleValue role) => role.value; + + public bool Equals(LeagueRoleValue? other) + { + return value.Equals(other?.value, StringComparison.OrdinalIgnoreCase); + } + + public bool Equals(string? other) + { + return value.Equals(other, StringComparison.OrdinalIgnoreCase); + } + + public override string ToString() + { + return value; + } + + public IEnumerable GetImplicitRoles() + { + return implicitRoles.ToArray(); + } + + /// + /// Check wether this role is contained by this RoleValue or any of its implicit roles + /// + /// + /// + public bool HasRole(string role) + { + return value.Equals(role) || implicitRoles.Any(x => x.HasRole(role)); + } + + /// + /// Check wether this role is contained by this RoleValue or any of its implicit roles + /// + /// + /// + public bool HasRole(LeagueRoleValue role) + { + return HasRole(role.ToString()) || implicitRoles.Any(x => x.HasRole(role)); + } + + public override bool Equals(object? obj) + { + return Equals(obj?.ToString()); + } + + public override int GetHashCode() + { + return value.ToLower().GetHashCode(); + } + + public static bool operator ==(LeagueRoleValue left, LeagueRoleValue right) + { + return left.Equals(right); + } + + public static bool operator !=(LeagueRoleValue left, LeagueRoleValue right) + { + return !(left == right); + } +} diff --git a/src/iRLeagueApiCore.Common/LeagueRoles.cs b/src/iRLeagueApiCore.Common/LeagueRoles.cs new file mode 100644 index 00000000..480be09c --- /dev/null +++ b/src/iRLeagueApiCore.Common/LeagueRoles.cs @@ -0,0 +1,129 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.RegularExpressions; + +namespace iRLeagueApiCore.Common; + +public static class LeagueRoles +{ + /// + /// Member with restricted read access to public information: + /// schedules, sessions, results - but not incident reviews + /// + public const string Member = "Member"; + public static LeagueRoleValue MemberValue { get; } = new(Member); + /// + /// Member with read access to reviews and allowed to create and edit own reviews + /// No write access to schedules, sessions or results + /// + public const string Steward = "Steward"; + public static LeagueRoleValue StewardValue { get; } = new(Steward, new[] { MemberValue }); + /// + /// Organizer of the league + /// Write privileges but not allowed to delete seasons or assign roles + /// + public const string Organizer = "Organizer"; + public static LeagueRoleValue OrganizerValue { get; } = new(Organizer, new[] { MemberValue }); + /// + /// Administrator of the league with full privileges + /// + public const string Admin = "Admin"; + public static LeagueRoleValue AdminValue { get; } = new(Admin, new[] { OrganizerValue, StewardValue }); + /// + /// Owner of the league + /// Full privilige including right to delete + /// + public const string Owner = "Owner"; + public static LeagueRoleValue OwnerValue { get; } = new(Owner, new[] { AdminValue }); + + /// + /// Array of all available league roles + /// + public static LeagueRoleValue[] RolesAvailable { get; } = new[] + { + OwnerValue, + AdminValue, + OrganizerValue, + StewardValue, + MemberValue + }; + + /// + /// Delimiter used to separate between league name and role name + /// + public const char RoleDelimiter = ':'; + + /// + /// Get the full league role name for a provided league name and role name + /// + /// if is not valid + public static string? GetLeagueRoleName(string leagueName, string roleName) + { + if (IsValidRole(roleName) == false) + { + return null; + } + + return $"{leagueName.ToLower()}{RoleDelimiter}{CapitalizeRoleName(roleName)}"; + } + + public static string? GetRoleName(string leagueRoleName) + { + return leagueRoleName.Split(RoleDelimiter).ElementAtOrDefault(1); + } + + /// + /// Check wether a full league role name is a valid role name for the provided league + /// + /// + public static bool IsLeagueRoleName(string leagueName, string roleName) + { + var pattern = $"({leagueName})({RoleDelimiter})({string.Join('|', RolesAvailable)})"; + return Regex.IsMatch(roleName, pattern, RegexOptions.IgnoreCase); + } + + public static bool IsValidRole(string roleName) + { + return RolesAvailable.Any(x => x.Equals(roleName)); + } + + private static string CapitalizeRoleName(string roleName) + { + return char.ToUpper(roleName[0]) + roleName[1..].ToLower(); + } + + /// + /// Get the role value for a valid roleName + /// + /// + /// + /// If is not a valid roleName + public static LeagueRoleValue GetRoleValue(string roleName) + { + return RolesAvailable.FirstOrDefault(x => x.Equals(roleName)) + ?? throw new ArgumentException($"{roleName} is not a valid role", nameof(roleName)); + } + + public static bool CheckRole(LeagueRoleValue role, IEnumerable UserRoles) + { + return UserRoles.Any(x => x.HasRole(role)); + } + + public static IEnumerable ImplicitRoleOf(LeagueRoleValue role) + { + return RolesAvailable. + Where(x => x.GetImplicitRoles().Contains(role)); + } + + private class RoleComparer : IEqualityComparer + { + public bool Equals(string? x, string? y) + { + return x?.Equals(y, System.StringComparison.OrdinalIgnoreCase) == true; + } + + public int GetHashCode([DisallowNull] string obj) + { + return obj.ToLower().GetHashCode(); + } + } +} diff --git a/src/iRLeagueApiCore.Common/Models/Championships/ChampSeasonInfoModel.cs b/src/iRLeagueApiCore.Common/Models/Championships/ChampSeasonInfoModel.cs new file mode 100644 index 00000000..96b2847e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Championships/ChampSeasonInfoModel.cs @@ -0,0 +1,16 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class ChampSeasonInfoModel +{ + [DataMember] + public long ChampSeasonId { get; set; } + [DataMember] + public long ChampionshipId { get; set; } + [DataMember] + public long SeasonId { get; set; } + [DataMember] + public string ChampionshipName { get; set; } = string.Empty; + [DataMember] + public string SeasonName { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Championships/ChampSeasonModel.cs b/src/iRLeagueApiCore.Common/Models/Championships/ChampSeasonModel.cs new file mode 100644 index 00000000..c0948587 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Championships/ChampSeasonModel.cs @@ -0,0 +1,14 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class ChampSeasonModel : PutChampSeasonModel +{ + [DataMember] + public long ChampSeasonId { get; set; } + [DataMember] + public long ChampionshipId { get; set; } + [DataMember] + public long SeasonId { get; set; } + [DataMember] + public string SeasonName { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Championships/ChampionshipModel.cs b/src/iRLeagueApiCore.Common/Models/Championships/ChampionshipModel.cs new file mode 100644 index 00000000..353e98a9 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Championships/ChampionshipModel.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class ChampionshipModel : PutChampionshipModel +{ + [DataMember] + public long ChampionshipId { get; set; } + [DataMember] + public IReadOnlyCollection Seasons { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Championships/PostChampSeasonModel.cs b/src/iRLeagueApiCore.Common/Models/Championships/PostChampSeasonModel.cs new file mode 100644 index 00000000..2d730034 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Championships/PostChampSeasonModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PostChampSeasonModel +{ +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Championships/PostChampionshipModel.cs b/src/iRLeagueApiCore.Common/Models/Championships/PostChampionshipModel.cs new file mode 100644 index 00000000..f7de015c --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Championships/PostChampionshipModel.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PostChampionshipModel +{ + [DataMember] + public string Name { get; set; } = string.Empty; + [DataMember] + public string DisplayName { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Championships/PutChampSeasonModel.cs b/src/iRLeagueApiCore.Common/Models/Championships/PutChampSeasonModel.cs new file mode 100644 index 00000000..3831fbbd --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Championships/PutChampSeasonModel.cs @@ -0,0 +1,20 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PutChampSeasonModel : PostChampSeasonModel +{ + [DataMember] + public string ChampionshipName { get; set; } = string.Empty; + [DataMember] + public string ChampionshipDisplayName { get; set; } = string.Empty; + [DataMember] + public StandingConfigModel? StandingConfig { get; set; } + [DataMember] + public ICollection ResultConfigs { get; set; } = new List(); + [DataMember] + public ResultConfigInfoModel? DefaultResultConfig { get; set; } + [DataMember] + public ResultKind ResultKind { get; set; } + [DataMember] + public ICollection Filters { get; set; } = new List(); +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Championships/PutChampionshipModel.cs b/src/iRLeagueApiCore.Common/Models/Championships/PutChampionshipModel.cs new file mode 100644 index 00000000..30d53a4e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Championships/PutChampionshipModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PutChampionshipModel : PostChampionshipModel +{ +} diff --git a/src/iRLeagueApiCore.Common/Models/IVersionModel.cs b/src/iRLeagueApiCore.Common/Models/IVersionModel.cs new file mode 100644 index 00000000..9a858ffd --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/IVersionModel.cs @@ -0,0 +1,35 @@ +namespace iRLeagueApiCore.Common.Models; + +public interface IVersionModel +{ + /// + /// Date of creation + /// + [DataMember] + DateTime? CreatedOn { get; set; } + /// + /// Date of last modification + /// + [DataMember] + DateTime? LastModifiedOn { get; set; } + /// + /// User id that created the entry + /// + [DataMember] + string? CreatedByUserId { get; set; } + /// + /// User id that last modified the entry + /// + [DataMember] + string? LastModifiedByUserId { get; set; } + /// + /// User name that created the entry + /// + [DataMember] + string? CreatedByUserName { get; set; } + /// + /// User name that last modified the entry + /// + [DataMember] + string? LastModifiedByUserName { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Leagues/LeagueModel.cs b/src/iRLeagueApiCore.Common/Models/Leagues/LeagueModel.cs new file mode 100644 index 00000000..f1addb20 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Leagues/LeagueModel.cs @@ -0,0 +1,58 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Schema for fetching an existing league +/// +[DataContract] +public class LeagueModel : PostLeagueModel, IVersionModel +{ + /// + /// Unique league id + /// + [DataMember] + public long Id { get; set; } + [DataMember] + public bool IsInitialized { get; set; } + /// + /// Ids of seasons in this league + /// + [DataMember] + public IEnumerable SeasonIds { get; set; } = Array.Empty(); + [DataMember(EmitDefaultValue = false)] + public SubscriptionStatus? SubscriptionStatus { get; set; } + [DataMember(EmitDefaultValue = false)] + public DateTime? SubscriptionExpires { get; set; } + + #region version + /// + /// Date of creation + /// + [DataMember] + public DateTime? CreatedOn { get; set; } + /// + /// Date of last modification + /// + [DataMember] + public DateTime? LastModifiedOn { get; set; } + /// + /// User id that created the entry + /// + [DataMember] + public string? CreatedByUserId { get; set; } + /// + /// User id that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserId { get; set; } + /// + /// User name that created the entry + /// + [DataMember] + public string? CreatedByUserName { get; set; } + /// + /// User name that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserName { get; set; } + #endregion +} diff --git a/src/iRLeagueApiCore.Common/Models/Leagues/PostLeagueModel.cs b/src/iRLeagueApiCore.Common/Models/Leagues/PostLeagueModel.cs new file mode 100644 index 00000000..9740da18 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Leagues/PostLeagueModel.cs @@ -0,0 +1,16 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Schema for updating an existing league +/// +[DataContract] +public class PostLeagueModel : PutLeagueModel +{ + /// + /// Short name of the league + /// Used to identify the league in queries + /// Cannot contain spaces and only use characters: a-z A-Z 0-1 _ - + /// + [DataMember] + public string Name { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Leagues/PutLeagueModel.cs b/src/iRLeagueApiCore.Common/Models/Leagues/PutLeagueModel.cs new file mode 100644 index 00000000..de371fd9 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Leagues/PutLeagueModel.cs @@ -0,0 +1,54 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Schema for posting a new league +/// +[DataContract] +public class PutLeagueModel +{ + /// + /// Full name of the league can contain any UTF-8 characters + /// + [DataMember] + public string NameFull { get; set; } = string.Empty; + /// + /// Longtext description of the league. Will be displayed on the league welcome page in iRLeagueManager.Web application. + /// Supports markdown + /// + [DataMember] + public string Description { get; set; } = string.Empty; + /// + /// Plain text version of league description + /// + [DataMember] + public string DescriptionPlain { get; set; } = string.Empty; + [DataMember] + public bool EnableProtests { get; set; } + /// + /// Time span after a race has finished (according to event duration) after which a protest can be filed + /// + [DataMember] + public TimeSpan ProtestCoolDownPeriod { get; set; } + /// + /// Time span after a race has finished (according to event duration) until a protest can be filed + /// + [DataMember] + public TimeSpan ProtestsClosedAfter { get; set; } + /// + /// Set public visibility of protests + /// + [DataMember] + public ProtestPublicSetting ProtestsPublic { get; set; } + /// + /// Set who can access the protest form and file protests + /// + [DataMember] + public ProtestFormAccess ProtestFormAccess { get; set; } + [DataMember] + public LeaguePublicSetting LeaguePublic { get; set; } + /// + /// Enable access to protest form and reviews while race is running and before results have been uploaded + /// + [DataMember] + public bool EnableLiveReviews { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Members/MemberInfoModel.cs b/src/iRLeagueApiCore.Common/Models/Members/MemberInfoModel.cs new file mode 100644 index 00000000..540da4a6 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Members/MemberInfoModel.cs @@ -0,0 +1,17 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class MemberInfoModel : IEquatable +{ + [DataMember] + public long MemberId { get; set; } + [DataMember] + public string FirstName { get; set; } = string.Empty; + [DataMember] + public string LastName { get; set; } = string.Empty; + + bool IEquatable.Equals(MemberInfoModel? other) + { + return MemberId == other?.MemberId; + } +} diff --git a/src/iRLeagueApiCore.Common/Models/Members/MemberModel.cs b/src/iRLeagueApiCore.Common/Models/Members/MemberModel.cs new file mode 100644 index 00000000..55d386af --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Members/MemberModel.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class MemberModel : MemberInfoModel +{ + [DataMember] + public string IRacingId { get; set; } = string.Empty; + [DataMember] + public string TeamName { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/AutoPenaltyConfiguration.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/AutoPenaltyConfiguration.cs new file mode 100644 index 00000000..2deb16ea --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/AutoPenaltyConfiguration.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class AutoPenaltyConfiguration +{ + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long PenaltyConfigId { get; set; } + [DataMember] + public string Description { get; set; } = string.Empty; + [DataMember] + public PenaltyType Type { get; set; } + [DataMember(EmitDefaultValue = false)] + public int Points { get; set; } + [DataMember(EmitDefaultValue = false)] + public TimeSpan Time { get; set; } + [DataMember(EmitDefaultValue = false)] + public int Positions { get; set; } + [DataMember] + public ICollection Conditions { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/BonusPointModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/BonusPointModel.cs new file mode 100644 index 00000000..9784f6f4 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/BonusPointModel.cs @@ -0,0 +1,14 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class BonusPointModel +{ + [DataMember] + public BonusPointType Type { get; set; } + [DataMember] + public double Value { get; set; } + [DataMember] + public double Points { get; set; } + [DataMember] + public ICollection Conditions { get; set; } = new List(); +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/FilterConditionModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/FilterConditionModel.cs new file mode 100644 index 00000000..ea7cb205 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/FilterConditionModel.cs @@ -0,0 +1,16 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class FilterConditionModel +{ + [DataMember] + public FilterType FilterType { get; set; } + [DataMember] + public string ColumnPropertyName { get; set; } = string.Empty; + [DataMember] + public ComparatorType Comparator { get; set; } + [DataMember] + public ICollection FilterValues { get; set; } = new List(); + [DataMember] + public MatchedValueAction Action { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PointRuleModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PointRuleModel.cs new file mode 100644 index 00000000..cfd5d4c3 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PointRuleModel.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PointRuleModel : PutPointRuleModel +{ + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long PointRuleId { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PostPointRuleModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PostPointRuleModel.cs new file mode 100644 index 00000000..5d3e6b9f --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PostPointRuleModel.cs @@ -0,0 +1,26 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PostPointRuleModel +{ + [DataMember] + public string Name { get; set; } = string.Empty; + [DataMember] + public PointRuleType RuleType { get; set; } + [DataMember] + public IList PointsPerPlace { get; set; } = new List(); + [DataMember] + public ICollection BonusPoints { get; set; } = new List(); + [DataMember] + public string Formula { get; set; } = string.Empty; + [DataMember] + public int MaxPoints { get; set; } + public int PointDropOff { get; set; } + public ICollection PointsSortOptions { get; set; } = new List(); + public ICollection FinalSortOptions { get; set; } = new List(); + /// + /// List of configurations for automated penalties + /// + [DataMember] + public ICollection AutoPenalties { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PostResultConfigModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PostResultConfigModel.cs new file mode 100644 index 00000000..ec92f0f9 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PostResultConfigModel.cs @@ -0,0 +1,20 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PostResultConfigModel +{ + [DataMember] + public string Name { get; set; } = string.Empty; + [DataMember] + public string DisplayName { get; set; } = string.Empty; + [DataMember] + public ResultConfigInfoModel? SourceResultConfig { get; set; } + [DataMember] + public int ResultsPerTeam { get; set; } + [DataMember] + public IList Scorings { get; set; } = new List(); + [DataMember] + public ICollection FiltersForPoints { get; set; } = new List(); + [DataMember] + public ICollection FiltersForResult { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PostScoringModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PostScoringModel.cs new file mode 100644 index 00000000..22ba799e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PostScoringModel.cs @@ -0,0 +1,65 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Schema for creating a new scoring +/// +[DataContract] +public class PostScoringModel +{ + /// + /// Kind of scoring + /// + [DataMember] + [EnumDataType(typeof(ResultKind))] + [JsonConverter(typeof(JsonStringEnumConverter))] + public ResultKind ScoringKind { get; set; } + /// + /// Name of the scoring - shown in results + /// + [DataMember] + public string Name { get; set; } = string.Empty; + [DataMember] + public int Index { get; set; } + /// + /// Maximum number of results to use for calculating scorin group (e.g: Team scoring) + /// + [DataMember] + public int MaxResultsPerGroup { get; set; } + /// + /// External source for results if TakeResultsFromExtSource is true + /// + [DataMember] + public long? ExtScoringSourceId { get; set; } + /// + /// Use teams information available from uploaded result set + /// + [DataMember] + public bool UseResultSetTeam { get; set; } + /// + /// Update teams information on recalculation - this will overwrite the previous team in a scored row when a recalculation is triggered + /// If you do not want the team to change after the result has been uploaded first (e.g.: team change during the runnin season) set to false + /// + [DataMember] + public bool UpdateTeamOnRecalculation { get; set; } + /// + /// Show this result on the result page + /// If false the results calculated from this scoring wont be + /// + [DataMember] + public bool ShowResults { get; set; } + /// + /// True to combine result of all other scorings in this config + /// + [DataMember] + public bool IsCombinedResult { get; set; } + /// + /// Use the points from the source configuration (when calculating a combined result) + /// + [DataMember] + public bool UseSourcePoints { get; set; } + /// + /// Point rule to determine point for this scoring + /// + [DataMember] + public PointRuleModel? PointRule { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PutPointRuleModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PutPointRuleModel.cs new file mode 100644 index 00000000..5bf1739f --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PutPointRuleModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PutPointRuleModel : PostPointRuleModel +{ +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PutResultConfigModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PutResultConfigModel.cs new file mode 100644 index 00000000..d81bcf46 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PutResultConfigModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PutResultConfigModel : PostResultConfigModel +{ +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PutScoringModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PutScoringModel.cs new file mode 100644 index 00000000..135fcb39 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/PutScoringModel.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Schema for updating an existing scoring +/// +public class PutScoringModel : PostScoringModel +{ +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ResultConfigInfoModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ResultConfigInfoModel.cs new file mode 100644 index 00000000..1270d193 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ResultConfigInfoModel.cs @@ -0,0 +1,20 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class ResultConfigInfoModel +{ + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long ResultConfigId { get; set; } + [DataMember] + public long ChampSeasonId { get; set; } + [DataMember] + public string ChampionshipName { get; set; } = string.Empty; + [DataMember] + public string Name { get; set; } = string.Empty; + [DataMember] + public string DisplayName { get; set; } = string.Empty; + [DataMember] + public bool IsDefaultConfig { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ResultConfigModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ResultConfigModel.cs new file mode 100644 index 00000000..dc2ce352 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ResultConfigModel.cs @@ -0,0 +1,16 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class ResultConfigModel : PutResultConfigModel +{ + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long ResultConfigId { get; set; } + [DataMember] + public long ChampSeasonId { get; set; } + [DataMember] + public string ChampionshipName { get; set; } = string.Empty; + [DataMember] + public bool IsDefaultConfig { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ResultFilterModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ResultFilterModel.cs new file mode 100644 index 00000000..fea46be6 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ResultFilterModel.cs @@ -0,0 +1,12 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class ResultFilterModel +{ + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long FilterOptionId { get; set; } + [DataMember] + public FilterConditionModel Condition { get; set; } = new(); +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ScoringModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ScoringModel.cs new file mode 100644 index 00000000..862efb5d --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/ScoringModel.cs @@ -0,0 +1,53 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Schema for fetching an existing scoring +/// +public class ScoringModel : PutScoringModel, IVersionModel +{ + /// + /// Id of the scoring + /// + [DataMember] + public long Id { get; set; } + /// + /// Id of the league the scoring belongs to + /// + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long ResultConfigId { get; set; } + + #region version + /// + /// Date of creation + /// + [DataMember] + public DateTime? CreatedOn { get; set; } + /// + /// Date of last modification + /// + [DataMember] + public DateTime? LastModifiedOn { get; set; } + /// + /// User id that created the entry + /// + [DataMember] + public string? CreatedByUserId { get; set; } + /// + /// User id that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserId { get; set; } + /// + /// User name that created the entry + /// + [DataMember] + public string? CreatedByUserName { get; set; } + /// + /// User name that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserName { get; set; } + #endregion +} diff --git a/src/iRLeagueApiCore.Common/Models/ResultConfigurations/StandingConfigModel.cs b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/StandingConfigModel.cs new file mode 100644 index 00000000..9742a048 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/ResultConfigurations/StandingConfigModel.cs @@ -0,0 +1,18 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class StandingConfigModel +{ + [DataMember] + public long StandingConfigId { get; set; } + [DataMember] + public string Name { get; set; } = string.Empty; + [DataMember] + public ResultKind ResultKind { get; set; } + [DataMember] + public bool UseCombinedResult { get; set; } + [DataMember] + public int WeeksCounted { get; set; } + [DataMember] + public ICollection SortOptions { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Results/CarListModel.cs b/src/iRLeagueApiCore.Common/Models/Results/CarListModel.cs new file mode 100644 index 00000000..0e4f0021 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Results/CarListModel.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Models.Results; + +[DataContract] +public sealed class CarListModel +{ + [DataMember] + public bool IsTeamEvent { get; set; } + [DataMember] + public IEnumerable Cars { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Results/EventCarInfoModel.cs b/src/iRLeagueApiCore.Common/Models/Results/EventCarInfoModel.cs new file mode 100644 index 00000000..a47c606e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Results/EventCarInfoModel.cs @@ -0,0 +1,23 @@ +namespace iRLeagueApiCore.Common.Models.Results; + +/// +/// Contains information about a specific car in an event and it's driver(s) or team +/// +[DataContract] +public sealed class EventCarInfoModel +{ + [DataMember] + public string Number { get; set; } = string.Empty; + [DataMember] + public string Car { get; set; } = string.Empty; + [DataMember] + public int CarId { get; set; } + [DataMember] + public int ClassId { get;} + [DataMember] + public string Class { get; set; } = string.Empty; + [DataMember] + public IEnumerable Members { get; set; } = Array.Empty(); + [DataMember] + public TeamInfoModel? Team { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Results/EventResultModel.cs b/src/iRLeagueApiCore.Common/Models/Results/EventResultModel.cs new file mode 100644 index 00000000..e3dc32d1 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Results/EventResultModel.cs @@ -0,0 +1,30 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class EventResultModel +{ + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long EventId { get; set; } + [DataMember] + public long ResultId { get; set; } + [DataMember] + public long SeasonId { get; set; } + [DataMember] + public string EventName { get; set; } = string.Empty; + [DataMember] + public string DisplayName { get; set; } = string.Empty; + [DataMember] + public DateTime Date { get; set; } + [DataMember] + public long TrackId { get; set; } + [DataMember] + public string TrackName { get; set; } = string.Empty; + [DataMember] + public string ConfigName { get; set; } = string.Empty; + [DataMember] + public int StrengthOfField { get; set; } + [DataMember] + public IEnumerable SessionResults { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Results/Interval.cs b/src/iRLeagueApiCore.Common/Models/Results/Interval.cs new file mode 100644 index 00000000..a095b9dc --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Results/Interval.cs @@ -0,0 +1,36 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class Interval : IComparable, IComparable +{ + public Interval() + { + Time = TimeSpan.Zero; + Laps = 0; + } + + public Interval(TimeSpan interval) + { + Time = interval.Subtract(TimeSpan.FromDays(interval.Days)); + Laps = interval.Days; + } + + [DataMember] + public TimeSpan Time { get; set; } + [DataMember] + public int Laps { get; set; } + + int IComparable.CompareTo(Interval? other) + { + return ((IComparable)this).CompareTo(other); + } + + int IComparable.CompareTo(object? obj) + { + if (obj is Interval other) + { + return Time.Add(TimeSpan.FromDays(Laps)).CompareTo(other.Time.Add(TimeSpan.FromDays(other.Laps))); + } + return 1; + } +} diff --git a/src/iRLeagueApiCore.Common/Models/Results/ResultModel.cs b/src/iRLeagueApiCore.Common/Models/Results/ResultModel.cs new file mode 100644 index 00000000..fc93ea7e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Results/ResultModel.cs @@ -0,0 +1,101 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Get a complete scored result from the database +/// +[DataContract] +public class ResultModel +{ + /// + /// Id of the league + /// + public long LeagueId { get; set; } + /// + /// Id of the season the result belongs to + /// + public long SeasonId { get; set; } + /// + /// Id of the unique session result + /// + [DataMember] + public long SessionResultId { get; set; } + /// + /// Name of the season the result belongs to + /// + [DataMember] + public string SeasonName { get; set; } = string.Empty; + /// + /// Id of the schedule the result belongs to + /// + [DataMember] + public long ScheduleId { get; set; } + /// + /// Name of the schedule the result belongs to + /// + [DataMember] + public string ScheduleName { get; set; } = string.Empty; + /// + /// Id of the event the result belongs to + /// + [DataMember] + public long EventId { get; set; } + /// + /// Name of the event the result belongs to + /// + [DataMember] + public string EventName { get; set; } = string.Empty; + /// + /// Id of the session the result belongs to + /// + [DataMember] + public long? SessionId { get; set; } + /// + /// Name of the session the result belongs to + /// + [DataMember] + public string SessionName { get; set; } = string.Empty; + /// + /// Number of the session order + /// + [DataMember] + public int? SessionNr { get; set; } + /// + /// Id of the scoring for this result + /// + [DataMember] + public long? ScoringId { get; set; } + /// + /// Name of the scoring for this result + /// + [DataMember] + public string ScoringName { get; set; } = string.Empty; + /// + /// List of entries + /// + [DataMember(IsRequired = true)] + public IEnumerable ResultRows { get; set; } = Array.Empty(); + + [DataMember] + public TimeSpan? FastestLapTime { get; set; } + [DataMember] + public MemberInfoModel? FastestLapDriver { get; set; } + [DataMember] + public TimeSpan? PoleLapTime { get; set; } + [DataMember] + public MemberInfoModel? PoleLapDriver { get; set; } + [DataMember] + public IEnumerable? CleanestDrivers { get; set; } + + #region version + /// + /// Date of creation + /// + [DataMember] + public DateTime? CreatedOn { get; set; } + /// + /// Date of last modification + /// + [DataMember] + public DateTime? LastModifiedOn { get; set; } + #endregion +} diff --git a/src/iRLeagueApiCore.Common/Models/Results/ResultRowModel.cs b/src/iRLeagueApiCore.Common/Models/Results/ResultRowModel.cs new file mode 100644 index 00000000..ce4cd5d7 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Results/ResultRowModel.cs @@ -0,0 +1,220 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Get a scored result row from the database +/// +[DataContract] +public class ResultRowModel +{ + [DataMember] + public long ScoredResultRowId { get; set; } + /// + /// First name of the driver + /// + [DataMember] + public string Firstname { get; set; } = string.Empty; + /// + /// Last name of the driver + /// + [DataMember] + public string Lastname { get; set; } = string.Empty; + /// + /// Team name of the drivers team (or team result) + /// + [DataMember] + public string TeamName { get; set; } = string.Empty; + /// + /// Hex code for team color + /// + [DataMember] + public string TeamColor { get; set; } = string.Empty; + /// + /// Posiion at start of race session (equal to qually result when using attached qualifying) + /// + [DataMember] + public double StartPosition { get; set; } + /// + /// Finish position in the race results (iracing penalties are applied - league penalties are not) + /// + [DataMember] + public double FinishPosition { get; set; } + /// + /// Iracing id of the member + /// + [DataMember] + public long? MemberId { get; set; } + /// + /// Car number in the session + /// + [DataMember] + public string CarNumber { get; set; } = string.Empty; + /// + /// Class id in the session (in multiclass sessions) + /// + [DataMember] + public int ClassId { get; set; } + /// + /// Id of the iracing member club + /// + [DataMember] + public int ClubId { get; set; } + /// + /// Name of the iracing member club + /// + [DataMember] + public string ClubName { get; set; } = string.Empty; + /// + /// Name of the car (e.g: "Skip Barber RT200") + /// + [DataMember] + public string Car { get; set; } = string.Empty; + /// + /// Name of the car class (in multiclass sessions) + /// + [DataMember] + public string CarClass { get; set; } = string.Empty; + /// + /// Number of completed laps in the main session (only includes laps from one session type e.g: race) + /// + [DataMember] + public double CompletedLaps { get; set; } + /// + /// Number of laps lead by this driver (only race) + /// + [DataMember] + public double LeadLaps { get; set; } + /// + /// Number of the fastest laps of this driver (applicable to all session types) + /// + [DataMember] + public int FastLapNr { get; set; } + /// + /// Number of incidents in the session (only main session) + /// + [DataMember] + public double Incidents { get; set; } + /// + /// Driver status at the end of the race (checkered flag) + /// + [DataMember] + public RaceStatus Status { get; set; } + /// + /// Time set in qualifying (only available with attached qualy) + /// + [DataMember] + public TimeSpan QualifyingTime { get; set; } + /// + /// Interval to the leading driver + /// + [DataMember] + public Interval Interval { get; set; } = new(); + /// + /// Average lap time in the main session + /// + [DataMember] + public TimeSpan AvgLapTime { get; set; } + /// + /// Fastest lap time in the main session + /// + [DataMember] + public TimeSpan FastestLapTime { get; set; } + /// + /// Position change StartPos -> FinPos during the main session + /// + [DataMember] + public double PositionChange { get; set; } + /// + /// Irating before the event + /// + [DataMember] + public int OldIrating { get; set; } + /// + /// Irating after completing the event + /// + [DataMember] + public int NewIrating { get; set; } + /// + /// Irating at the start of the season + /// + [DataMember] + public int SeasonStartIrating { get; set; } + /// + /// License class of the driver + /// + [DataMember] + public string License { get; set; } = string.Empty; + /// + /// Driver safety rating before the event + /// + [DataMember] + public double OldSafetyRating { get; set; } + /// + /// Driver safety rating after completing the event + /// + [DataMember] + public double NewSafetyRating { get; set; } + /// + /// Driver/Team car id + /// + [DataMember] + public int CarId { get; set; } + /// + /// Completed race distance + /// When omited the value is calculated based on driver-laps/session-laps + /// + [DataMember] + public double? CompletedPct { get; set; } + /// + /// Iracing division of the driver + /// + [DataMember] + public int Division { get; set; } + /// + /// Driver License level before the event + /// + [DataMember] + public int OldLicenseLevel { get; set; } + /// + /// Driver license level after completing the event + /// + [DataMember] + public int NewLicenseLevel { get; set; } + /// + /// [optional] Id of the team the driver was part in this event + /// omit for no team + /// + [DataMember] + public long? TeamId { get; set; } + /// + /// Points gained from result in the race + /// + [DataMember] + public double RacePoints { get; set; } + /// + /// Points gained from bonus condition (will be added to race points) + /// + [DataMember] + public double BonusPoints { get; set; } + /// + /// Points deducted as penalty (Value is positive but points will be deducted from race points) + /// + [DataMember] + public double PenaltyPoints { get; set; } + /// + /// Total scored points -> sum of: (RacePoints + BonusPoints - PenaltyPoints) + /// + [DataMember] + public double TotalPoints { get; set; } + /// + /// Final position after all scoring rules and penalties are applied + /// + [DataMember] + public int FinalPosition { get; set; } + /// + /// Position change StartPosition -> FinalPosition + /// + [DataMember] + public double FinalPositionChange { get; set; } + [DataMember] + public IEnumerable TeamResultRows { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Results/SeasonResultsModel.cs b/src/iRLeagueApiCore.Common/Models/Results/SeasonResultsModel.cs new file mode 100644 index 00000000..8e296c94 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Results/SeasonResultsModel.cs @@ -0,0 +1,16 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class SeasonEventResultModel +{ + [DataMember] + public long EventId { get; set; } + [DataMember] + public string EventName { get; set; } = string.Empty; + [DataMember] + public string TrackName { get; set; } = string.Empty; + [DataMember] + public string ConfigName { get; set; } = string.Empty; + [DataMember] + public IEnumerable EventResults { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PenaltyModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PenaltyModel.cs new file mode 100644 index 00000000..fdd6c739 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PenaltyModel.cs @@ -0,0 +1,24 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class PenaltyModel : PutPenaltyModel +{ + [DataMember] + public long ResultRowId { get; set; } + [DataMember] + public long? AddPenaltyId { get; set; } + [DataMember(EmitDefaultValue = false)] + public long? ReviewId { get; set; } + [DataMember(EmitDefaultValue = false)] + public long? ReviewVoteId { get; set; } + [DataMember] + public long EventId { get; set; } + [DataMember] + public int SessionNr { get; set; } + [DataMember] + public string SessionName { get; set; } = string.Empty; + [DataMember] + public MemberInfoModel? Member { get; set; } + [DataMember] + public TeamInfoModel? Team { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PostPenaltyModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PostPenaltyModel.cs new file mode 100644 index 00000000..1e66cc7e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PostPenaltyModel.cs @@ -0,0 +1,20 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PostPenaltyModel +{ + [DataMember] + public string Lap { get; set; } = string.Empty; + [DataMember] + public string Corner { get; set; } = string.Empty; + [DataMember] + public string Reason { get; set; } = string.Empty; + [DataMember] + public PenaltyType Type { get; set; } + [DataMember(EmitDefaultValue = false)] + public int Points { get; set; } + [DataMember(EmitDefaultValue = false)] + public TimeSpan Time { get; set; } + [DataMember(EmitDefaultValue = false)] + public int Positions { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PostProtestModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PostProtestModel.cs new file mode 100644 index 00000000..3bc5ed92 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PostProtestModel.cs @@ -0,0 +1,18 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PostProtestModel +{ + [DataMember] + public long AuthorMemberId { get; set; } + [DataMember] + public string ConfirmIRacingId { get; set; } = string.Empty; + [DataMember] + public string FullDescription { get; set; } = string.Empty; + [DataMember] + public string OnLap { get; set; } = string.Empty; + [DataMember] + public string Corner { get; set; } = string.Empty; + [DataMember] + public IList InvolvedMembers { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PostReviewCommentModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PostReviewCommentModel.cs new file mode 100644 index 00000000..820db343 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PostReviewCommentModel.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class PostReviewCommentModel +{ + [DataMember] + public string Text { get; set; } = string.Empty; + [DataMember] + public ICollection Votes { get; set; } = Array.Empty(); +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PostReviewModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PostReviewModel.cs new file mode 100644 index 00000000..605baf75 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PostReviewModel.cs @@ -0,0 +1,26 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class PostReviewModel +{ + [DataMember] + public string IncidentKind { get; set; } = string.Empty; + [DataMember] + public string FullDescription { get; set; } = string.Empty; + [DataMember] + public string OnLap { get; set; } = string.Empty; + [DataMember] + public string Corner { get; set; } = string.Empty; + [DataMember] + public TimeSpan TimeStamp { get; set; } + [DataMember] + public string IncidentNr { get; set; } = string.Empty; + [DataMember] + public ICollection InvolvedMembers { get; set; } = new List(); + [DataMember] + public ICollection InvolvedTeams { get; set; } = new List(); + [DataMember] + public string ResultText { get; set; } = string.Empty; + [DataMember] + public ICollection VoteResults { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PostVoteCategoryModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PostVoteCategoryModel.cs new file mode 100644 index 00000000..e65d376f --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PostVoteCategoryModel.cs @@ -0,0 +1,12 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class PostVoteCategoryModel +{ + [DataMember] + public string Text { get; set; } = string.Empty; + [DataMember] + public int Index { get; set; } + [DataMember] + public int DefaultPenalty { get; set; } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/ProtestModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/ProtestModel.cs new file mode 100644 index 00000000..26a2b381 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/ProtestModel.cs @@ -0,0 +1,18 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class ProtestModel : PutProtestModel +{ + [DataMember] + public MemberInfoModel Author { get; set; } = new(); + [DataMember] + public long ProtestId { get; set; } + [DataMember] + public long EventId { get; set; } + [DataMember] + public long SessionId { get; set; } + [DataMember] + public int SessionNr { get; set; } + [DataMember] + public string SessionName { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PutPenaltyModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PutPenaltyModel.cs new file mode 100644 index 00000000..9aa65ece --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PutPenaltyModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PutPenaltyModel : PostPenaltyModel +{ +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PutProtestModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PutProtestModel.cs new file mode 100644 index 00000000..e619255e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PutProtestModel.cs @@ -0,0 +1,14 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PutProtestModel +{ + [DataMember] + public string FullDescription { get; set; } = string.Empty; + [DataMember] + public string OnLap { get; set; } = string.Empty; + [DataMember] + public string Corner { get; set; } = string.Empty; + [DataMember] + public ICollection InvolvedMembers { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PutReviewCommentModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PutReviewCommentModel.cs new file mode 100644 index 00000000..71b26b42 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PutReviewCommentModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class PutReviewCommentModel : PostReviewCommentModel +{ +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PutReviewModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PutReviewModel.cs new file mode 100644 index 00000000..11bed8e4 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PutReviewModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class PutReviewModel : PostReviewModel +{ +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/PutVoteCategoryModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/PutVoteCategoryModel.cs new file mode 100644 index 00000000..15ca6ca0 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/PutVoteCategoryModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class PutVoteCategoryModel : PostVoteCategoryModel +{ +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/ReviewCommentModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/ReviewCommentModel.cs new file mode 100644 index 00000000..a5ec5a98 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/ReviewCommentModel.cs @@ -0,0 +1,51 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class ReviewCommentModel : PutReviewCommentModel, IVersionModel +{ + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long CommentId { get; set; } + [DataMember] + public long ReviewId { get; set; } + [DataMember] + public DateTime? Date { get; set; } + [DataMember] + public string AuthorUserId { get; set; } = string.Empty; + [DataMember] + public string AuthorName { get; set; } = string.Empty; + + #region version + /// + /// Date of creation + /// + [DataMember] + public DateTime? CreatedOn { get; set; } + /// + /// Date of last modification + /// + [DataMember] + public DateTime? LastModifiedOn { get; set; } + /// + /// User id that created the entry + /// + [DataMember] + public string? CreatedByUserId { get; set; } + /// + /// User id that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserId { get; set; } + /// + /// User name that created the entry + /// + [DataMember] + public string? CreatedByUserName { get; set; } + /// + /// User name that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserName { get; set; } + #endregion +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/ReviewModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/ReviewModel.cs new file mode 100644 index 00000000..e9428476 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/ReviewModel.cs @@ -0,0 +1,59 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class ReviewModel : PutReviewModel, IVersionModel +{ + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long ReviewId { get; set; } + [DataMember] + public long SeasonId { get; set; } + [DataMember] + public long EventId { get; set; } + [DataMember] + public long SessionId { get; set; } + [DataMember] + public int SessionNr { get; set; } + [DataMember] + public string SessionName { get; set; } = string.Empty; + [DataMember] + public string AuthorUserId { get; set; } = string.Empty; + [DataMember] + public string AuthorName { get; set; } = string.Empty; + [DataMember] + public IEnumerable ReviewComments { get; set; } = Array.Empty(); + + #region version + /// + /// Date of creation + /// + [DataMember] + public DateTime? CreatedOn { get; set; } + /// + /// Date of last modification + /// + [DataMember] + public DateTime? LastModifiedOn { get; set; } + /// + /// User id that created the entry + /// + [DataMember] + public string? CreatedByUserId { get; set; } + /// + /// User id that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserId { get; set; } + /// + /// User name that created the entry + /// + [DataMember] + public string? CreatedByUserName { get; set; } + /// + /// User name that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserName { get; set; } + #endregion +} diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/VoteCategoryModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/VoteCategoryModel.cs new file mode 100644 index 00000000..96400b74 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/VoteCategoryModel.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class VoteCategoryModel : PutVoteCategoryModel +{ + [DataMember] + public long Id { get; set; } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Reviews/VoteModel.cs b/src/iRLeagueApiCore.Common/Models/Reviews/VoteModel.cs new file mode 100644 index 00000000..f2ef92ae --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Reviews/VoteModel.cs @@ -0,0 +1,18 @@ +namespace iRLeagueApiCore.Common.Models.Reviews; + +[DataContract] +public class VoteModel +{ + [DataMember] + public long Id { get; set; } + [DataMember] + public long? VoteCategoryId { get; set; } + [DataMember] + public string? VoteCategoryText { get; set; } + [DataMember] + public string Description { get; set; } = string.Empty; + [DataMember] + public MemberInfoModel? MemberAtFault { get; set; } + [DataMember] + public TeamInfoModel? TeamAtFault { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Schedules/PostScheduleModel.cs b/src/iRLeagueApiCore.Common/Models/Schedules/PostScheduleModel.cs new file mode 100644 index 00000000..d1f4dfe9 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Schedules/PostScheduleModel.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Common.Models; + +public class PostScheduleModel : PutScheduleModel +{ +} diff --git a/src/iRLeagueApiCore.Common/Models/Schedules/PutScheduleModel.cs b/src/iRLeagueApiCore.Common/Models/Schedules/PutScheduleModel.cs new file mode 100644 index 00000000..252ab9bb --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Schedules/PutScheduleModel.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PutScheduleModel +{ + [DataMember] + public string Name { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Schedules/ScheduleModel.cs b/src/iRLeagueApiCore.Common/Models/Schedules/ScheduleModel.cs new file mode 100644 index 00000000..8f1879ac --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Schedules/ScheduleModel.cs @@ -0,0 +1,47 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class ScheduleModel : PutScheduleModel, IVersionModel +{ + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long ScheduleId { get; set; } + [DataMember] + public long SeasonId { get; set; } + [DataMember] + public IEnumerable EventIds { get; set; } = Array.Empty(); + + #region version + /// + /// Date of creation + /// + [DataMember] + public DateTime? CreatedOn { get; set; } + /// + /// Date of last modification + /// + [DataMember] + public DateTime? LastModifiedOn { get; set; } + /// + /// User id that created the entry + /// + [DataMember] + public string? CreatedByUserId { get; set; } + /// + /// User id that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserId { get; set; } + /// + /// User name that created the entry + /// + [DataMember] + public string? CreatedByUserName { get; set; } + /// + /// User name that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserName { get; set; } + #endregion +} diff --git a/src/iRLeagueApiCore.Common/Models/SearchModel.cs b/src/iRLeagueApiCore.Common/Models/SearchModel.cs new file mode 100644 index 00000000..2bd03d3b --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/SearchModel.cs @@ -0,0 +1,20 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Model providing data for search functionalty (e.g.: search user by name(s)) +/// +[DataContract] +public class SearchModel +{ + /// + /// Array of search keys to search a match for + /// + [DataMember] + public IEnumerable SearchKeys { get; set; } = Array.Empty(); + /// + /// If true -> only return sets that match all of the provided search keys + /// Default: + /// + [DataMember] + public bool MatchAll { get; set; } = false; +} diff --git a/src/iRLeagueApiCore.Common/Models/Seasons/PostSeasonModel.cs b/src/iRLeagueApiCore.Common/Models/Seasons/PostSeasonModel.cs new file mode 100644 index 00000000..eeed28c5 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Seasons/PostSeasonModel.cs @@ -0,0 +1,14 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PostSeasonModel +{ + [DataMember] + public string SeasonName { get; set; } = string.Empty; + [DataMember] + public long? MainScoringId { get; set; } + [DataMember] + public bool HideComments { get; set; } + [DataMember] + public bool Finished { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Seasons/PutSeasonModel.cs b/src/iRLeagueApiCore.Common/Models/Seasons/PutSeasonModel.cs new file mode 100644 index 00000000..fe44ee33 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Seasons/PutSeasonModel.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PutSeasonModel : PostSeasonModel +{ + +} diff --git a/src/iRLeagueApiCore.Common/Models/Seasons/SeasonModel.cs b/src/iRLeagueApiCore.Common/Models/Seasons/SeasonModel.cs new file mode 100644 index 00000000..b700c625 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Seasons/SeasonModel.cs @@ -0,0 +1,49 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class SeasonModel : PutSeasonModel, IVersionModel +{ + [DataMember] + public long SeasonId { get; set; } + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public DateTime? SeasonStart { get; set; } + [DataMember] + public DateTime? SeasonEnd { get; set; } + [DataMember] + public IEnumerable ScheduleIds { get; set; } = Array.Empty(); + + #region version + /// + /// Date of creation + /// + [DataMember] + public DateTime? CreatedOn { get; set; } + /// + /// Date of last modification + /// + [DataMember] + public DateTime? LastModifiedOn { get; set; } + /// + /// User id that created the entry + /// + [DataMember] + public string? CreatedByUserId { get; set; } + /// + /// User id that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserId { get; set; } + /// + /// User name that created the entry + /// + [DataMember] + public string? CreatedByUserName { get; set; } + /// + /// User name that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserName { get; set; } + #endregion +} diff --git a/src/iRLeagueApiCore.Common/Models/Sessions/EventModel.cs b/src/iRLeagueApiCore.Common/Models/Sessions/EventModel.cs new file mode 100644 index 00000000..b572b6fb --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Sessions/EventModel.cs @@ -0,0 +1,28 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class EventModel : PutEventModel +{ + /// + /// EventId + /// + [DataMember] + public long Id { get; set; } + [DataMember] + public long LeagueId { get; set; } + [DataMember] + public long SeasonId { get; set; } + /// + /// Id of the schedule this event belongs to + /// + [DataMember] + public long ScheduleId { get; set; } + [DataMember] + public bool HasResult { get; set; } + [DataMember] + public string TrackName { get; set; } = string.Empty; + [DataMember] + public string ConfigName { get; set; } = string.Empty; + [DataMember(EmitDefaultValue = false)] + public SimSessionDetailsModel? SimSessionDetails { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Sessions/PostEventModel.cs b/src/iRLeagueApiCore.Common/Models/Sessions/PostEventModel.cs new file mode 100644 index 00000000..77a12300 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Sessions/PostEventModel.cs @@ -0,0 +1,33 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PostEventModel +{ + public string Name { get; set; } = string.Empty; + + [DataMember] + [EnumDataType(typeof(EventType))] + public EventType EventType { get; set; } + /// + /// Day and time of session start + /// + [DataMember] + public DateTime? Date { get; set; } + /// + /// Track id of the location + /// + [DataMember] + public long? TrackId { get; set; } + /// + /// Total duration of the session including all Subsessions and events + /// + [DataMember] + public TimeSpan Duration { get; set; } + /// + /// Sessions configured for this event + /// + [DataMember] + public ICollection Sessions { get; set; } = new List(); + [DataMember] + public ICollection ResultConfigs { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Sessions/PostSessionModel.cs b/src/iRLeagueApiCore.Common/Models/Sessions/PostSessionModel.cs new file mode 100644 index 00000000..c559cbf8 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Sessions/PostSessionModel.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Common.Models; + +public class PostSessionModel : PutSessionModel +{ +} diff --git a/src/iRLeagueApiCore.Common/Models/Sessions/PutEventModel.cs b/src/iRLeagueApiCore.Common/Models/Sessions/PutEventModel.cs new file mode 100644 index 00000000..7e238d90 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Sessions/PutEventModel.cs @@ -0,0 +1,9 @@ +namespace iRLeagueApiCore.Common.Models; + +public class PutEventModel : PostEventModel +{ + /// + /// Ids of ResultConfigurations to connect with this event + /// + ICollection ResultConfigIds { get; set; } = new List(); +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Sessions/PutSessionModel.cs b/src/iRLeagueApiCore.Common/Models/Sessions/PutSessionModel.cs new file mode 100644 index 00000000..17d56177 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Sessions/PutSessionModel.cs @@ -0,0 +1,36 @@ +#if NETCOREAPP +#endif + +namespace iRLeagueApiCore.Common.Models; + +/// +/// Scheme for creating and updating a session entry +/// +[DataContract] +public class PutSessionModel +{ + /// + /// Name of the session + /// + [DataMember] + public string Name { get; set; } = string.Empty; + /// + /// Number that defines order of sessions in event + /// + [DataMember] + public int SessionNr { get; set; } + /// + /// Session type specifier - 0 = Undefined, 1 = Practice, 2 = Qualifying, 3 = Race, 4 = HeatEvent, 5 = Heat, 6 = Warmup + /// + [DataMember] +#if NETCOREAPP + [EnumDataType(typeof(SessionType))] + [JsonConverter(typeof(JsonStringEnumConverter))] +#endif + public SessionType SessionType { get; set; } + [DataMember] + public int Laps { get; set; } + [DataMember] + public TimeSpan Duration { get; set; } + +} diff --git a/src/iRLeagueApiCore.Common/Models/Sessions/SessionModel.cs b/src/iRLeagueApiCore.Common/Models/Sessions/SessionModel.cs new file mode 100644 index 00000000..88592477 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Sessions/SessionModel.cs @@ -0,0 +1,57 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Scheme for fetching a session entry +/// +[DataContract] +public class SessionModel : PutSessionModel, IVersionModel +{ + /// + /// Unique identifier + /// + [DataMember] + public long SessionId { get; set; } + /// + /// Id of the league this session belongs to + /// + [DataMember] + public long LeagueId { get; set; } + /// + /// Flag shows if result is available + /// + [DataMember] + public bool HasResult { get; set; } + + #region version + /// + /// Date of creation + /// + [DataMember] + public DateTime? CreatedOn { get; set; } + /// + /// Date of last modification + /// + [DataMember] + public DateTime? LastModifiedOn { get; set; } + /// + /// User id that created the entry + /// + [DataMember] + public string? CreatedByUserId { get; set; } + /// + /// User id that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserId { get; set; } + /// + /// User name that created the entry + /// + [DataMember] + public string? CreatedByUserName { get; set; } + /// + /// User name that last modified the entry + /// + [DataMember] + public string? LastModifiedByUserName { get; set; } + #endregion +} diff --git a/src/iRLeagueApiCore.Common/Models/Sessions/SimSessionDetailsModel.cs b/src/iRLeagueApiCore.Common/Models/Sessions/SimSessionDetailsModel.cs new file mode 100644 index 00000000..291dc36e --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Sessions/SimSessionDetailsModel.cs @@ -0,0 +1,29 @@ +namespace iRLeagueApiCore.Common.Models; + +public class SimSessionDetailsModel +{ + public long SessionDetailsId { get; set; } + public long IRSubsessionId { get; set; } + public int IRRaceWeek { get; set; } + public long IRSessionId { get; set; } + public int LicenseCategory { get; set; } + public string SessionName { get; set; } = string.Empty; + public DateTime? StartTime { get; set; } + public DateTime? EndTime { get; set; } + public int EventStrengthOfField { get; set; } + public TimeSpan EventAverageLap { get; set; } + public int EventLapsComplete { get; set; } + public int TimeOfDay { get; set; } + public int WeatherType { get; set; } + public int TempUnits { get; set; } + public int TempValue { get; set; } + public int RelHumidity { get; set; } + public int Fog { get; set; } + public int WindDir { get; set; } + public int WindUnits { get; set; } + public int Skies { get; set; } + public int WeatherVarInitial { get; set; } + public int WeatherVarOngoing { get; set; } + public DateTime? SimStartUtcTime { get; set; } + public TimeSpan SimStartUtcOffset { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/SimSessionDetails.cs b/src/iRLeagueApiCore.Common/Models/SimSessionDetails.cs new file mode 100644 index 00000000..7ef29c38 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/SimSessionDetails.cs @@ -0,0 +1,249 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Extended session information about the iracing subsession +/// +[DataContract] +public class SimSessionDetails +{ + /// + /// Id of the iracing subsession + /// + [DataMember] + public long IRSubsessionId { get; set; } + /// + /// Id of the iracing season + /// + [DataMember] + public long IRSeasonId { get; set; } + /// + /// Name of the iracing season + /// + [DataMember] + public string IRSeasonName { get; set; } = string.Empty; + /// + /// Year of the iracing season + /// + [DataMember] + public int IRSeasonYear { get; set; } + /// + /// Quarter of the iracing season + /// + [DataMember] + public int IRSeasonQuarter { get; set; } + /// + /// Race week in the iracing season + /// + [DataMember] + public int IRRaceWeek { get; set; } + /// + /// Id of the iracing session + /// + [DataMember] + public long IRSessionId { get; set; } + /// + /// License category of the iracing session + /// + [DataMember] + public int LicenseCategory { get; set; } + /// + /// Name of the iracing session + /// + [DataMember] + public string SessionName { get; set; } = string.Empty; + /// + /// Start time of the iracing session (timezone??) + /// + [DataMember] + public DateTime? StartTime { get; set; } + /// + /// End time of the iracing session (timezone??) + /// + [DataMember] + public DateTime? EndTime { get; set; } + /// + /// Corners per lap on the selected track configuration + /// + [DataMember] + public int CornersPerLap { get; set; } + /// + /// Distance per lap on the selected track configuration + /// + [DataMember] + public double KmDistPerLap { get; set; } + /// + /// Maximum number of weeks in the iracing session + /// + [DataMember] + public int MaxWeeks { get; set; } + /// + /// SOF of the field in this event + /// + [DataMember] + public int EventStrengthOfField { get; set; } + /// + /// Average number of laps in this event + /// + [DataMember] + public long EventAverageLap { get; set; } + /// + /// Number of laps completed in this event + /// + [DataMember] + public int EventLapsComplete { get; set; } + /// + /// Number of cautions in this event + /// + [DataMember] + public int NumCautions { get; set; } + /// + /// Number of laps under caution in this event + /// + [DataMember] + public int NumCautionLaps { get; set; } + /// + /// Number of lead changes in this event + /// + [DataMember] + public int NumLeadChanges { get; set; } + /// + /// Time of day setting in the iracing session + /// + [DataMember] + public int TimeOfDay { get; set; } + /// + /// Damage model setting in the iracing session + /// + [DataMember] + public int DamageModel { get; set; } + /// + /// Track id of the selected track configuration + /// + [DataMember] + public int IRTrackId { get; set; } + /// + /// Name of the selected track (without config) + /// + [DataMember] + public string TrackName { get; set; } = string.Empty; + /// + /// Name of the selected track configuration + /// + [DataMember] + public string ConfigName { get; set; } = string.Empty; + /// + /// Category id of the selected track configuration + /// + [DataMember] + public int TrackCategoryId { get; set; } + /// + /// Category name of the selected track configuration + /// + [DataMember] + public string Category { get; set; } = string.Empty; + /// + /// Weather type in the iracing session + /// + [DataMember] + public int WeatherType { get; set; } + /// + /// Selected temp unit + /// + [DataMember] + public int TempUnits { get; set; } + /// + /// Environment temperate in the iracing session + /// + [DataMember] + public int TempValue { get; set; } + /// + /// Relative humidity in the iracing session + /// + [DataMember] + public int RelHumidity { get; set; } + /// + /// Fog level in the iracing session + /// + [DataMember] + public int Fog { get; set; } + /// + /// Wind direction in the iracing session + /// + [DataMember] + public int WindDir { get; set; } + /// + /// Selected wind units + /// + [DataMember] + public int WindUnits { get; set; } + /// + /// Skies setting in the iracing session + /// + [DataMember] + public int Skies { get; set; } + /// + /// ??? + /// + [DataMember] + public int WeatherVarInitial { get; set; } + /// + /// ??? + /// + [DataMember] + public int WeatherVarOngoing { get; set; } + /// + /// Start time of the simulation in UTC + /// + [DataMember] + public DateTime? SimStartUtcTime { get; set; } + /// + /// UTC offset to local time + /// + [DataMember] + public long SimStartUtcOffset { get; set; } + /// + /// Leave marbles between session transition setting + /// + [DataMember] + public bool LeaveMarbles { get; set; } + /// + /// Setting for rubber in practice session + /// + [DataMember] + public int PracticeRubber { get; set; } + /// + /// Setting for rubber in qualy session + /// + [DataMember] + public int QualifyRubber { get; set; } + /// + /// Setting for rubber in warmub session + /// + [DataMember] + public int WarmupRubber { get; set; } + /// + /// Setting for rubber in race session + /// + [DataMember] + public int RaceRubber { get; set; } + /// + /// Compound setting in practice session + /// + [DataMember] + public int PracticeGripCompound { get; set; } + /// + /// Compound setting in qualy session + /// + [DataMember] + public int QualifyGripCompund { get; set; } + /// + /// Compound setting in warmup session + /// + [DataMember] + public int WarmupGripCompound { get; set; } + /// + /// Compound setting in race session + /// + [DataMember] + public int RaceGripCompound { get; set; } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Standings/StandingResultRowModel.cs b/src/iRLeagueApiCore.Common/Models/Standings/StandingResultRowModel.cs new file mode 100644 index 00000000..2c47d8a9 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Standings/StandingResultRowModel.cs @@ -0,0 +1,76 @@ +namespace iRLeagueApiCore.Common.Models; +public sealed class StandingResultRowModel +{ + /// + /// Id of the Event + /// + [DataMember] + public long EventId { get; set; } + /// + /// Date of event + /// + [DataMember] + public DateTime Date { get; set; } + /// + /// Posiion at start of race session (equal to qually result when using attached qualifying) + /// + [DataMember] + public double StartPosition { get; set; } + /// + /// Finish position in the race results (iracing penalties are applied - league penalties are not) + /// + [DataMember] + public double FinishPosition { get; set; } + /// + /// Number of completed laps in the main session (only includes laps from one session type e.g: race) + /// + [DataMember] + public double CompletedLaps { get; set; } + /// + /// Number of incidents in the session (only main session) + /// + [DataMember] + public double Incidents { get; set; } + /// + /// Driver status at the end of the race (checkered flag) + /// + [DataMember] + public int Status { get; set; } + /// + /// Irating before the event + /// + [DataMember] + public int Irating { get; set; } + /// + /// Irating at the start of the season + /// + [DataMember] + public int SeasonStartIrating { get; set; } + /// + /// Points gained from result in the race + /// + [DataMember] + public double RacePoints { get; set; } + /// + /// Points gained from bonus condition (will be added to race points) + /// + [DataMember] + public double BonusPoints { get; set; } + /// + /// Points deducted as penalty (Value is positive but points will be deducted from race points) + /// + [DataMember] + public double PenaltyPoints { get; set; } + /// + /// Total scored points -> sum of: (RacePoints + BonusPoints - PenaltyPoints) + /// + [DataMember] + public double TotalPoints { get; set; } + /// + /// Final position after all scoring rules and penalties are applied + /// + [DataMember] + public int FinalPosition { get; set; } + [DataMember] + public bool IsScored { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Standings/StandingRowModel.cs b/src/iRLeagueApiCore.Common/Models/Standings/StandingRowModel.cs new file mode 100644 index 00000000..f0f36f7a --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Standings/StandingRowModel.cs @@ -0,0 +1,92 @@ +namespace iRLeagueApiCore.Common.Models.Standings; + +[DataContract] +public class StandingRowModel +{ + [DataMember] + public long StandingRowId { get; set; } + [DataMember] + public string Firstname { get; set; } = string.Empty; + [DataMember] + public string Lastname { get; set; } = string.Empty; + [DataMember] + public string TeamName { get; set; } = string.Empty; + [DataMember] + public string TeamColor { get; set; } = string.Empty; + [DataMember] + public long? MemberId { get; set; } + [DataMember] + public long? TeamId { get; set; } + [DataMember] + public int Position { get; set; } + [DataMember] + public int LastPosition { get; set; } + [DataMember] + public int ClassId { get; set; } + [DataMember] + public string CarClass { get; set; } = string.Empty; + [DataMember] + public int RacePoints { get; set; } + [DataMember] + public int RacePointsChange { get; set; } + [DataMember] + public int PenaltyPoints { get; set; } + [DataMember] + public int PenaltyPointsChange { get; set; } + [DataMember] + public int TotalPoints { get; set; } + [DataMember] + public int TotalPointsChange { get; set; } + [DataMember] + public int Races { get; set; } + [DataMember] + public int RacesCounted { get; set; } + [DataMember] + public int RacesScored { get; set; } + [DataMember] + public int RacesInPoints { get; set; } + [DataMember] + public int DroppedResultCount { get; set; } + [DataMember] + public int ClubId { get; set; } + [DataMember] + public string ClubName { get; set; } = string.Empty; + [DataMember] + public int CompletedLaps { get; set; } + [DataMember] + public int CompletedLapsChange { get; set; } + [DataMember] + public int LeadLaps { get; set; } + [DataMember] + public int LeadLapsChange { get; set; } + [DataMember] + public int FastestLaps { get; set; } + [DataMember] + public int FastestLapsChange { get; set; } + [DataMember] + public int PolePositions { get; set; } + [DataMember] + public int PolePositionsChange { get; set; } + [DataMember] + public int Wins { get; set; } + [DataMember] + public int WinsChange { get; set; } + [DataMember] + public int Top3 { get; set; } + [DataMember] + public int Top5 { get; set; } + [DataMember] + public int Top10 { get; set; } + [DataMember] + public int Incidents { get; set; } + [DataMember] + public int IncidentsChange { get; set; } + [DataMember] + public int PositionChange { get; set; } + [DataMember] + public int StartIrating { get; set; } + [DataMember] + public int LastIrating { get; set; } + [DataMember] + public IEnumerable ResultRows { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Standings/StandingsModel.cs b/src/iRLeagueApiCore.Common/Models/Standings/StandingsModel.cs new file mode 100644 index 00000000..0403d445 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Standings/StandingsModel.cs @@ -0,0 +1,11 @@ +namespace iRLeagueApiCore.Common.Models.Standings; + +public class StandingsModel +{ + public long LeagueId { get; set; } + public long SeasonId { get; set; } + public long StandingId { get; set; } + public string Name { get; set; } = string.Empty; + public bool IsTeamStanding { get; set; } + public IEnumerable StandingRows { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Teams/PostTeamModel.cs b/src/iRLeagueApiCore.Common/Models/Teams/PostTeamModel.cs new file mode 100644 index 00000000..cf994198 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Teams/PostTeamModel.cs @@ -0,0 +1,18 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PostTeamModel +{ + [DataMember] + public string Name { get; set; } = string.Empty; + [DataMember] + public string Profile { get; set; } = string.Empty; + [DataMember] + public string TeamColor { get; set; } = string.Empty; + [DataMember] + public string TeamHomepage { get; set; } = string.Empty; + [DataMember] + public long? IRacingTeamId { get; set; } + [DataMember] + public ICollection Members { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Teams/PutTeamModel.cs b/src/iRLeagueApiCore.Common/Models/Teams/PutTeamModel.cs new file mode 100644 index 00000000..9274284d --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Teams/PutTeamModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public class PutTeamModel : PostTeamModel +{ +} diff --git a/src/iRLeagueApiCore.Common/Models/Teams/TeamInfoModel.cs b/src/iRLeagueApiCore.Common/Models/Teams/TeamInfoModel.cs new file mode 100644 index 00000000..c2e49194 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Teams/TeamInfoModel.cs @@ -0,0 +1,12 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class TeamInfoModel +{ + [DataMember] + public long TeamId { get; set; } + [DataMember] + public string Name { get; set; } = string.Empty; + [DataMember] + public string TeamColor { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Teams/TeamModel.cs b/src/iRLeagueApiCore.Common/Models/Teams/TeamModel.cs new file mode 100644 index 00000000..55257d03 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Teams/TeamModel.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Common.Models; + +[DataContract] +public sealed class TeamModel : PutTeamModel +{ + [DataMember] + public long TeamId { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Tracks/TrackConfigModel.cs b/src/iRLeagueApiCore.Common/Models/Tracks/TrackConfigModel.cs new file mode 100644 index 00000000..da6ad0fe --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Tracks/TrackConfigModel.cs @@ -0,0 +1,29 @@ +namespace iRLeagueApiCore.Common.Models.Tracks; + +[DataContract] +public class TrackConfigModel +{ + /// + /// Id of this configuration. The same as iracing track_id + /// + [DataMember] + public long TrackId { get; set; } + /// + /// Name of the track (or track group) + /// + [DataMember] + public string TrackName { get; set; } = string.Empty; + /// + /// Name of the specific track configuration + /// + [DataMember] + public string ConfigName { get; set; } = string.Empty; + [DataMember] + public int Turns { get; set; } + [DataMember] + public double Length { get; set; } + [DataMember] + public ConfigType Type { get; set; } + [DataMember] + public bool HasNightLighting { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Tracks/TrackGroupModel.cs b/src/iRLeagueApiCore.Common/Models/Tracks/TrackGroupModel.cs new file mode 100644 index 00000000..bf15df41 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Tracks/TrackGroupModel.cs @@ -0,0 +1,12 @@ +namespace iRLeagueApiCore.Common.Models.Tracks; + +[DataContract] +public class TrackGroupModel +{ + [DataMember] + public long TrackGroupId { get; set; } + [DataMember] + public string TrackName { get; set; } = string.Empty; + [DataMember] + public IEnumerable Configs { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/UserRoleModel.cs b/src/iRLeagueApiCore.Common/Models/UserRoleModel.cs new file mode 100644 index 00000000..fb918e22 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/UserRoleModel.cs @@ -0,0 +1,16 @@ +namespace iRLeagueApiCore.Common.Models; + +/// +/// Schema to use for permission control over a single role for a user +/// +public class UserRoleModel +{ + /// + /// Name of the user to change permission + /// + public string UserName { get; set; } = string.Empty; + /// + /// Name of the role to give/revoke + /// + public string RoleName { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Users/AdminUserModel.cs b/src/iRLeagueApiCore.Common/Models/Users/AdminUserModel.cs new file mode 100644 index 00000000..3bdb72bf --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Users/AdminUserModel.cs @@ -0,0 +1,12 @@ +namespace iRLeagueApiCore.Common.Models.Users; + +/// +/// User model that is only retrieved by admin functionality +/// Shows all roles the user is in +/// +[DataContract] +public class AdminUserModel : PrivateUserModel +{ + [DataMember] + public IEnumerable Roles { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Users/AuthorizeModel.cs b/src/iRLeagueApiCore.Common/Models/Users/AuthorizeModel.cs new file mode 100644 index 00000000..3e1dab3d --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Users/AuthorizeModel.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Common.Models.Users; +public sealed class AuthorizeModel +{ + public string IdToken { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Users/LeagueUserModel.cs b/src/iRLeagueApiCore.Common/Models/Users/LeagueUserModel.cs new file mode 100644 index 00000000..081c400f --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Users/LeagueUserModel.cs @@ -0,0 +1,13 @@ +namespace iRLeagueApiCore.Common.Models.Users; + +/// +/// Information about user and the current league roles +/// Can either be retreived by an admin or the user itself +/// +[DataContract] +public class LeagueUserModel : UserModel +{ + + [DataMember] + public IEnumerable LeagueRoles { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Common/Models/Users/LoginModel.cs b/src/iRLeagueApiCore.Common/Models/Users/LoginModel.cs new file mode 100644 index 00000000..3084a614 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Users/LoginModel.cs @@ -0,0 +1,18 @@ +namespace iRLeagueApiCore.Common.Models.Users; + +/// +/// Model containing user data used for login +/// +public class LoginModel +{ + /// + /// User name as registered + /// + [Required(ErrorMessage = "User Name is required")] + public string Username { get; set; } = string.Empty; + /// + /// User password + /// + [Required(ErrorMessage = "Password is required")] + public string Password { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Users/PrivateUserModel.cs b/src/iRLeagueApiCore.Common/Models/Users/PrivateUserModel.cs new file mode 100644 index 00000000..6f4f2443 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Users/PrivateUserModel.cs @@ -0,0 +1,13 @@ +namespace iRLeagueApiCore.Common.Models.Users; + +/// +/// User model including potentially personal details +/// +[DataContract] +public class PrivateUserModel : UserModel +{ + [DataMember] + public string Email { get; set; } = string.Empty; + [DataMember] + public bool HideFirstnameLastname { get; set; } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/Models/Users/PutUserModel.cs b/src/iRLeagueApiCore.Common/Models/Users/PutUserModel.cs new file mode 100644 index 00000000..a38523f6 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Users/PutUserModel.cs @@ -0,0 +1,14 @@ +namespace iRLeagueApiCore.Common.Models.Users; + +[DataContract] +public class PutUserModel +{ + [DataMember] + public string Firstname { get; set; } = string.Empty; + [DataMember] + public string Lastname { get; set; } = string.Empty; + [DataMember] + public string Email { get; set; } = string.Empty; + [DataMember] + public bool HideFirstnameLastname { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Models/Users/RegisterModel.cs b/src/iRLeagueApiCore.Common/Models/Users/RegisterModel.cs new file mode 100644 index 00000000..04a470d5 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Users/RegisterModel.cs @@ -0,0 +1,34 @@ +namespace iRLeagueApiCore.Common.Models.Users; + +/// +/// Model containing user data used for creating a new user +/// +public class RegisterModel +{ + /// + /// User name used for login later + /// + [Required(ErrorMessage = "User Name is required")] + public string Username { get; set; } = string.Empty; + /// + /// Firstname + /// + [Required(ErrorMessage = "Firstname is required")] + public string Firstname { get; set; } = string.Empty; + /// + /// Lastname + /// + [Required(ErrorMessage = "Lastname is required")] + public string Lastname { get; set; } = string.Empty; + /// + /// Valid email + /// + [EmailAddress] + [Required(ErrorMessage = "Email is required")] + public string Email { get; set; } = string.Empty; + /// + /// User password + /// + [Required(ErrorMessage = "Password is required")] + public string Password { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Users/RoleModel.cs b/src/iRLeagueApiCore.Common/Models/Users/RoleModel.cs new file mode 100644 index 00000000..8cb62779 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Users/RoleModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Models.Users; + +public class RoleModel +{ + public string RoleName { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Models/Users/UserModel.cs b/src/iRLeagueApiCore.Common/Models/Users/UserModel.cs new file mode 100644 index 00000000..f74f9d89 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Models/Users/UserModel.cs @@ -0,0 +1,17 @@ +namespace iRLeagueApiCore.Common.Models.Users; + +/// +/// User model containing basic user infos that can be viewed by everyone +/// +[DataContract] +public class UserModel +{ + [DataMember] + public string UserId { get; set; } = string.Empty; + [DataMember] + public string UserName { get; set; } = string.Empty; + [DataMember] + public string Firstname { get; set; } = string.Empty; + [DataMember] + public string Lastname { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Common/Responses/BadRequestResponse.cs b/src/iRLeagueApiCore.Common/Responses/BadRequestResponse.cs new file mode 100644 index 00000000..49e11f58 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Responses/BadRequestResponse.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.Common.Responses; + +public struct BadRequestResponse +{ + public string Status { get; set; } + public IEnumerable Errors { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Responses/UnauthorizedResponse.cs b/src/iRLeagueApiCore.Common/Responses/UnauthorizedResponse.cs new file mode 100644 index 00000000..589ea579 --- /dev/null +++ b/src/iRLeagueApiCore.Common/Responses/UnauthorizedResponse.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Common.Responses; +public struct UnauthorizedResponse +{ + public string Status { get; set; } + public IEnumerable Errors { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/Responses/ValidationError.cs b/src/iRLeagueApiCore.Common/Responses/ValidationError.cs new file mode 100644 index 00000000..988c05cc --- /dev/null +++ b/src/iRLeagueApiCore.Common/Responses/ValidationError.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Common.Responses; + +public struct ValidationError +{ + public string Property { get; set; } + public string Error { get; set; } + public object Value { get; set; } +} diff --git a/src/iRLeagueApiCore.Common/_GlobalUsings.cs b/src/iRLeagueApiCore.Common/_GlobalUsings.cs new file mode 100644 index 00000000..2212494b --- /dev/null +++ b/src/iRLeagueApiCore.Common/_GlobalUsings.cs @@ -0,0 +1,4 @@ +global using iRLeagueApiCore.Common.Enums; +global using System.ComponentModel.DataAnnotations; +global using System.Runtime.Serialization; +global using System.Text.Json.Serialization; \ No newline at end of file diff --git a/src/iRLeagueApiCore.Common/iRLeagueApiCore.Common.csproj b/src/iRLeagueApiCore.Common/iRLeagueApiCore.Common.csproj new file mode 100644 index 00000000..998b49f8 --- /dev/null +++ b/src/iRLeagueApiCore.Common/iRLeagueApiCore.Common.csproj @@ -0,0 +1,31 @@ + + + + + + true + + + + 1701;1702;1591 + + + + 1701;1702;1591 + + + + Library + net6.0 + iRLeagueApiCore.Common + 0.11.1 + Simon Schulze + Simon Schulze + enable + enable + This package contains shared objects for all members of the iRLeagueDatabase-iRLeagueApi stack + https://github.com/SSchulze1989/iRLeagueApiCore.Common + true + + + diff --git a/src/iRLeagueApiCore.Server/.config/dotnet-tools.json b/src/iRLeagueApiCore.Server/.config/dotnet-tools.json new file mode 100644 index 00000000..23f4f077 --- /dev/null +++ b/src/iRLeagueApiCore.Server/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "6.0.3", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Server/Authentication/ApplicationUser.cs b/src/iRLeagueApiCore.Server/Authentication/ApplicationUser.cs new file mode 100644 index 00000000..841563c7 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Authentication/ApplicationUser.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Authentication; + +public class ApplicationUser : IdentityUser +{ + public string? FullName { get; set; } + public bool HideFullName { get; set; } +} diff --git a/src/iRLeagueApiCore.Server/Authentication/Response.cs b/src/iRLeagueApiCore.Server/Authentication/Response.cs new file mode 100644 index 00000000..3ea6d023 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Authentication/Response.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.Server.Authentication; + +public sealed class Response +{ + public string Status { get; set; } = string.Empty; + public string Message { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Server/Authentication/UserDbContext.cs b/src/iRLeagueApiCore.Server/Authentication/UserDbContext.cs new file mode 100644 index 00000000..9a509430 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Authentication/UserDbContext.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; + +namespace iRLeagueApiCore.Server.Authentication; + +public sealed class UserDbContext : IdentityDbContext +{ + public UserDbContext(DbContextOptions options) : base(options) + { + + } + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.Entity() + .Property(x => x.Id) + .HasMaxLength(85); + + builder.Entity(entity => entity.Property(m => m.Id).HasMaxLength(85)); + builder.Entity(entity => entity.Property(m => m.NormalizedEmail).HasMaxLength(85)); + builder.Entity(entity => entity.Property(m => m.NormalizedUserName).HasMaxLength(85)); + + builder.Entity(entity => entity.Property(m => m.Id).HasMaxLength(85)); + builder.Entity(entity => entity.Property(m => m.NormalizedName).HasMaxLength(85)); + + builder.Entity>(entity => entity.Property(m => m.LoginProvider).HasMaxLength(85)); + builder.Entity>(entity => entity.Property(m => m.ProviderKey).HasMaxLength(85)); + builder.Entity>(entity => entity.Property(m => m.UserId).HasMaxLength(85)); + builder.Entity>(entity => entity.Property(m => m.UserId).HasMaxLength(85)); + + builder.Entity>(entity => entity.Property(m => m.RoleId).HasMaxLength(85)); + + builder.Entity>(entity => entity.Property(m => m.UserId).HasMaxLength(85)); + builder.Entity>(entity => entity.Property(m => m.LoginProvider).HasMaxLength(85)); + builder.Entity>(entity => entity.Property(m => m.Name).HasMaxLength(85)); + + builder.Entity>(entity => entity.Property(m => m.Id).HasMaxLength(85)); + builder.Entity>(entity => entity.Property(m => m.UserId).HasMaxLength(85)); + builder.Entity>(entity => entity.Property(m => m.Id).HasMaxLength(85)); + builder.Entity>(entity => entity.Property(m => m.RoleId).HasMaxLength(85)); + } +} diff --git a/src/iRLeagueApiCore.Server/Authentication/UserDbContextFactory.cs b/src/iRLeagueApiCore.Server/Authentication/UserDbContextFactory.cs new file mode 100644 index 00000000..bdc4c6d9 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Authentication/UserDbContextFactory.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Authentication; + +public sealed class UserDbContextFactory : IDbContextFactory +{ + private readonly IConfiguration _configuration; + + public UserDbContextFactory(IConfiguration configuration) + { + _configuration = configuration; + } + + public UserDbContext CreateDbContext() + { + var dbConnectionString = _configuration.GetConnectionString("UserDb"); + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseMySQL(dbConnectionString); + + var dbContext = new UserDbContext(optionsBuilder.Options); + dbContext.Database.EnsureCreated(); + return dbContext; + } +} diff --git a/src/iRLeagueApiCore.Server/Authentication/UserRoles.cs b/src/iRLeagueApiCore.Server/Authentication/UserRoles.cs new file mode 100644 index 00000000..59e00935 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Authentication/UserRoles.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.Server.Authentication; + +public static class UserRoles +{ + public const string Admin = "Admin"; + public const string User = "User"; +} diff --git a/src/iRLeagueApiCore.Server/Controllers/AdminController.cs b/src/iRLeagueApiCore.Server/Controllers/AdminController.cs new file mode 100644 index 00000000..4e4d8447 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/AdminController.cs @@ -0,0 +1,68 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Admin; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[RequireLeagueRole(LeagueRoles.Admin)] +[Route("{leagueName}/[controller]")] +public sealed class AdminController : LeagueApiController +{ + public AdminController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + /// + /// List the users with at least one role in the current league + /// + /// [Required] Name of the league + /// + /// + [HttpGet("ListUsers")] + public async Task>> ListUsers([FromRoute] string leagueName, CancellationToken cancellationToken = default) + { + try + { + var request = new ListUsersRequest(leagueName); + var getUsers = await mediator.Send(request, cancellationToken); + if (getUsers.Count() == 0) + { + return NotFound(); + } + return Ok(getUsers); + } + catch (ValidationException ex) + { + _logger.LogInformation("Bad request - errors: {ValidationErrors}", ex.Errors.Select(x => x.ErrorMessage)); + return ex.ToActionResult(); + } + } + + /// + /// Give a league role to a user + /// + /// Name of the league + /// RoleName of the role to give to the user named UserName + /// + /// Action result + [HttpPost("GiveRole")] + public async Task GiveRole([FromRoute] string leagueName, [FromBody] UserRoleModel userRole, CancellationToken cancellationToken = default) + { + try + { + _logger.LogInformation("Give league role {LeagueRole} to user {RoleUser} for {LeagueName} by {UserName}", + userRole.RoleName, userRole.UserName, leagueName, GetUsername()); + var request = new GiveRoleRequest(leagueName, userRole); + await mediator.Send(request, cancellationToken); + return OkMessage($"Role {userRole.RoleName} given to user {userRole.UserName}"); + } + catch (ValidationException ex) + { + _logger.LogInformation("Bad request - errors: {ValidationErrors}", ex.Errors.Select(x => x.ErrorMessage)); + return ex.ToActionResult(); + } + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/AdminPanel/PaymentsController.cs b/src/iRLeagueApiCore.Server/Controllers/AdminPanel/PaymentsController.cs new file mode 100644 index 00000000..5be874e1 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/AdminPanel/PaymentsController.cs @@ -0,0 +1,95 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.AdminPanel; +using iRLeagueApiCore.Server.Models.Payments; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers.AdminPanel; + +[ApiController] +[TypeFilter(typeof(DefaultExceptionFilterAttribute))] +[Authorize(Roles = "Admin")] +[Route("AdminPanel/[controller]")] +public class PaymentsController : ControllerBase +{ + private readonly IMediator mediator; + + public PaymentsController(IMediator mediator) + { + this.mediator = mediator; + } + + /// + /// Get payments from customers + /// + /// [Optional] If set: only show payments done for this league + /// + /// + [HttpGet] + public async Task>> Get([FromQuery] long? leagueId, CancellationToken cancellationToken) + { + var request = new GetAllPaymentsRequest(leagueId); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + /// + /// Get single payment by id + /// + /// Id of the payment + /// + /// + [HttpGet("{id:Guid}")] + public async Task> GetById([FromRoute] Guid id, CancellationToken cancellationToken) + { + var request = new GetPaymentRequest(id); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + /// + /// Create a new payment + /// + /// Id of league for which the payment will be set + /// Payment data + /// + /// + [HttpPost] + public async Task> Post([FromQuery] long leagueId, [FromBody] PostPaymentModel model, CancellationToken cancellationToken) + { + var request = new PostPaymentRequest(leagueId, model); + var result = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(GetById), new { id = result.Id }, result); + } + + /// + /// Deactivate a running payment (when Subscription is cancelled) + /// + /// Id of the payment + /// + /// + [HttpPost("{id:Guid}/Deactivate")] + public async Task> Deactivate([FromRoute] Guid id, CancellationToken cancellationToken) + { + var request = new DeactivatePaymentRequest(id); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + /// + /// Directly set the current league subscription status + /// + /// Id of the league + /// Status and expiration of subscription + /// + /// + [HttpPost("SetSubscription/{leagueId:long}")] + public async Task> SetSubscription([FromRoute] long leagueId, [FromBody] SetLeagueSubscriptionModel model, + CancellationToken cancellationToken) + { + var request = new SetLeagueSubscriptionRequest(leagueId, model); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/AuthenticateController.cs b/src/iRLeagueApiCore.Server/Controllers/AuthenticateController.cs new file mode 100644 index 00000000..8c81e039 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/AuthenticateController.cs @@ -0,0 +1,303 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Common.Responses; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Authentication; +using iRLeagueApiCore.Server.Handlers.Users; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc; +using Microsoft.IdentityModel.Tokens; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using System.Text; +using System.Text.Json; + +namespace iRLeagueApiCore.Server.Controllers; + +[ApiController] +[TypeFilter(typeof(DefaultExceptionFilterAttribute))] +[Route("[controller]")] +public sealed class AuthenticateController : Controller +{ + private readonly ILogger _logger; + private readonly UserManager userManager; + private readonly RoleManager roleManager; + private readonly IMediator mediator; + private readonly IConfiguration _configuration; + + public AuthenticateController( + ILogger logger, + UserManager userManager, + RoleManager roleManager, + IMediator mediator, + IConfiguration configuration) + { + _logger = logger; + this.userManager = userManager; + this.roleManager = roleManager; + this.mediator = mediator; + _configuration = configuration; + } + + [HttpPost] + [Route("login")] + public async Task Login([FromBody] LoginModel model) + { + _logger.LogInformation("Log in requested with {UserName}", model.Username); + var userAgent = Request.Headers["User-Agent"].ToString(); + + var user = await userManager.FindByNameAsync(model.Username); + if (user != null && await userManager.CheckPasswordAsync(user, model.Password)) + { + if (user.EmailConfirmed == false) + { + return Unauthorized(new UnauthorizedResponse() { + Status = "MailConfirm", + Errors = new object[] { "Missing email confirmation" }, + }); + } + + var idToken = await CreateIdToken(user, userAgent); + if (idToken is null) + { + return Unauthorized(new UnauthorizedResponse() + { + Status = "Login failed", + Errors = new object[] { "Could not generate id token" }, + }); + } + var accessToken = await CreateAccessTokenAsync(user); + if (accessToken is null) + { + return Unauthorized(new UnauthorizedResponse() + { + Status = "Login failed", + Errors = new object[] { "Could not generate access token" }, + }); + } + + _logger.LogInformation("User {UserName} logged in until {ValidTo}", user.UserName, idToken.ValidTo); + var tokenHandler = new JwtSecurityTokenHandler(); + return Ok(new + { + idToken = tokenHandler.WriteToken(idToken), + accessToken = tokenHandler.WriteToken(accessToken), + expiration = idToken.ValidTo + }); + } + + if (user == null) + { + _logger.LogInformation("User {UserName} not found in user database", model.Username); + } + else + { + _logger.LogInformation("User {UserName} credentials do not match", model.Username); + } + + return Unauthorized(new UnauthorizedResponse() + { + Status = "Wrong username or password", + Errors = Array.Empty(), + }); + } + + [HttpPost] + [Route("authorize")] + public async Task Authorize([FromBody] AuthorizeModel model) + { + _logger.LogInformation("Requesting access by idToken"); + + // decrypt token + var tokenHandler = new JwtSecurityTokenHandler(); + var validationParameters = new TokenValidationParameters() + { + ValidateIssuer = true, + ValidateAudience = true, + ValidAudience = _configuration["JWT:ValidAudience"], + ValidIssuer = _configuration["JWT:ValidIssuer"], + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["JWT:Secret"])) + }; + + try + { + var principal = tokenHandler.ValidateToken(model.IdToken, validationParameters, out SecurityToken validatedToken); + var jwtToken = (JwtSecurityToken)validatedToken; + var loginKey = jwtToken.Claims.FirstOrDefault(x => x.Type == "idKey")?.Value; + if (loginKey is null) + { + return Unauthorized(); + } + var user = await userManager.FindByLoginAsync("iRLeagueApiCore", loginKey); + if (user is null) + { + return Unauthorized(); + } + + var accessToken = await CreateAccessTokenAsync(user); + if (accessToken is null) + { + return Unauthorized(); + } + + _logger.LogInformation("User {UserName} granted access until {ValidTo}", user.UserName, accessToken.ValidTo); + return Ok(new + { + accessToken = tokenHandler.WriteToken(accessToken), + expiration = accessToken.ValidTo + }); + } + catch (SecurityTokenValidationException) + { + _logger.LogWarning("Invalid token provided"); + return Unauthorized(); + } + catch (Exception ex) when (ex is ArgumentException || ex is SecurityTokenException || ex is InvalidCastException) + { + return Unauthorized(); + } + } + + [HttpPost] + [Route("register")] + public async Task Register([FromBody] RegisterModel model, [FromQuery] string? linkTemplate = null) + { + if (string.IsNullOrWhiteSpace(linkTemplate)) + { + var baseUri = $"https://{Request.Host.Value}"; + linkTemplate = $$"""{{baseUri}}/users/{userId}/confirm/{token}"""; + } + var request = new RegisterUserRequest(model, linkTemplate); + var status = await mediator.Send(request); + if (status.result.Succeeded) + { + return CreatedAtAction(nameof(UsersController.GetUser), "Users", new { id = status.user.UserId }, status.user); + } + return StatusCode(StatusCodes.Status500InternalServerError, new Response { Status = "Error", Message = "User creation failed! Please check user details and try again." }); + } + + [HttpPost] + [AllowAnonymous] + [Route("ResetPassword")] + [ApiExplorerSettings(IgnoreApi = true)] + public async Task ResetPassword([FromBody] PasswordResetModel model, CancellationToken cancellationToken = default) + { + _logger.LogInformation("[{Method}] Generate password reset token for user {User} by {UserName}", "Post", model.UserName, User.Identity?.Name); + var request = new PasswordResetRequest(model); + await mediator.Send(request, cancellationToken); + return NoContent(); + } + + [HttpPost] + [Route("SetPassword/{userId}")] + [TypeFilter(typeof(DefaultExceptionFilterAttribute))] + [AllowAnonymous] + [ApiExplorerSettings(IgnoreApi = true)] + public async Task ResetPasswordWithToken([FromRoute] string userId, [FromBody] SetPasswordTokenModel model, CancellationToken cancellationToken = default) + { + _logger.LogInformation("[{Method}] Set Password with reset token for user {UserId}", "Post", userId); + var request = new SetPasswordWithTokenRequest(userId, model); + var result = await mediator.Send(request, cancellationToken); + if (result) + { + _logger.LogInformation("Password was set successfully"); + return NoContent(); + } + _logger.LogInformation("Set password failed"); + return BadRequest(); + } + + private async Task CreateIdToken(ApplicationUser user, string userAgent) + { + // prune expired logins + var logins = await userManager.GetLoginsAsync(user); + foreach(var login in logins) + { + var (id, exp) = DecodeLoginKey(login.ProviderKey); + if (exp <= DateTime.Now) + { + await userManager.RemoveLoginAsync(user, "iRLeagueApiCore", login.ProviderKey); + } + } + + var expiration = DateTime.Now.AddMonths(3); + var loginKey = GenerateLoginkey(expiration); + var loginInfo = new UserLoginInfo("iRLeagueApiCore", loginKey, "iRLeagueApiCore"); + var result = await userManager.AddLoginAsync(user, loginInfo); + if (result.Succeeded == false) + { + return null; + } + var idClaims = new List() + { + new Claim("idKey", loginKey), + }; + + var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["JWT:Secret"])); + + var token = new JwtSecurityToken( + issuer: _configuration["JWT:ValidIssuer"], + audience: _configuration["JWT:ValidAudience"], + expires: expiration, + claims: idClaims, + signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256) + ); + + return token; + } + + private static string GenerateLoginkey(DateTime expiration) + { + // encode generated id and browser information as base64 string + var guid = Guid.NewGuid(); + var keyString = string.Join('&', guid, expiration.ToString()); + var bytes = Encoding.UTF8.GetBytes(keyString); + return Convert.ToBase64String(bytes); + } + + private (string id, DateTime expiration) DecodeLoginKey(string loginKey) + { + var bytes = Convert.FromBase64String(loginKey); + var keyString = Encoding.UTF8.GetString(bytes); + + var parts = keyString.Split('&'); + var id = parts.ElementAtOrDefault(0) ?? throw new InvalidOperationException(); + if (DateTime.TryParse(parts.ElementAtOrDefault(1), out DateTime expiration) == false) + { + throw new InvalidOperationException(); + } + return (id, expiration); + } + + private async Task CreateAccessTokenAsync(ApplicationUser user) + { + var userRoles = await userManager.GetRolesAsync(user); + + var authClaims = new List + { + new Claim(ClaimTypes.Name, user.UserName), + new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), + }; + + foreach (var userRole in userRoles) + { + authClaims.Add(new Claim(ClaimTypes.Role, userRole)); + } + + authClaims.Add(new Claim(ClaimTypes.NameIdentifier, user.Id.ToString())); + + var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["JWT:Secret"])); + + var token = new JwtSecurityToken( + issuer: _configuration["JWT:ValidIssuer"], + audience: _configuration["JWT:ValidAudience"], + expires: DateTime.Now.AddMinutes(10), + claims: authClaims, + signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256) + ); + + return token; + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/CarsController.cs b/src/iRLeagueApiCore.Server/Controllers/CarsController.cs new file mode 100644 index 00000000..ebe574c3 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/CarsController.cs @@ -0,0 +1,32 @@ +using iRLeagueApiCore.Common.Models.Results; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Cars; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +/// +/// Endpoint for retrieving information about cars +/// +[Authorize] +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[Route("{leagueName}/[controller]")] +public class CarsController : LeagueApiController +{ + public CarsController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [Route("/{leagueName}/Events/{eventId:long}/[controller]")] + [AllowAnonymous] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long eventId, + CancellationToken cancellationToken) + { + var request = new GetCarsFromEventRequest(eventId); + var getMembers = await mediator.Send(request, cancellationToken); + return Ok(getMembers); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/ChampSeasonsController.cs b/src/iRLeagueApiCore.Server/Controllers/ChampSeasonsController.cs new file mode 100644 index 00000000..6ab326c4 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/ChampSeasonsController.cs @@ -0,0 +1,150 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Championships; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[Authorize] +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole] +[Route("{leagueName}/[controller]")] +public class ChampSeasonsController : LeagueApiController +{ + public ChampSeasonsController(ILogger logger, IMediator mediator) : + base(logger, mediator) + { + } + + /// + /// Get single champSeason by id + /// + /// + /// + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken = default) + { + var request = new GetChampSeasonRequest(id); + var getChampSeason = await mediator.Send(request, cancellationToken); + return Ok(getChampSeason); + } + + /// + /// Get all champSeasons from a championship + /// + /// + /// + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Championships/{id:long}/ChampSeasons")] + public async Task>> GetFromChampionship([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken = default) + { + var request = new GetChampSeasonsFromChampionshipRequest(id); + var getChampSeasons = await mediator.Send(request, cancellationToken); + return Ok(getChampSeasons); + } + + /// + /// Get all champSeasons from a season + /// + /// + /// + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Seasons/{id:long}/ChampSeasons")] + public async Task>> GetFromSeason([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken = default) + { + var request = new GetChampSeasonsFromSeasonRequest(id); + var getChampSeasons = await mediator.Send(request, cancellationToken); + return Ok(getChampSeasons); + } + + /// + /// Get a single champseason from a season and championship + /// + /// + /// + /// + /// + /// + [HttpGet] + [Route("/{leagueName}/Seasons/{seasonId:long}/Championships/{championshipId:long}")] + public async Task> GetFromSeasonAndChampionship([FromRoute] string leagueName, [FromRoute] long championshipId, + [FromRoute] long seasonId, CancellationToken cancellationToken = default) + { + var request = new GetChampSeasonFromSeasonChampionshipRequest(seasonId, championshipId); + var getChampSeason = await mediator.Send(request, cancellationToken); + return Ok(getChampSeason); + } + + /// + /// Post a new champSeason for a championship to the selected season + /// + /// + /// + /// + /// + /// + /// + [HttpPost] + [Route("/{leagueName}/Seasons/{seasonId:long}/Championships/{championshipId:long}")] + public async Task> Post([FromRoute] string leagueName, [FromRoute] long championshipId, [FromRoute] long seasonId, + [FromBody] PostChampSeasonModel postChampSeason, CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostChampSeasonRequest(championshipId, seasonId, leagueUser, postChampSeason); + var getChampSeason = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getChampSeason.ChampSeasonId }, getChampSeason); + } + + /// + /// Update a single champSeason + /// + /// + /// + /// + /// + /// + [HttpPut] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + [Route("{id:long}")] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, + [FromBody] PutChampSeasonModel putChampSeason, CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutChampSeasonRequest(id, leagueUser, putChampSeason); + var getChampSeason = await mediator.Send(request, cancellationToken); + return Ok(getChampSeason); + } + + /// + /// Delete a champSeason permanently + /// + /// + /// + /// + /// + [HttpDelete] + [RequireLeagueRole(LeagueRoles.Admin)] + [Route("{id:long}")] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, CancellationToken cancellationToken = default) + { + var request = new DeleteChampSeasonRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/ChampionshipsController.cs b/src/iRLeagueApiCore.Server/Controllers/ChampionshipsController.cs new file mode 100644 index 00000000..f2c097e5 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/ChampionshipsController.cs @@ -0,0 +1,113 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Championships; +using iRLeagueApiCore.Server.Handlers.Events; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[Authorize] +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole] +[Route("{leagueName}/[controller]")] +public class ChampionshipsController : LeagueApiController +{ + public ChampionshipsController(ILogger logger, IMediator mediator) : + base(logger, mediator) + { + } + + /// + /// Get single championship by id + /// + /// + /// + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken = default) + { + var request = new GetChampionshipRequest(id); + var getChampionship = await mediator.Send(request, cancellationToken); + return Ok(getChampionship); + } + + /// + /// Get all championships from a league + /// + /// + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("")] + public async Task>> GetFromLeague([FromRoute] string leagueName, + CancellationToken cancellationToken = default) + { + var request = new GetChampionshipsFromLeagueRequest(); + var getChampionships = await mediator.Send(request, cancellationToken); + return Ok(getChampionships); + } + + /// + /// Post a new championship + /// + /// + /// + /// + /// + [HttpPost] + [Route("")] + public async Task> Post([FromRoute] string leagueName, [FromBody] PostChampionshipModel postChampionship, + CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostChampionshipRequest(leagueUser, postChampionship); + var getChampionship = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getChampionship.ChampionshipId }, getChampionship); + } + + /// + /// Update a single championship + /// + /// + /// + /// + /// + /// + [HttpPut] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + [Route("{id:long}")] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, + [FromBody] PutChampionshipModel putChampionship, CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutChampionshipRequest(id, leagueUser, putChampionship); + var getChampionship = await mediator.Send(request, cancellationToken); + return Ok(getChampionship); + } + + /// + /// Delete a championship permanently + /// + /// + /// + /// + /// + [HttpDelete] + [RequireLeagueRole(LeagueRoles.Admin)] + [Route("{id:long}")] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken = default) + { + var request = new DeleteChampionshipRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/EventsController.cs b/src/iRLeagueApiCore.Server/Controllers/EventsController.cs new file mode 100644 index 00000000..1a864ee4 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/EventsController.cs @@ -0,0 +1,91 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Events; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +/// +/// Endpoint for managing session entries +/// +[Authorize] +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole] +[Route("{leagueName}/[controller]")] +public sealed class EventsController : LeagueApiController +{ + public EventsController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [AllowAnonymous] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, [FromQuery] bool includeDetails = false, + CancellationToken cancellationToken = default) + { + var request = new GetEventRequest(id, includeDetails); + var getEvent = await mediator.Send(request, cancellationToken); + return Ok(getEvent); + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Schedules/{scheduleId:long}/Events")] + public async Task>> GetFromSchedule([FromRoute] string leagueName, [FromRoute] long scheduleId, [FromQuery] bool includeDetails = false, + CancellationToken cancellationToken = default) + { + var request = new GetEventsFromScheduleRequest(scheduleId, includeDetails); + var getEvents = await mediator.Send(request, cancellationToken); + return Ok(getEvents); + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Seasons/{seasonId:long}/Events")] + public async Task>> GetFromSeason([FromRoute] string leagueName, + [FromRoute] long seasonId, [FromQuery] bool includeDetails = false, CancellationToken cancellationToken = default) + { + var request = new GetEventsFromSeasonRequest(seasonId, includeDetails); + var getSessions = await mediator.Send(request, cancellationToken); + return Ok(getSessions); + } + + [HttpPost] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + [Route("/{leagueName}/Schedules/{scheduleId:long}/Events")] + public async Task> PostToSchedule([FromRoute] string leagueName, + [FromRoute] long scheduleId, [FromBody] PostEventModel postEvent, CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostEventToScheduleRequest(scheduleId, leagueUser, postEvent); + var getEvent = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getEvent.Id }, getEvent); + } + + [HttpPut] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + [Route("{id:long}")] + public async Task> Put([FromRoute] string leagueName, + [FromRoute] long id, [FromBody] PutEventModel putEvent, CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutEventRequest(id, leagueUser, putEvent); + var getEvent = await mediator.Send(request, cancellationToken); + return Ok(getEvent); + } + + [HttpDelete] + [RequireLeagueRole(LeagueRoles.Admin)] + [Route("{id:long}")] + public async Task Delete([FromRoute] string leagueName, + [FromRoute] long id, CancellationToken cancellationToken = default) + { + var request = new DeleteEventRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/Extensions.cs b/src/iRLeagueApiCore.Server/Controllers/Extensions.cs new file mode 100644 index 00000000..c7b50228 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/Extensions.cs @@ -0,0 +1,22 @@ +using iRLeagueApiCore.Common.Responses; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +public static class Extensions +{ + public static ActionResult ToActionResult(this ValidationException ex) + { + var response = new BadRequestResponse() + { + Status = "Bad request", + Errors = ex.Errors.Select(error => new ValidationError() + { + Property = error.PropertyName, + Error = error.ErrorMessage, + Value = error.AttemptedValue + }) + }; + return new BadRequestObjectResult(response); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/LeagueApiController.cs b/src/iRLeagueApiCore.Server/Controllers/LeagueApiController.cs new file mode 100644 index 00000000..7af08f02 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/LeagueApiController.cs @@ -0,0 +1,115 @@ +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Mvc; +using System.Security.Principal; + +namespace iRLeagueApiCore.Server.Controllers; + +[ApiController] +[TypeFilter(typeof(DefaultExceptionFilterAttribute))] +public abstract class LeagueApiController : Controller where TController : LeagueApiController +{ + protected readonly ILogger _logger; + protected readonly IMediator mediator; + + protected LeagueApiController(ILogger logger, IMediator mediator) + { + _logger = logger; + this.mediator = mediator; + } + + /// + /// Returns a generic "something went wrong" error message in case the error + /// should not be forwarded to the user + /// + protected ActionResult SomethingWentWrong() + { + return StatusCode(StatusCodes.Status500InternalServerError, new Response() + { + Status = "Error", + Message = "Something went wrong. Please try again to see if the error persists" + }); + } + + /// + /// Return a success request status with provided message + /// + protected ActionResult OkMessage(string message) + { + return new OkObjectResult(new Response() + { + Status = "Success", + Message = message + }); + } + + /// + /// Return a success request status with provided result and message + /// + protected ActionResult OkMessage(string result, string message) + { + return new OkObjectResult(new ResultResponse() + { + Status = "Success", + Result = result, + Message = message + }); + } + + /// + /// Return a bad request status code with provided status and messag in body + /// + protected ActionResult BadRequestMessage(string result, string message) + { + return new BadRequestObjectResult(new ResultResponse() + { + Status = "Bad Request", + Result = result, + Message = message + }); + } + + protected ActionResult NotFoundMessage(string message) + { + return new NotFoundObjectResult(new Response() + { + Status = "Not found", + Message = message + }); + } + + protected ActionResult WrongLeague() + { + return BadRequest(); + } + + protected ActionResult WrongLeague(string message) + { + return BadRequestMessage("Wrong league", message); + } + + protected bool HasAnyLeagueRole(IPrincipal user, string leagueName) + { + foreach (var role in LeagueRoles.RolesAvailable) + { + var leagueRole = $"{leagueName.ToLower()}:{role}"; + if (user.IsInRole(leagueRole)) + { + return true; + } + } + return user.IsInRole(UserRoles.Admin); + } + + protected bool HasLeagueRole(IPrincipal user, string leagueName, string roleName) + { + var leagueRole = $"{leagueName.ToLower()}:{roleName}"; + return user.IsInRole(leagueRole) || user.IsInRole(UserRoles.Admin); + } + + protected string GetUsername() + { + return User.Identity?.Name ?? "Anonymous"; + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/LeaguesController.cs b/src/iRLeagueApiCore.Server/Controllers/LeaguesController.cs new file mode 100644 index 00000000..24c4f2d8 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/LeaguesController.cs @@ -0,0 +1,113 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Extensions; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Security.Claims; + +namespace iRLeagueApiCore.Server.Controllers; + +[Route("[controller]")] +public sealed class LeaguesController : LeagueApiController +{ + public LeaguesController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [AllowAnonymous] + [Route("")] + public async Task>> GetAll(CancellationToken cancellationToken = default) + { + var includeHidden = User.IsInRole("Admin"); + var owned = GetUserLeagues(User); + var request = new GetLeaguesRequest(owned, includeHidden); + var getLeagues = await mediator.Send(request, cancellationToken); + return Ok(getLeagues); + } + + [HttpGet] + [AllowAnonymous] + [Route("{leagueId:long}")] + public async Task> Get([FromRoute] long leagueId, CancellationToken cancellationToken = default) + { + var leagueUser = HttpContext.GetLeagueUser(); + var includeSubscriptionDetails = leagueUser.IsInRole(LeagueRoles.Admin, LeagueRoles.Organizer); + var request = new GetLeagueRequest(leagueId, includeSubscriptionDetails); + var getLeague = await mediator.Send(request, cancellationToken); + return Ok(getLeague); + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}")] + public async Task> GetByName([FromRoute] string leagueName, CancellationToken cancellationToken = default) + { + var leagueUser = HttpContext.GetLeagueUser(); + var includeSubscriptionDetails = leagueUser.IsInRole(LeagueRoles.Admin, LeagueRoles.Organizer); + var request = new GetLeagueByNameRequest(leagueName, includeSubscriptionDetails); + var getLeague = await mediator.Send(request, cancellationToken); + return Ok(getLeague); + } + + [HttpPost] + [Route("")] + [Authorize] + public async Task> Post([FromBody] PostLeagueModel postLeague, CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(string.Empty, User); + var request = new PostLeagueRequest(leagueUser, postLeague); + var getLeague = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueId = getLeague.Id }, getLeague); + } + + [HttpPut] + [Route("{leagueId:long}")] + [TypeFilter(typeof(LeagueAuthorizeAttribute))] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task> Put([FromRoute] long leagueId, [FromBody] PutLeagueModel putLeague, CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(string.Empty, User); + var request = new PutLeagueRequest(leagueId, leagueUser, putLeague); + var getLeague = await mediator.Send(request, cancellationToken); + return Ok(getLeague); + } + + [HttpDelete] + [Route("{leagueId:long}")] + [TypeFilter(typeof(LeagueAuthorizeAttribute))] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task Delete([FromRoute] long leagueId, CancellationToken cancellationToken = default) + { + var request = new DeleteLeagueRequest(leagueId); + await mediator.Send(request, cancellationToken); + return NoContent(); + } + + [HttpPost] + [Route("{leagueId:long}")] + [TypeFilter(typeof(LeagueAuthorizeAttribute))] + [RequireLeagueRole(LeagueRoles.Admin)] + public async Task Initialize([FromRoute] long leagueId, CancellationToken cancellationToken = default) + { + var request = new PostIntitializeLeagueRequest(leagueId); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + private static IEnumerable GetUserLeagues(ClaimsPrincipal user) + { + var userRoles = user.Claims.Where(x => x.Type == ClaimTypes.Role); + var leagueRoles = userRoles + .Select(x => x.Value.Split(LeagueRoles.RoleDelimiter)) + .Where(x => x.Length == 2) + .Select(x => new { League = x.ElementAt(0), Role = x.ElementAt(1) }); + var owned = leagueRoles + .Select(x => x.League) + .Distinct(); + return owned; + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/MembersController.cs b/src/iRLeagueApiCore.Server/Controllers/MembersController.cs new file mode 100644 index 00000000..e00bc972 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/MembersController.cs @@ -0,0 +1,41 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Members; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +/// +/// Endpoint for retrieving and managin member information +/// +[Authorize] +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[Route("{leagueName}/[controller]")] +public sealed class MembersController : LeagueApiController +{ + public MembersController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [AllowAnonymous] + public async Task>> GetFromLeague([FromRoute] string leagueName, CancellationToken cancellationToken) + { + var request = new GetMembersFromLeagueRequest(); + var getMembers = await mediator.Send(request, cancellationToken); + return Ok(getMembers); + } + + [HttpGet] + [Route("/{leagueName}/Events/{eventId:long}/[controller]")] + [AllowAnonymous] + public async Task>> Get([FromRoute] string leagueName, [FromRoute] long eventId, + CancellationToken cancellationToken) + { + var request = new GetMembersFromEventRequest(eventId); + var getMembers = await mediator.Send(request, cancellationToken); + return Ok(getMembers); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/PenaltiesController.cs b/src/iRLeagueApiCore.Server/Controllers/PenaltiesController.cs new file mode 100644 index 00000000..ecac2b19 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/PenaltiesController.cs @@ -0,0 +1,72 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Reviews; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Steward)] +[Route("{leagueName}/[controller]")] +public sealed class PenaltiesController : LeagueApiController +{ + public PenaltiesController(ILogger logger, IMediator mediator) + : base(logger, mediator) + { + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/ScoredSessionResults/{id:long}/[controller]")] + public async Task>> GetPenaltiesFromSessionResult([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new GetPenaltiesFromSessionResultRequest(id); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Results/{id:long}/[controller]")] + public async Task>> GetPenaltiesFromEventResult([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new GetPenaltiesFromEventResultRequest(id); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpPost] + [Route("/{leagueName}/ScoredSessionResults/{resultId:long}/Rows/{resultRowId:long}/[controller]")] + public async Task> PostPenaltyToResult([FromRoute] string leagueName, [FromRoute] long resultId, [FromRoute] long resultRowId, + [FromBody] PostPenaltyModel postPenalty, CancellationToken cancellationToken) + { + var request = new PostPenaltyToResultRequest(resultId, resultRowId, postPenalty); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpPut] + [Route("{id:long}")] + public async Task> PutPenalty([FromRoute] string leagueName, [FromRoute] long id, + [FromBody] PutPenaltyModel putPenalty, CancellationToken cancellationToken) + { + var request = new PutPenaltyRequest(id, putPenalty); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpDelete] + [Route("{id:long}")] + public async Task DeletePenalty([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new DeletePenaltyRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/PointRulesController.cs b/src/iRLeagueApiCore.Server/Controllers/PointRulesController.cs new file mode 100644 index 00000000..71b3ae90 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/PointRulesController.cs @@ -0,0 +1,64 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Scorings; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole] +[Route("{leagueName}/[controller]")] +public sealed class PointRulesController : LeagueApiController +{ + public PointRulesController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new GetPointRuleRequest(id); + var getPointRule = await mediator.Send(request, cancellationToken); + return Ok(getPointRule); + } + + [HttpPost] + [Route("")] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task> Post([FromRoute] string leagueName, PostPointRuleModel postPointRule, + CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostPointRuleRequest(leagueUser, postPointRule); + var getPointRule = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getPointRule.PointRuleId }, getPointRule); + } + + [HttpPut] + [Route("{id:long}")] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, + [FromBody] PutPointRuleModel putPointRule, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutPointRuleRequest(id, leagueUser, putPointRule); + var getPointRule = await mediator.Send(request, cancellationToken); + _logger.LogInformation("Return entry for pointRule {PointRuleId} from {LeagueName}", getPointRule.PointRuleId, leagueName); + return Ok(getPointRule); + } + + [HttpDelete] + [Route("{id:long}")] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new DeletePointRuleRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/ProtestsController.cs b/src/iRLeagueApiCore.Server/Controllers/ProtestsController.cs new file mode 100644 index 00000000..4457f480 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/ProtestsController.cs @@ -0,0 +1,54 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[Route("{leagueName}/[controller]")] +public class ProtestsController : LeagueApiController +{ + public ProtestsController(ILogger logger, IMediator mediator) : + base(logger, mediator) + { + } + + [HttpPost] + [AllowAnonymous] + [Route("/{leagueName}/Sessions/{sessionId:long}/[controller]")] + public async Task> Post([FromRoute] string leagueName, [FromRoute] long sessionId, PostProtestModel postReview, + CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostProtestToSessionRequest(sessionId, leagueUser, postReview); + var getProtest = await mediator.Send(request, cancellationToken); + return Created(string.Empty, getProtest); + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Events/{eventId:long}/Protests")] + public async Task>> GetFromEvent([FromRoute] string leagueName, [FromRoute] long eventId, + CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new GetProtestsFromEventRequest(leagueUser, eventId); + var getProtests = await mediator.Send(request, cancellationToken); + return Ok(getProtests); + } + + [HttpDelete] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Steward)] + [Route("{id:long}")] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new DeleteProtestRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/ResultConfigsController.cs b/src/iRLeagueApiCore.Server/Controllers/ResultConfigsController.cs new file mode 100644 index 00000000..656acd4d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/ResultConfigsController.cs @@ -0,0 +1,86 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole] +[Route("{leagueName}/[controller]")] +public sealed class ResultConfigsController : LeagueApiController +{ + public ResultConfigsController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [Route("")] + [AllowAnonymous] + public async Task>> GetAll([FromRoute] string leagueName, CancellationToken cancellationToken) + { + var request = new GetResultConfigsFromLeagueRequest(); + var getResultConfigs = await mediator.Send(request, cancellationToken); + return Ok(getResultConfigs); + } + + [HttpGet] + [Route("{id:long}")] + [AllowAnonymous] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new GetResultConfigRequest(id); + var getResultConfig = await mediator.Send(request, cancellationToken); + return Ok(getResultConfig); + } + + [HttpGet] + [Route("/{leagueName}/Seasons/{seasonId:long}/ResultConfigs")] + [AllowAnonymous] + public async Task> GetFromSeason([FromRoute] string leagueName, [FromRoute] long seasonId, + CancellationToken cancellationToken) + { + var request = new GetResultConfigsFromSeasonRequest(seasonId); + var getResultConfigs = await mediator.Send(request, cancellationToken); + return Ok(getResultConfigs); + } + + [HttpPost] + [Route("/{leagueName}/ChampSeasons/{champSeasonId:long}/ResultConfigs")] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task> Post([FromRoute] string leagueName, [FromRoute] long champSeasonId, + [FromBody] PostResultConfigModel postResultConfig, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostResultConfigToChampSeasonRequest(champSeasonId, leagueUser, postResultConfig); + var getResultConfig = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getResultConfig.ResultConfigId }, getResultConfig); + } + + [HttpPut] + [Route("{id:long}")] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, + [FromBody] PutResultConfigModel putResultConfig, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutResultConfigRequest(id, leagueUser, putResultConfig); + var getResultConfig = await mediator.Send(request, cancellationToken); + return Ok(getResultConfig); + } + + [HttpDelete] + [Route("{id:long}")] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new DeleteResultConfigRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/ResultsController.cs b/src/iRLeagueApiCore.Server/Controllers/ResultsController.cs new file mode 100644 index 00000000..b9e1939a --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/ResultsController.cs @@ -0,0 +1,160 @@ +using iRLeagueApiCore.Client.ResultsParsing; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Results; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[Route("/{leagueName}/[controller]")] +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[TypeFilter(typeof(CheckLeagueSubscriptionAttribute))] +[RequireLeagueRole] +public sealed class ResultsController : LeagueApiController +{ + public ResultsController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + /// + /// Get single result from specific resultId + /// + /// + /// + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new GetResultRequest(id); + var getResult = await mediator.Send(request, cancellationToken); + return Ok(getResult); + } + + [HttpGet] + [AllowAnonymous] + [Route("latest")] + public async Task>> GetLatest([FromRoute] string leagueName, CancellationToken cancellationToken = default) + { + var request = new GetLatestResultRequest(); + var getResult = await mediator.Send(request, cancellationToken); + return Ok(getResult); + } + + /// + /// Get all results from a season + /// + /// + /// + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Seasons/{seasonId:long}/[controller]")] + public async Task>> GetFromSeason([FromRoute] string leagueName, [FromRoute] long seasonId, + CancellationToken cancellationToken = default) + { + var request = new GetResultsFromSeasonRequest(seasonId); + var getResults = await mediator.Send(request, cancellationToken); + return Ok(getResults); + } + + /// + /// Get all results from a session + /// + /// + /// + /// + /// + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Events/{eventId:long}/[controller]")] + public async Task>> GetFromEvent([FromRoute] string leagueName, [FromRoute] long eventId, + CancellationToken cancellationToken = default) + { + var request = new GetResultsFromEventRequest(eventId); + var getResults = await mediator.Send(request, cancellationToken); + return Ok(getResults); + } + + [HttpDelete] + [Route("/{leagueName}/Events/{eventId:long}/[controller]")] + public async Task DeleteFromEvent([FromRoute] string leagueName, [FromRoute] long eventId, + CancellationToken cancellationToken = default) + { + var request = new DeleteResultRequest(eventId); + await mediator.Send(request, cancellationToken); + return NoContent(); + } + + /// + /// Upload a result json (must be exported from the iRacing GUI) + /// + /// + /// + /// complete json data exported from iRacing GUI + /// + /// + [HttpPost] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + //[RequireSubscription] + [Route("/{leagueName}/Events/{eventId:long}/[controller]/Upload")] + public async Task> UploadResult([FromRoute] string leagueName, [FromRoute] long eventId, + [FromBody] ParseSimSessionResult subsessionId, CancellationToken cancellationToken = default) + { + var request = new UploadResultRequest(eventId, subsessionId); + var success = await mediator.Send(request, cancellationToken); + if (success) + { + return Ok(true); + } + else + { + return BadRequest("Oops, something went wrong with the result upload!"); + } + } + + /// + /// Fetch a result from the iracing API and automatically update the associated event result + /// + /// + /// + /// complete json data exported from iRacing GUI + /// + /// + [HttpPost] + [AllowAnonymous] + //[RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + //[RequireSubscription] + [Route("/{leagueName}/Events/{eventId:long}/[controller]/Fetch/{subsessionId:int}")] + public async Task> FetchFromIracing([FromRoute] string leagueName, [FromRoute] long eventId, + [FromRoute] int subsessionId, CancellationToken cancellationToken = default) + { + var request = new FetchResultsFromIRacingAPIRequest(eventId, subsessionId); + var success = await mediator.Send(request, cancellationToken); + if (success) + { + return Ok(true); + } + else + { + return BadRequest("Oops, something went wrong with the result upload!"); + } + } + + [HttpPost] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + [Route("/{leagueName}/Events/{eventId:long}/[controller]/Calculate")] + public async Task> TriggerResultCalculation([FromRoute] string leagueName, [FromRoute] long eventId, + CancellationToken cancellationToken = default) + { + var request = new TriggerResultCalculationCommand(eventId); + await mediator.Send(request, cancellationToken); + return Ok(true); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/ReviewCommentsController.cs b/src/iRLeagueApiCore.Server/Controllers/ReviewCommentsController.cs new file mode 100644 index 00000000..ef8e7134 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/ReviewCommentsController.cs @@ -0,0 +1,68 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Steward)] +[Route("{leagueName}/[controller]")] +public sealed class ReviewCommentsController : LeagueApiController +{ + public ReviewCommentsController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new GetReviewCommentRequest(id); + var getReviewComment = await mediator.Send(request, cancellationToken); + return Ok(getReviewComment); + } + + /// + /// Post new Comment to an existing review + /// + /// + /// + /// + /// + /// + [HttpPost] + [Route("/{leagueName}/Reviews/{reviewId:long}/[controller]")] + public async Task> PostToReview([FromRoute] string leagueName, [FromRoute] long reviewId, + [FromBody] PostReviewCommentModel postComment, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostReviewCommentToReviewRequest(reviewId, leagueUser, postComment); + var getComment = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getComment.CommentId }, getComment); + } + + [HttpPut] + [Route("{id:long}")] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, + PutReviewCommentModel putReviewComment, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutReviewCommentRequest(id, leagueUser, putReviewComment); + var getReviewComment = await mediator.Send(request, cancellationToken); + return Ok(getReviewComment); + } + + [HttpDelete] + [Route("{id:long}")] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new DeleteReviewCommentRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/ReviewsController.cs b/src/iRLeagueApiCore.Server/Controllers/ReviewsController.cs new file mode 100644 index 00000000..504f36f4 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/ReviewsController.cs @@ -0,0 +1,103 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Steward)] +[Route("{leagueName}/[controller]")] +public sealed class ReviewsController : LeagueApiController +{ + public ReviewsController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + private static bool IncludeComments(LeagueUser user) + { + return user.IsInRole(LeagueRoles.Admin, LeagueRoles.Steward); + } + + [HttpGet] + [AllowAnonymous] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var includeComments = IncludeComments(new LeagueUser(leagueName, User)); + var request = new GetReviewRequest(id, includeComments); + var getReview = await mediator.Send(request, cancellationToken); + return Ok(getReview); + } + + [HttpPost] + [Route("/{leagueName}/Sessions/{sessionId:long}/[controller]")] + public async Task> Post([FromRoute] string leagueName, [FromRoute] long sessionId, + PostReviewModel postReview, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostReviewToSessionRequest(sessionId, leagueUser, postReview); + var getReview = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getReview.ReviewId }, getReview); + } + + [HttpPut] + [Route("{id:long}")] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, + PutReviewModel putReview, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutReviewRequest(id, leagueUser, putReview); + var getReview = await mediator.Send(request, cancellationToken); + return Ok(getReview); + } + + [HttpDelete] + [Route("{id:long}")] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new DeleteReviewRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Sessions/{sessionId:long}/[controller]")] + public async Task>> GetFromSession([FromRoute] string leagueName, [FromRoute] long sessionId, + CancellationToken cancellationToken) + { + var includeComments = IncludeComments(new LeagueUser(leagueName, User)); + var request = new GetReviewsFromSessionRequest(sessionId, includeComments); + var getReviews = await mediator.Send(request, cancellationToken); + return Ok(getReviews); + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Events/{eventId:long}/[controller]")] + public async Task>> GetFromEvent([FromRoute] string leagueName, [FromRoute] long eventId, + CancellationToken cancellationToken) + { + var includeComments = IncludeComments(new LeagueUser(leagueName, User)); + var request = new GetReviewsFromEventRequest(eventId, includeComments); + var getReviews = await mediator.Send(request, cancellationToken); + return Ok(getReviews); + } + + [HttpPost] + [Route("{id:long}/MoveToSession/{sessionId:long}")] + public async Task> MoveReviewToSession([FromRoute] string leagueName, [FromRoute] long id, + [FromRoute] long sessionId, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new MoveReviewToSessionRequest(sessionId, id, leagueUser); + var getReview = await mediator.Send(request, cancellationToken); + return Ok(getReview); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/SchedulesController.cs b/src/iRLeagueApiCore.Server/Controllers/SchedulesController.cs new file mode 100644 index 00000000..8a0e386b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/SchedulesController.cs @@ -0,0 +1,84 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Schedules; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole] +[Route("{leagueName}/[controller]")] +public sealed class SchedulesController : LeagueApiController +{ + public SchedulesController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [Route("")] + public async Task>> GetAll([FromRoute] string leagueName, CancellationToken cancellationToken = default) + { + var request = new GetSchedulesRequest(); + var getSchedules = await mediator.Send(request, cancellationToken); + return Ok(getSchedules); + } + + [HttpGet] + [AllowAnonymous] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken = default) + { + var request = new GetScheduleRequest(id); + var getSchedule = await mediator.Send(request, cancellationToken); + return Ok(getSchedule); + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Seasons/{seasonId:long}/[controller]")] + public async Task>> GetFromSeason([FromRoute] string leagueName, [FromRoute] long seasonId, + CancellationToken cancellationToken = default) + { + var request = new GetSchedulesFromSeasonRequest(seasonId); + var getSchedules = await mediator.Send(request, cancellationToken); + return Ok(getSchedules); + } + + [HttpPost] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + [Route("/{leagueName}/Seasons/{seasonId:long}/[controller]")] + public async Task> Post([FromRoute] string leagueName, [FromRoute] long seasonId, [FromBody] PostScheduleModel postSchedule, + CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostScheduleRequest(seasonId, leagueUser, postSchedule); + var getSchedule = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getSchedule.ScheduleId }, getSchedule); + } + + [HttpPut] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + [Route("{id:long}")] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, [FromBody] PutScheduleModel putSchedule, + CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutScheduleRequest(leagueUser, id, putSchedule); + var getSchedule = await mediator.Send(request, cancellationToken); + return Ok(getSchedule); + } + + [HttpDelete] + [RequireLeagueRole(LeagueRoles.Admin)] + [Route("{id:long}")] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, CancellationToken cancellationToken = default) + { + var request = new DeleteScheduleRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/ScoringsController.cs b/src/iRLeagueApiCore.Server/Controllers/ScoringsController.cs new file mode 100644 index 00000000..940a2eda --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/ScoringsController.cs @@ -0,0 +1,86 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Scorings; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole] +[Route("{leagueName}/[controller]")] +public sealed class ScoringsController : LeagueApiController +{ + public ScoringsController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + /// + /// Get all scorings from league + /// + /// + /// + /// + [Route("")] + [HttpGet] + public async Task>> Get([FromRoute] string leagueName, CancellationToken cancellationToken = default) + { + var request = new GetScoringsRequest(); + var getScorings = await mediator.Send(request, cancellationToken); + return Ok(getScorings); + } + + /// + /// Get scoring from league by Id + /// + /// + /// + /// + /// + [Route("{id:long}")] + [HttpGet] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, CancellationToken cancellationToken = default) + { + var request = new GetScoringRequest(id); + var getScoring = await mediator.Send(request, cancellationToken); + return Ok(getScoring); + } + + /// + /// Update existing scoring with Id + /// + /// + /// + /// + /// + /// + [Route("{id:long}")] + [HttpPut] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, [FromBody] PutScoringModel model, + CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutScoringRequest(id, leagueUser, model); + var getScoring = await mediator.Send(request, cancellationToken); + return Ok(getScoring); + } + + /// + /// Delete existing scoring with id + /// + /// + /// + /// + /// + [Route("{id:long}")] + [HttpDelete] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, CancellationToken cancellationToken = default) + { + var request = new DeleteScoringRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/SeasonsController.cs b/src/iRLeagueApiCore.Server/Controllers/SeasonsController.cs new file mode 100644 index 00000000..372d7a51 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/SeasonsController.cs @@ -0,0 +1,81 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Seasons; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole] +[Route("{leagueName}/[controller]")] +public sealed class SeasonsController : LeagueApiController +{ + public SeasonsController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [AllowAnonymous] + [Route("")] + public async Task>> GetAll([FromRoute] string leagueName, CancellationToken cancellationToken = default) + { + var request = new GetSeasonsRequest(); + var getSeasons = await mediator.Send(request, cancellationToken); + return Ok(getSeasons); + } + + [HttpGet] + [AllowAnonymous] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, CancellationToken cancellationToken = default) + { + var request = new GetSeasonRequest(id); + var getSeason = await mediator.Send(request, cancellationToken); + return Ok(getSeason); + } + + [HttpGet] + [AllowAnonymous] + [Route("Current")] + public async Task> GetCurrent([FromRoute] string leagueName, CancellationToken cancellationToken = default) + { + var request = new GetCurrentSeasonRequest(); + var getSeason = await mediator.Send(request, cancellationToken); + return Ok(getSeason); + } + + [HttpPost] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + [Route("")] + public async Task> Post([FromRoute] string leagueName, [FromBody] PostSeasonModel postSeason, CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostSeasonRequest(leagueUser, postSeason); + var getSeason = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getSeason.SeasonId }, getSeason); + } + + [HttpPut] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + [Route("{id:long}")] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, [FromBody] PutSeasonModel putSeason, CancellationToken cancellationToken = default) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutSeasonRequest(leagueUser, id, putSeason); + var getSeason = await mediator.Send(request, cancellationToken); + return Ok(getSeason); + } + + [HttpDelete] + [RequireLeagueRole(LeagueRoles.Admin)] + [Route("{id:long}")] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, CancellationToken cancellationToken = default) + { + var request = new DeleteSeasonRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/StandingsController.cs b/src/iRLeagueApiCore.Server/Controllers/StandingsController.cs new file mode 100644 index 00000000..32bf0de5 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/StandingsController.cs @@ -0,0 +1,41 @@ +using iRLeagueApiCore.Common.Models.Standings; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Standings; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[Route("/{leagueName}/[controller]")] +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole] +public sealed class StandingsController : LeagueApiController +{ + public StandingsController(ILogger logger, IMediator mediator) : + base(logger, mediator) + { + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Seasons/{seasonId:long}/[controller]")] + public async Task>> GetFromSeason([FromRoute] string leagueName, [FromRoute] long seasonId, + CancellationToken cancellationToken = default) + { + var request = new GetStandingsFromSeasonRequest(seasonId); + var getStandings = await mediator.Send(request, cancellationToken); + return Ok(getStandings); + } + + [HttpGet] + [AllowAnonymous] + [Route("/{leagueName}/Events/{eventId:long}/[controller]")] + public async Task>> GetFromEvent([FromRoute] string leagueName, [FromRoute] long eventId, + CancellationToken cancellationToken = default) + { + var request = new GetStandingsFromEventRequest(eventId); + var getStandings = await mediator.Send(request, cancellationToken); + return Ok(getStandings); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/TeamsController.cs b/src/iRLeagueApiCore.Server/Controllers/TeamsController.cs new file mode 100644 index 00000000..dc6c9d0b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/TeamsController.cs @@ -0,0 +1,73 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Teams; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[Authorize] +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[Route("{leagueName}/[controller]")] +public sealed class TeamsController : LeagueApiController +{ + public TeamsController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [Route("")] + public async Task>> GetAll([FromRoute] string leagueName, CancellationToken cancellationToken) + { + var request = new GetTeamsFromLeagueRequest(); + var getTeams = await mediator.Send(request, cancellationToken); + return Ok(getTeams); + } + + [HttpGet] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new GetTeamRequest(id); + var getTeam = await mediator.Send(request, cancellationToken); + return Ok(getTeam); + } + + [HttpPost] + [Route("")] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task> Post([FromRoute] string leagueName, + [FromBody] PostTeamModel postTeam, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PostTeamRequest(leagueUser, postTeam); + var getTeam = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getTeam.TeamId }, getTeam); + } + + [HttpPut] + [Route("{id:long}")] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, + [FromBody] PutTeamModel putTeam, CancellationToken cancellationToken) + { + var leagueUser = new LeagueUser(leagueName, User); + var request = new PutTeamRequest(id, leagueUser, putTeam); + var getTeam = await mediator.Send(request, cancellationToken); + return Ok(getTeam); + } + + [HttpDelete] + [Route("{id:long}")] + [RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Organizer)] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new DeleteTeamRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/TracksController.cs b/src/iRLeagueApiCore.Server/Controllers/TracksController.cs new file mode 100644 index 00000000..bd872b37 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/TracksController.cs @@ -0,0 +1,34 @@ +using iRLeagueApiCore.Common.Models.Tracks; +using iRLeagueApiCore.Server.Handlers.Tracks; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[Route("[controller]")] +public sealed class TracksController : LeagueApiController +{ + public TracksController(ILogger logger, IMediator mediator) : + base(logger, mediator) + { + } + + [HttpGet] + [Route("")] + public async Task>> Get(CancellationToken cancellationToken) + { + var request = new GetTracksRequest(); + var getTracks = await mediator.Send(request, cancellationToken); + return Ok(getTracks); + } + + [HttpPost("UpdateTracks")] + [Authorize(Roles = "Admin")] + public async Task ImportTracks([FromBody] IracingAuthModel authData, CancellationToken cancellationToken) + { + var request = new ImportTracksCommand(authData); + await mediator.Send(request, cancellationToken); + return Ok(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/UsersController.cs b/src/iRLeagueApiCore.Server/Controllers/UsersController.cs new file mode 100644 index 00000000..c8f96b2f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/UsersController.cs @@ -0,0 +1,152 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Extensions; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Users; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.WebUtilities; +using System.Security.Cryptography.Xml; +using System.Text; + +namespace iRLeagueApiCore.Server.Controllers; + +[Route("[controller]")] +public sealed class UsersController : LeagueApiController +{ + public UsersController(ILogger logger, IMediator mediator) : base(logger, mediator) + { + } + + [HttpGet] + [TypeFilter(typeof(LeagueAuthorizeAttribute))] + [RequireLeagueRole(LeagueRoles.Admin)] + [Route("/{leagueName}/[controller]")] + public async Task>> GetAllLeagueUsers([FromRoute] string leagueName, CancellationToken cancellationToken) + { + _logger.LogInformation("[{Method}] all users from {LeagueName} by {Username}", "Get", leagueName, User.Identity?.Name); + var request = new GetUserListRequest(leagueName); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpGet] + [TypeFilter(typeof(LeagueAuthorizeAttribute))] + [RequireLeagueRole] + [Route("/{leagueName}/[controller]/{id}")] + public async Task> GetLeagueUser([FromRoute] string leagueName, [FromRoute] string id, CancellationToken cancellationToken) + { + _logger.LogInformation("[{Method}] user {UserId} from {LeagueName} by {Username}", "Get", id, leagueName, User.Identity?.Name); + var request = new GetLeagueUserRequest(leagueName, id); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpGet] + [Authorize] + [Route("{id}")] + public async Task> GetUser([FromRoute] string id, CancellationToken cancellationToken = default) + { + _logger.LogInformation("[{Method}] user {UserId} by {Username}", "Get", id, User.Identity?.Name); + var currentUserId = User.GetUserId()!; + object result; + if (id == currentUserId) + { + // if the user requests its own info --> return private user data + var request = new GetPrivateUserRequest(id); + result = await mediator.Send(request, cancellationToken); + } + else + { + // else get public user data + var request = new GetUserRequest(id); + result = await mediator.Send(request, cancellationToken); + } + return Ok(result); + } + + [HttpPut] + [Authorize] + [Route("{id}")] + public async Task> PutUser([FromRoute] string id, PutUserModel putUser, CancellationToken cancellationToken) + { + _logger.LogInformation("[{Method}] user data for user {UserId} by {Username}", "Put", id, User.Identity?.Name); + var currentUserId = User.GetUserId(); + if (currentUserId != id) + { + // only the user (or manager admin) is allowed to change his own data + return Forbid(); + } + var request = new PutUserRequest(id, putUser); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpPost] + [Authorize] + [Route("Search")] + public async Task>> SearchByName([FromBody] SearchModel model, CancellationToken cancellationToken) + { + _logger.LogInformation("[{Method}] search for users with names {SearchKeys} by {Username}", "Post", + model.SearchKeys, User.Identity?.Name); + var request = new SearchUsersByNameRequest(model.SearchKeys.ToArray()); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpPost] + [TypeFilter(typeof(LeagueAuthorizeAttribute))] + [RequireLeagueRole(LeagueRoles.Admin)] + [Route("/{leagueName}/[controller]/{id}/AddRole")] + public async Task> AddUserRole([FromRoute] string leagueName, [FromRoute] string id, [FromBody] RoleModel role, + CancellationToken cancellationToken) + { + _logger.LogInformation("[{Method}] Add role {RoleName} to user {RoleUserId} from {LeagueName} by {UserName}", "Post", + role.RoleName, id, leagueName, User.Identity?.Name); + var request = new AddLeagueRoleRequest(leagueName, id, role.RoleName); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpPost] + [TypeFilter(typeof(LeagueAuthorizeAttribute))] + [RequireLeagueRole(LeagueRoles.Admin)] + [Route("/{leagueName}/[controller]/{id}/RemoveRole")] + public async Task> RemoveUserRole([FromRoute] string leagueName, [FromRoute] string id, [FromBody] RoleModel role, + CancellationToken cancellationToken) + { + _logger.LogInformation("[{Method}] Remove role {RoleName} to user {RoleUserId} from {LeagueName} by {UserName}", "Post", + role.RoleName, id, leagueName, User.Identity?.Name); + var request = new RemoveLeagueRoleRequest(leagueName, id, role.RoleName); + var result = await mediator.Send(request, cancellationToken); + return Ok(result); + } + + [HttpPost] + [Route("{userId}/confirm/{confirmationToken}")] + public async Task> ConfirmEmail([FromRoute] string userId, [FromRoute] string confirmationToken, CancellationToken cancellationToken = default) + { + var decodedToken = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(confirmationToken)); + var request = new ConfirmEmailRequest(userId, decodedToken); + var (success, _) = await mediator.Send(request, cancellationToken); + if (success) + { + return Ok(true); + } + return BadRequest(false); + } + + [HttpPost] + [Route("ResendConfirmation")] + public async Task ResendConfirmationEmail([FromBody] string email, [FromQuery] string? linkTemplate = null, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(linkTemplate)) + { + var baseUri = $"https://{Request.Host.Value}"; + linkTemplate = $$"""{{baseUri}}/users/{userId}/confirm/{token}"""; + } + var request = new SendConfirmationEmailRequest(email, linkTemplate); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Controllers/VoteCategoriesController.cs b/src/iRLeagueApiCore.Server/Controllers/VoteCategoriesController.cs new file mode 100644 index 00000000..f919e257 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Controllers/VoteCategoriesController.cs @@ -0,0 +1,72 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace iRLeagueApiCore.Server.Controllers; + +[TypeFilter(typeof(LeagueAuthorizeAttribute))] +[TypeFilter(typeof(SetTenantLeagueIdAttribute))] +[RequireLeagueRole(LeagueRoles.Admin, LeagueRoles.Steward)] +[Route("{leagueName}/[controller]")] +public sealed class VoteCategoriesController : LeagueApiController +{ + public VoteCategoriesController(ILogger logger, IMediator mediator) : + base(logger, mediator) + { + } + + [HttpGet] + [AllowAnonymous] + [Route("")] + public async Task>> GetAll([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new GetLeagueVoteCategoriesRequest(); + var getVoteCategories = await mediator.Send(request, cancellationToken); + return Ok(getVoteCategories); + } + + [HttpGet] + [AllowAnonymous] + [Route("{id:long}")] + public async Task> Get([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new GetVoteCategoryRequest(id); + var getVoteCategory = await mediator.Send(request, cancellationToken); + return Ok(getVoteCategory); + } + + [HttpPost] + [Route("")] + public async Task> Post([FromRoute] string leagueName, + [FromBody] PostVoteCategoryModel postVoteCategory, CancellationToken cancellationToken) + { + var request = new PostVoteCategoryRequest(postVoteCategory); + var getVoteCategory = await mediator.Send(request, cancellationToken); + return CreatedAtAction(nameof(Get), new { leagueName, id = getVoteCategory.Id }, getVoteCategory); + } + + [HttpPut] + [Route("{id:long}")] + public async Task> Put([FromRoute] string leagueName, [FromRoute] long id, + [FromBody] PutVoteCategoryModel putVoteCategory, CancellationToken cancellationToken) + { + var request = new PutVoteCategoryRequest(id, putVoteCategory); + var getVoteCategory = await mediator.Send(request, cancellationToken); + return Ok(getVoteCategory); + } + + [HttpDelete] + [Route("{id:long}")] + public async Task Delete([FromRoute] string leagueName, [FromRoute] long id, + CancellationToken cancellationToken) + { + var request = new DeleteVoteCategoryRequest(id); + await mediator.Send(request, cancellationToken); + return NoContent(); + } +} diff --git a/src/iRLeagueApiCore.Server/Exceptions/HandlerOperationException.cs b/src/iRLeagueApiCore.Server/Exceptions/HandlerOperationException.cs new file mode 100644 index 00000000..2423e459 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Exceptions/HandlerOperationException.cs @@ -0,0 +1,22 @@ +using System.Runtime.Serialization; + +namespace iRLeagueApiCore.Server.Exceptions; + +public sealed class HandlerOperationException : InvalidOperationException +{ + public HandlerOperationException() + { + } + + public HandlerOperationException(string message) : base(message) + { + } + + public HandlerOperationException(string message, Exception innerException) : base(message, innerException) + { + } + + private HandlerOperationException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } +} diff --git a/src/iRLeagueApiCore.Server/Exceptions/ResourceNotFoundException.cs b/src/iRLeagueApiCore.Server/Exceptions/ResourceNotFoundException.cs new file mode 100644 index 00000000..3583799c --- /dev/null +++ b/src/iRLeagueApiCore.Server/Exceptions/ResourceNotFoundException.cs @@ -0,0 +1,23 @@ +using System.Runtime.Serialization; + +namespace iRLeagueApiCore.Server.Exceptions; + +public sealed class ResourceNotFoundException : Exception +{ + public string ResourceName { get; } = string.Empty; + public ResourceNotFoundException() : this("Requested resource was not found") + { + } + + public ResourceNotFoundException(string message) : base(message) + { + } + + public ResourceNotFoundException(string message, Exception innerException) : base(message, innerException) + { + } + + private ResourceNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } +} diff --git a/src/iRLeagueApiCore.Server/Extensions/HttpContextExtensions.cs b/src/iRLeagueApiCore.Server/Extensions/HttpContextExtensions.cs new file mode 100644 index 00000000..97d3a1fe --- /dev/null +++ b/src/iRLeagueApiCore.Server/Extensions/HttpContextExtensions.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Extensions; + +internal static class HttpContextExtensions +{ + public static LeagueUser GetLeagueUser(this HttpContext context) + { + var leagueName = (string?)context.GetRouteValue("leagueName") ?? string.Empty; + return new LeagueUser(leagueName, context.User); + } +} diff --git a/src/iRLeagueApiCore.Server/Extensions/PrincipalExtensions.cs b/src/iRLeagueApiCore.Server/Extensions/PrincipalExtensions.cs new file mode 100644 index 00000000..6f657731 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Extensions/PrincipalExtensions.cs @@ -0,0 +1,11 @@ +using System.Security.Claims; + +namespace iRLeagueApiCore.Server.Extensions; + +public static class PrincipalExtensions +{ + public static string? GetUserId(this ClaimsPrincipal principal) + { + return principal.FindFirst(ClaimTypes.NameIdentifier)?.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Extensions/StringExtensions.cs b/src/iRLeagueApiCore.Server/Extensions/StringExtensions.cs new file mode 100644 index 00000000..dd2aa7c2 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Extensions/StringExtensions.cs @@ -0,0 +1,15 @@ +using System.Text.RegularExpressions; + +namespace iRLeagueApiCore.Server.Extensions; + +public static class StringExtensions +{ + public static string PadNumbers(this string input, int n = 10) + { + if (string.IsNullOrEmpty(input)) + { + return input; + } + return Regex.Replace(input, "[0-9]+", match => match.Value.PadLeft(n, '0')); + } +} diff --git a/src/iRLeagueApiCore.Server/Filters/CheckLeagueSubscriptionAttribute.cs b/src/iRLeagueApiCore.Server/Filters/CheckLeagueSubscriptionAttribute.cs new file mode 100644 index 00000000..0e421d2f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Filters/CheckLeagueSubscriptionAttribute.cs @@ -0,0 +1,98 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Responses; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Caching.Memory; +using System.Net; + +namespace iRLeagueApiCore.Server.Filters; + +internal sealed class CheckLeagueSubscriptionAttribute : ActionFilterAttribute +{ + private readonly LeagueDbContext dbContext; + private readonly IMemoryCache memoryCache; + + public CheckLeagueSubscriptionAttribute(LeagueDbContext dbContext, IMemoryCache memoryCache) + { + this.dbContext = dbContext; + this.memoryCache = memoryCache; + } + + public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) + { + if (context.RouteData.Values.TryGetValue("leagueName", out var leagueNameObject) == false) + { + throw new InvalidOperationException("Missing {leagueName} in action route"); + } + var leagueName = (string)leagueNameObject!; + var requireSubscription = context.ActionDescriptor.EndpointMetadata + .OfType() + .Any(); + if (requireSubscription == false) + { + await next(); + return; + } + var league = await GetLeagueByName(leagueName) + ?? throw new InvalidOperationException("League data could not be found for given name"); + if (CheckSubscriptionStatus(league) == false) + { + if (league.Subscription != SubscriptionStatus.Expired) + { + await SetLeagueExpired(league.Id); + } + context.Result = new StatusCodeResult((int)HttpStatusCode.PaymentRequired); + return; + } + await next(); + } + + private static bool CheckSubscriptionStatus(LeagueEntity league) + { + var subscriptionActive = league.Subscription switch + { + SubscriptionStatus.FreeTrial => league.Expires > DateTime.UtcNow, + SubscriptionStatus.PaidPlan => league.Expires > DateTime.UtcNow, + SubscriptionStatus.Lifetime => true, + _ => false, + }; + return subscriptionActive; + } + + private async Task SetLeagueExpired(long leagueId) + { + var league = await dbContext.Leagues + .FirstOrDefaultAsync(x => x.Id == leagueId) + ?? throw new InvalidOperationException("League data could not be found for given name"); + // Check subscription status again to prevent missing updates during valid cache period + var subscriptionActive = CheckSubscriptionStatus(league); + if (subscriptionActive == false) + { + league.Subscription = SubscriptionStatus.Expired; + await dbContext.SaveChangesAsync(); + memoryCache.Remove(CacheKeys.GetLeagueNameKey(league.Name)); + } + } + + private async Task GetLeagueByName(string leagueName) + { + // hit cache and try to get league information without asking database + if (memoryCache.TryGetValue(CacheKeys.GetLeagueNameKey(leagueName), out LeagueEntity cachedLeague)) + { + return cachedLeague; + } + // get league from database and store in cache + var league = await dbContext.Leagues + .AsNoTracking() + .SingleOrDefaultAsync(x => x.Name == leagueName); + if (league is not null) + { + var cacheEntryOptions = new MemoryCacheEntryOptions() + .SetAbsoluteExpiration(DateTime.UtcNow.AddSeconds(30)); + memoryCache.Set(CacheKeys.GetLeagueNameKey(leagueName), league, cacheEntryOptions); + } + return league; + } +} diff --git a/src/iRLeagueApiCore.Server/Filters/DefaultExceptionFilterAttribute.cs b/src/iRLeagueApiCore.Server/Filters/DefaultExceptionFilterAttribute.cs new file mode 100644 index 00000000..811dcc2a --- /dev/null +++ b/src/iRLeagueApiCore.Server/Filters/DefaultExceptionFilterAttribute.cs @@ -0,0 +1,47 @@ +using iRLeagueApiCore.Server.Controllers; +using iRLeagueApiCore.Server.Handlers.Authentication; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; + +namespace iRLeagueApiCore.Server.Filters; + +[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)] +public sealed class DefaultExceptionFilterAttribute : Attribute, IExceptionFilter +{ + private readonly ILogger _logger; + + public DefaultExceptionFilterAttribute(ILogger logger) + { + _logger = logger; + } + + public void OnException(ExceptionContext context) + { + context.Result = context.Exception switch + { + ValidationException ex => ValidationActionResult(ex), + ResourceNotFoundException ex => ResourceNotFoundActionResult(ex), + UnauthorizedAccessException ex => UnauthorizedActionResult(ex, context.HttpContext), + _ => context.Result + }; + } + + private IActionResult ValidationActionResult(ValidationException validationException) + { + _logger.LogInformation("Bad request - errors: {ValidationErrors}", + validationException.Errors.Select(x => x.ErrorMessage)); + return validationException.ToActionResult(); + } + + private IActionResult ResourceNotFoundActionResult(ResourceNotFoundException notFoundException) + { + _logger.LogInformation("Resource not found"); + return new NotFoundResult(); + } + + private IActionResult UnauthorizedActionResult(UnauthorizedAccessException unauthorizedAccess, HttpContext context) + { + _logger.LogInformation("Permission denied for {User}", context.User.Identity?.Name ?? "Anonymous"); + return new ForbidResult(); + } +} diff --git a/src/iRLeagueApiCore.Server/Filters/FromFilterAttribute.cs b/src/iRLeagueApiCore.Server/Filters/FromFilterAttribute.cs new file mode 100644 index 00000000..c7a66b2f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Filters/FromFilterAttribute.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Server.Filters; + +/// +/// Indicates, that an Action parameter will be filled by an applied Filter an should be ignored by OpenAPI doc generator +/// +public sealed class FromFilterAttribute : ParameterIgnoreAttribute +{ +} diff --git a/src/iRLeagueApiCore.Server/Filters/LeagueAuthorizeAttribute.cs b/src/iRLeagueApiCore.Server/Filters/LeagueAuthorizeAttribute.cs new file mode 100644 index 00000000..2357c847 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Filters/LeagueAuthorizeAttribute.cs @@ -0,0 +1,151 @@ +using iRLeagueApiCore.Common.Responses; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Serilog; +using System.Diagnostics; +using System.Security.Principal; + +namespace iRLeagueApiCore.Server.Filters; + +/// +/// Authorization filter to manage access to league resources bases on user roles specific to each league +/// The pattern for league roles is {leagueName}:{roleName} so for example an admin for testleague must be in the role: testleague:Admin +/// The decorated class or method must have {leagueName} as a route parameter. +/// +[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)] +public sealed class LeagueAuthorizeAttribute : ActionFilterAttribute +{ + private readonly ILogger _logger; + private readonly LeagueDbContext dbContext; + private readonly IDiagnosticContext diagnosticContext; + + public LeagueAuthorizeAttribute(ILogger logger, IDiagnosticContext diagnosticContext, LeagueDbContext dbContext) + { + _logger = logger; + this.diagnosticContext = diagnosticContext; + this.dbContext = dbContext; + } + + public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) + { + // infer league name from context + var leagueName = await GetLeagueNameFromContext(context); + if (string.IsNullOrEmpty(leagueName)) + { + _logger.LogError("Missing [leagueName] or [leagueId] parameter in action route"); + throw new InvalidOperationException("Missing [leagueName] or [leagueId] in action route"); + } + + // get user from httpcontext + var user = context.HttpContext.User; + var userName = (user.Identity != null && user.Identity.IsAuthenticated) ? user.Identity.Name : "Anonymous"; + var leagueUser = new LeagueUser(leagueName, user); + + // _logger.LogDebug("Authorizing request for {UserName} on {leagueName}", userName, leagueName); + + // check if specific league role required + var requireLeagueRoleAttribute = context.ActionDescriptor.EndpointMetadata + .OfType(); + var allowAnonymousAttribute = context.ActionDescriptor.EndpointMetadata + .OfType() + .FirstOrDefault(); + if (allowAnonymousAttribute != null || requireLeagueRoleAttribute.Any() == false) + { + // Allow public access + await AccessGranted(context, next); + return; + } + + if (user == null || user.Identity == null || user.Identity.IsAuthenticated == false) + { + _logger.LogInformation("Permission denied for Anonymous user on {LeagueName}. League is not public", leagueName); + context.Result = new UnauthorizedObjectResult(new UnauthorizedResponse() + { + Status = "Not logged in", + Errors = new object[] { "Not logged in to user account" }, + }); + return; + } + + var requiredRoles = requireLeagueRoleAttribute + .SelectMany(x => x.Roles) + .ToList(); + if (requiredRoles.Count > 0) + { + var hasRole = requiredRoles + .Any(x => HasLeagueRole(user, leagueName, x)); + + if (hasRole == false) + { + _logger.LogInformation("Permission denied for {User} on {LeagueName}. User is not in any required role {Roles}", + user.Identity.Name, leagueName, requiredRoles); + AccessDenied(context, next); + return; + } + } + else if (HasAnyLeagueRole(user, leagueName) == false) + { + _logger.LogInformation("Permission denied for {User} on {LeagueName}. User is not in any league role", user.Identity.Name, leagueName); + AccessDenied(context, next); + return; + } + + await AccessGranted(context, next); + } + + private static bool HasAnyLeagueRole(IPrincipal user, string leagueName) + { + foreach (var roleName in LeagueRoles.RolesAvailable) + { + var leagueRole = LeagueRoles.GetLeagueRoleName(leagueName, roleName); + if (leagueRole != null && user.IsInRole(leagueRole)) + { + return true; + } + } + return user.IsInRole(UserRoles.Admin); + } + + private static bool HasLeagueRole(IPrincipal user, string leagueName, string roleName) + { + var leagueRole = LeagueRoles.GetLeagueRoleName(leagueName, roleName); + if (leagueRole == null) + { + return false; + } + return user.IsInRole(leagueRole) || user.IsInRole(UserRoles.Admin); + } + + private async Task GetLeagueNameFromContext(ActionExecutingContext context) + { + if (context.RouteData.Values.TryGetValue("leagueName", out var leagueNameObject)) + { + return (string)leagueNameObject!; + } + if (context.RouteData.Values.TryGetValue("leagueId", out var leagueIdObject) == false) + { + return null; + } + if (long.TryParse((string)leagueIdObject!, out long leagueId) == false) + { + return null; + } + return (await dbContext.Leagues + .Where(x => x.Id == leagueId) + .FirstOrDefaultAsync()) + ?.Name; + } + + private void AccessDenied(ActionExecutingContext context, ActionExecutionDelegate next) + { + context.Result = new ForbidResult(); + } + + private async Task AccessGranted(ActionExecutingContext context, ActionExecutionDelegate next) + { + await base.OnActionExecutionAsync(context, next); + } +} diff --git a/src/iRLeagueApiCore.Server/Filters/ParameterIgnoreAttribute.cs b/src/iRLeagueApiCore.Server/Filters/ParameterIgnoreAttribute.cs new file mode 100644 index 00000000..ecabcb6a --- /dev/null +++ b/src/iRLeagueApiCore.Server/Filters/ParameterIgnoreAttribute.cs @@ -0,0 +1,42 @@ +namespace iRLeagueApiCore.Server.Filters; + +/// +/// Ignore parameter when generating Swagger open API documentation +/// +[AttributeUsage(AttributeTargets.Parameter)] +public class ParameterIgnoreAttribute : System.Attribute +{ +} + +public sealed class OpenApiParameterIgnoreFilter : Swashbuckle.AspNetCore.SwaggerGen.IOperationFilter +{ + public void Apply(Microsoft.OpenApi.Models.OpenApiOperation operation, Swashbuckle.AspNetCore.SwaggerGen.OperationFilterContext context) + { + if (operation == null || context == null || context.ApiDescription?.ParameterDescriptions == null) + return; + + var parametersToHide = context.ApiDescription.ParameterDescriptions + .Where(parameterDescription => ParameterHasIgnoreAttribute(parameterDescription)) + .ToList(); + + if (parametersToHide.Count == 0) + return; + + foreach (var parameterToHide in parametersToHide) + { + var parameter = operation.Parameters.FirstOrDefault(parameter => string.Equals(parameter.Name, parameterToHide.Name, System.StringComparison.Ordinal)); + if (parameter != null) + operation.Parameters.Remove(parameter); + } + } + + private static bool ParameterHasIgnoreAttribute(Microsoft.AspNetCore.Mvc.ApiExplorer.ApiParameterDescription parameterDescription) + { + if (parameterDescription.ModelMetadata is Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata metadata) + { + return metadata.Attributes.ParameterAttributes?.Any(attribute => typeof(ParameterIgnoreAttribute).IsAssignableFrom(attribute.GetType())) ?? false; + } + + return false; + } +} diff --git a/src/iRLeagueApiCore.Server/Filters/RequireLeagueRoleAttribute.cs b/src/iRLeagueApiCore.Server/Filters/RequireLeagueRoleAttribute.cs new file mode 100644 index 00000000..18e6f735 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Filters/RequireLeagueRoleAttribute.cs @@ -0,0 +1,40 @@ +namespace iRLeagueApiCore.Server.Filters; + +/// +/// Sets requirement for having at least one of the listed league roles to access the resource +/// Only works in combination with +/// If no league role is specified, the user is checked to be in at least one of any available league role +/// +[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true, Inherited = true)] +public sealed class RequireLeagueRoleAttribute : Attribute +{ + /// + /// Private field to prevent modifiying from outside + /// + private readonly LeagueRoleValue[] _roles; + /// + /// Roles that are required to access the decorated resource + /// + public LeagueRoleValue[] Roles => _roles.ToArray(); + /// + /// + /// List of roles. Requires user to be in at least one of the provided roles + public RequireLeagueRoleAttribute(params string[] roles) + { + var roleValues = roles.Select(x => LeagueRoles.GetRoleValue(x)); + var allRoles = IncludeImplicitRoles(roleValues); + _roles = allRoles.ToArray(); + } + + /// + /// Includes the (reverse) implicit role requirements + /// For example "Admin" is always implicit in role "Owner", that means "Owner" will satisfy all conditions where "Admin" is required + /// Therefore "Owner" is automatically added to the required roles list + /// + /// + /// + private static IEnumerable IncludeImplicitRoles(IEnumerable roles) + { + return roles.Concat(roles.SelectMany(x => LeagueRoles.ImplicitRoleOf(x))).Distinct(); + } +} diff --git a/src/iRLeagueApiCore.Server/Filters/RequireSubscriptionAttribute.cs b/src/iRLeagueApiCore.Server/Filters/RequireSubscriptionAttribute.cs new file mode 100644 index 00000000..8bc085a7 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Filters/RequireSubscriptionAttribute.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Data; + +namespace iRLeagueApiCore.Server.Filters; + +/// +/// Sets requirement for having an active subscription in order to hit this endpoint - +/// Only works in combination with +/// Endpoint will return "402 - Payment Required" if no subscription available +/// +[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)] +internal sealed class RequireSubscriptionAttribute : Attribute +{ +} diff --git a/src/iRLeagueApiCore.Server/Filters/SetTenantLeagueIdAttribute.cs b/src/iRLeagueApiCore.Server/Filters/SetTenantLeagueIdAttribute.cs new file mode 100644 index 00000000..429fc8db --- /dev/null +++ b/src/iRLeagueApiCore.Server/Filters/SetTenantLeagueIdAttribute.cs @@ -0,0 +1,69 @@ +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Caching.Memory; + +namespace iRLeagueApiCore.Server.Filters; + +/// +/// Automatically insert the league id corresponding the league name in route parameters +/// +/// Requires "{leagueName}" in Route +/// +/// +[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)] +internal sealed class SetTenantLeagueIdAttribute : ActionFilterAttribute +{ + private readonly LeagueDbContext _dbContext; + private readonly RequestLeagueProvider leagueProvider; + private readonly IMemoryCache memoryCache; + public SetTenantLeagueIdAttribute(LeagueDbContext dbContext, RequestLeagueProvider leagueProvider, IMemoryCache memoryCache) + { + _dbContext = dbContext; + this.leagueProvider = leagueProvider; + this.memoryCache = memoryCache; + } + + public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) + { + if (context.RouteData.Values.TryGetValue("leagueName", out var leagueNameObject) == false) + { + throw new InvalidOperationException("Missing {leagueName} in action route"); + } + var leagueName = (string)leagueNameObject!; + var leagueId = await GetLeagueIdByName(leagueName); + + if (leagueId == 0) + { + context.Result = new NotFoundObjectResult($"League {leagueName} does not exist"); + return; + } + + context.ActionArguments.Add("leagueId", leagueId); + leagueProvider.SetLeague(leagueId, leagueName); + + await base.OnActionExecutionAsync(context, next); + } + + private async Task GetLeagueIdByName(string leagueName) + { + // hit cache and try to get league information without asking database + if (memoryCache.TryGetValue(CacheKeys.GetLeagueNameKey(leagueName), out LeagueEntity cachedLeague)) + { + return cachedLeague.Id; + } + // get league from database and store in cache + var league = await _dbContext.Leagues + .AsNoTracking() + .SingleOrDefaultAsync(x => x.Name == leagueName); + if (league is null) + { + return 0; + } + var cacheEntryOptions = new MemoryCacheEntryOptions() + .SetAbsoluteExpiration(DateTime.UtcNow.AddSeconds(30)); + memoryCache.Set(CacheKeys.GetLeagueNameKey(leagueName), league, cacheEntryOptions); + return league.Id; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Admin/GiveRoleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Admin/GiveRoleHandler.cs new file mode 100644 index 00000000..ddd9a4e7 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Admin/GiveRoleHandler.cs @@ -0,0 +1,87 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Admin; + +public sealed class GiveRoleRequest : UserRoleModel, IRequest +{ + public string LeagueName { get; } + public ApplicationUser User { get; set; } = default!; + + public GiveRoleRequest(string leagueName, UserRoleModel UserRole) + { + LeagueName = leagueName; + UserName = UserRole.UserName; + RoleName = UserRole.RoleName; + } +} + +public sealed class GiveRoleHandler : IRequestHandler +{ + private readonly ILogger _logger; + private readonly IEnumerable> _validators; + private readonly UserManager _userManager; + private readonly RoleManager _roleManager; + + public GiveRoleHandler(ILogger logger, IEnumerable> validators, + UserManager userManager, RoleManager roleManager) + { + _logger = logger; + _validators = validators; + _userManager = userManager; + _roleManager = roleManager; + } + + public async Task Handle(GiveRoleRequest request, CancellationToken cancellationToken = default) + { + await _validators.ValidateAllAndThrowAsync(request, cancellationToken); + var leagueName = request.LeagueName; + var roleName = request.RoleName; + var leagueRoleName = LeagueRoles.GetLeagueRoleName(leagueName, roleName); + var user = request.User; + + if (leagueRoleName == null) + { + return Unit.Value; + } + + // check if role needs to be created + if (await _roleManager.RoleExistsAsync(leagueRoleName) == false) + { + _logger.LogInformation("Creating league role {LeagueRole} for {LeagueName} => {Role}", roleName, + leagueName, leagueRoleName); + await CreateLeagueRoleAsync(leagueRoleName); + _logger.LogInformation("League role {LeagueRole} for {LeagueName} created => {Role}", roleName, + leagueName, leagueRoleName); + } + await AddUserToRole(user, leagueRoleName); + _logger.LogInformation("Added league role {LeagueRole} to user {RoleUser} for {LeagueName}", + roleName, user.UserName, leagueName); + return Unit.Value; + } + + private async Task CreateLeagueRoleAsync(string leagueRoleName) + { + var roleResult = await _roleManager.CreateAsync(new IdentityRole(leagueRoleName)); + + if (roleResult.Succeeded == false) + { + _logger.LogError("Failed to create role {Role} due to errors: {Errors}", leagueRoleName, + roleResult.Errors.Select(x => $"{x.Code}: {x.Description}")); + throw new InvalidOperationException($"Failed to create role {leagueRoleName}"); + } + } + + private async Task AddUserToRole(ApplicationUser user, string roleName) + { + var addToRoleResult = await _userManager.AddToRoleAsync(user, roleName); + if (addToRoleResult.Succeeded == false) + { + _logger.LogError("Failed to add user {RoleUser} to role {Role} due to errors: {Errors}", + user.UserName, roleName, + addToRoleResult.Errors.Select(x => $"{x.Code}: {x.Description}")); + throw new InvalidOperationException($"Failed to add {user.UserName} to role {roleName}"); + } + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Admin/ListUsersHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Admin/ListUsersHandler.cs new file mode 100644 index 00000000..8a6e96cd --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Admin/ListUsersHandler.cs @@ -0,0 +1,59 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Admin; + +public record ListUsersRequest(string LeagueName) : IRequest>; + +public sealed class ListUsersHandler : IRequestHandler> +{ + private readonly ILogger _logger; + private readonly IEnumerable> _validators; + private readonly UserManager _userManager; + + public ListUsersHandler(ILogger logger, IEnumerable> validators, + UserManager userManager) + { + _logger = logger; + _validators = validators; + _userManager = userManager; + } + + public async Task> Handle(ListUsersRequest request, CancellationToken cancellationToken = default) + { + await _validators.ValidateAllAndThrowAsync(request, cancellationToken); + // Get users that have a league role + var users = await GetUsersWithLeagueRoleAsync(request.LeagueName); + var getUsers = users.Select(x => MapToAdminUserModel(x.Key, x)); + return getUsers; + } + + private async Task>> GetUsersWithLeagueRoleAsync(string leagueName) + { + var users = new List<(ApplicationUser user, string role)>(); + foreach (var role in LeagueRoles.RolesAvailable) + { + var leagueRoleName = LeagueRoles.GetLeagueRoleName(leagueName, role); + var inRole = await _userManager.GetUsersInRoleAsync(leagueRoleName); + if (inRole != null) + { + users.AddRange(inRole.Select(user => (user, (string)role))); + } + } + return users.GroupBy(x => x.user, x => x.role); + } + + private static AdminUserModel MapToAdminUserModel(ApplicationUser user, IEnumerable roles) + { + var parts = user.FullName?.Split(';') ?? Array.Empty(); + return new AdminUserModel() + { + UserName = user.UserName, + Firstname = parts.ElementAtOrDefault(0) ?? string.Empty, + Lastname = parts.ElementAtOrDefault(1) ?? string.Empty, + Email = user.Email, + Roles = roles, + }; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/AdminPanel/AdminHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/AdminHandlerBase.cs new file mode 100644 index 00000000..bbd89e15 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/AdminHandlerBase.cs @@ -0,0 +1,38 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Server.Models.Payments; +using System.Diagnostics.CodeAnalysis; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.AdminPanel; + +public class AdminHandlerBase : HandlerBase +{ + public AdminHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + protected virtual LeagueEntity UpdateLeagueSubscriptionStatus(LeagueEntity league, PaymentEntity payment) + { + if (league.Subscription == SubscriptionStatus.Lifetime) + { + return league; + } + league.Subscription = payment.Status == PaymentStatus.Active ? SubscriptionStatus.PaidPlan : SubscriptionStatus.Expired; + league.Expires = payment.NextPaymentDue; + return league; + } + + protected static Expression> MapToPaymentModelExpression => payment => + new(payment.Id, + payment.Type, + payment.PlanId ?? string.Empty, + payment.Subscription != null ? payment.Subscription.Name : string.Empty, + payment.Subscription != null ? payment.Subscription.Interval : default, + payment.SubscriptionId ?? string.Empty, + payment.LeagueId, + payment.UserId, + payment.LastPaymentReceived, + payment.NextPaymentDue, + payment.Status); +} diff --git a/src/iRLeagueApiCore.Server/Handlers/AdminPanel/DeactivatePaymentHandler.cs b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/DeactivatePaymentHandler.cs new file mode 100644 index 00000000..0d4f0c31 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/DeactivatePaymentHandler.cs @@ -0,0 +1,32 @@ +using iRLeagueApiCore.Server.Models.Payments; + +namespace iRLeagueApiCore.Server.Handlers.AdminPanel; + +public record DeactivatePaymentRequest(Guid Id) : IRequest; + +public class DeactivatePaymentHandler : AdminHandlerBase, + IRequestHandler +{ + public DeactivatePaymentHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(DeactivatePaymentRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var payment = await dbContext.Payments + .Include(x => x.League) + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) + ?? throw new ResourceNotFoundException(); + payment.Status = PaymentStatus.Inactive; + payment.League = UpdateLeagueSubscriptionStatus(payment.League!, payment); + await dbContext.SaveChangesAsync(cancellationToken); + var getPayment = await dbContext.Payments + .Where(x => x.Id == request.Id) + .Select(MapToPaymentModelExpression) + .FirstAsync(cancellationToken); + return getPayment; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/AdminPanel/GetAllPaymentsHandler.cs b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/GetAllPaymentsHandler.cs new file mode 100644 index 00000000..54a842b0 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/GetAllPaymentsHandler.cs @@ -0,0 +1,26 @@ +using iRLeagueApiCore.Server.Models.Payments; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.AdminPanel; + +public record GetAllPaymentsRequest(long? LeagueId = null) : IRequest>; + +public class GetAllPaymentsHandler : AdminHandlerBase, + IRequestHandler> +{ + public GetAllPaymentsHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetAllPaymentsRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getSubscriptions = await dbContext.Payments + .Where(x => request.LeagueId == null || x.LeagueId == request.LeagueId) + .Select(MapToPaymentModelExpression) + .ToListAsync(cancellationToken); + return getSubscriptions; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/AdminPanel/GetPaymentHandler.cs b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/GetPaymentHandler.cs new file mode 100644 index 00000000..7696f1c0 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/GetPaymentHandler.cs @@ -0,0 +1,24 @@ +using iRLeagueApiCore.Server.Models.Payments; + +namespace iRLeagueApiCore.Server.Handlers.AdminPanel; + +public record GetPaymentRequest(Guid Id) : IRequest; + +public class GetPaymentHandler : AdminHandlerBase, IRequestHandler +{ + public GetPaymentHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(GetPaymentRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getPayment = await dbContext.Payments + .Select(MapToPaymentModelExpression) + .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getPayment; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/AdminPanel/PostPaymentHandler.cs b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/PostPaymentHandler.cs new file mode 100644 index 00000000..532a6ea3 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/PostPaymentHandler.cs @@ -0,0 +1,51 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Server.Models.Payments; + +namespace iRLeagueApiCore.Server.Handlers.AdminPanel; + +public record PostPaymentRequest(long LeagueId, PostPaymentModel Model) : IRequest; + +public sealed class PostPaymentHandler : AdminHandlerBase, + IRequestHandler +{ + public PostPaymentHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(PostPaymentRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var league = await dbContext.Leagues.FirstAsync(x => x.Id == request.LeagueId, cancellationToken); + var postPayment = await CreatePayment(league, request.Model, cancellationToken); + league = UpdateLeagueSubscriptionStatus(league, postPayment); + dbContext.Payments.Add(postPayment); + await dbContext.SaveChangesAsync(cancellationToken); + var getPayment = await dbContext.Payments + .Where(x => x.Id == postPayment.Id) + .Select(MapToPaymentModelExpression) + .FirstAsync(cancellationToken); + return getPayment; + } + + private async Task CreatePayment(LeagueEntity league, PostPaymentModel model, CancellationToken cancellationToken) + { + var subscription = await dbContext.Subscriptions + .FirstOrDefaultAsync(x => x.PlanId == model.PlanId, cancellationToken); + var payment = new PaymentEntity() + { + LastPaymentReceived = model.Received, + League = league, + LeagueId = league.Id, + NextPaymentDue = model.NextDue, + PlanId = model.PlanId, + Subscription = subscription, + SubscriptionId = model.SubscriptionId, + Status = (model.NextDue == null || model.NextDue > DateTime.UtcNow) ? PaymentStatus.Active : PaymentStatus.Inactive, + Type = model.PaymentType, + UserId = model.UserId, + }; + return payment; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/AdminPanel/SetLeagueSubscriptionHandler.cs b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/SetLeagueSubscriptionHandler.cs new file mode 100644 index 00000000..bc812140 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/AdminPanel/SetLeagueSubscriptionHandler.cs @@ -0,0 +1,30 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.Server.Models.Payments; + +namespace iRLeagueApiCore.Server.Handlers.AdminPanel; + +public record SetLeagueSubscriptionRequest(long LeagueId, SetLeagueSubscriptionModel Model) : IRequest; + +public class SetLeagueSubscriptionHandler : LeagueHandlerBase, + IRequestHandler +{ + public SetLeagueSubscriptionHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(SetLeagueSubscriptionRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var league = await GetLeagueEntityAsync(request.LeagueId, cancellationToken) + ?? throw new ResourceNotFoundException(); + league.Subscription = request.Model.Status; + league.Expires = request.Model.Expires; + await dbContext.SaveChangesAsync(cancellationToken); + var getLeague = await MapToGetLeagueModelAsync(request.LeagueId, true, cancellationToken); + return getLeague!; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Authentication/PasswordResetHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Authentication/PasswordResetHandler.cs new file mode 100644 index 00000000..d16ce0b3 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Authentication/PasswordResetHandler.cs @@ -0,0 +1,80 @@ +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Models; +using iRLeagueApiCore.Services.EmailService; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.WebUtilities; +using System.Text; + +namespace iRLeagueApiCore.Server.Handlers.Authentication; + +public record PasswordResetRequest(PasswordResetModel Model) : IRequest; +public sealed class PasswordResetHandler : IRequestHandler +{ + private readonly ILogger logger; + private readonly UserManager userManager; + private readonly IEnumerable> validators; + private readonly IEmailClient emailClient; + + public PasswordResetHandler(ILogger logger, UserManager userManager, + IEnumerable> validators, IEmailClient emailClient) + { + this.logger = logger; + this.userManager = userManager; + this.validators = validators; + this.emailClient = emailClient; + } + + public async Task Handle(PasswordResetRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await userManager.FindByNameAsync(request.Model.UserName) + ?? throw new ResourceNotFoundException(); + var token = await GetResetToken(user); + if (user.Email.Equals(request.Model.Email, StringComparison.OrdinalIgnoreCase) == false) + { + logger.LogWarning("Cancel password reset token request: provided Email does not match username"); + return Unit.Value; + } + await SendResetMailAsync(user, request.Model.Email, token, request.Model.LinkUriTemplate); + return Unit.Value; + } + + private async Task GetResetToken(ApplicationUser user) + { + return await userManager.GeneratePasswordResetTokenAsync(user); + } + + private async Task SendResetMailAsync(ApplicationUser user, string email, string token, string linkTemplate) + { + string subject = $"Password Reset Token for your Account \"{user.UserName}\""; + string body = GenerateMailBody(user, token, linkTemplate); + await emailClient.SendNoReplyMailAsync(email, subject, body); + } + + private static string GenerateMailBody(ApplicationUser user, string token, string linkTemplate) + { + var resetUrl = GeneratePasswordResetUrl(user.Id, token, linkTemplate); + var body = $""" +

Dear User,

+

For your account with the username "{user.UserName}" a password reset was requested. + If you posted this request pleas use the following link to complete the process and set a new password:

+ {resetUrl} +

If you did not post this request you can ignore this mail.

+

Please do not reply to this mail. Messages send to the sender of this mail will not be processed

+ """; + return body; + } + + private static string GeneratePasswordResetUrl(string userId, string token, string template) + { + if (string.IsNullOrWhiteSpace(template)) + { + template = "https://irleaguemanager.net/member/{userId}/SetPassword/{token}"; + } + var encodedToken = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(token)); + var url = template + .Replace("{userId}", userId) + .Replace("{token}", encodedToken); + return url; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Authentication/SetPasswordWithTokenHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Authentication/SetPasswordWithTokenHandler.cs new file mode 100644 index 00000000..03d3265f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Authentication/SetPasswordWithTokenHandler.cs @@ -0,0 +1,38 @@ +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Authentication; + +public record SetPasswordWithTokenRequest(string UserId, SetPasswordTokenModel Model) : IRequest; + +public sealed class SetPasswordWithTokenHandler : IRequestHandler +{ + private readonly ILogger logger; + private readonly UserManager userManager; + private readonly IEnumerable> validators; + + public SetPasswordWithTokenHandler(ILogger logger, UserManager userManager, + IEnumerable> validators) + { + this.logger = logger; + this.userManager = userManager; + this.validators = validators; + } + + public async Task Handle(SetPasswordWithTokenRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await userManager.FindByIdAsync(request.UserId) + ?? throw new InvalidOperationException(); + logger.LogWarning("Resetting password for user {UserName}:{UserId}", user.UserName, user.Id); + var result = await userManager.ResetPasswordAsync(user, request.Model.PasswordToken, request.Model.NewPassword); + if (result.Succeeded == false) + { + logger.LogError("Password reset failed: {Errors}", result.Errors); + return false; + } + logger.LogWarning("Password reset successfull"); + return true; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Cars/GetCarsFromEventHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Cars/GetCarsFromEventHandler.cs new file mode 100644 index 00000000..86fe0da0 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Cars/GetCarsFromEventHandler.cs @@ -0,0 +1,78 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Results; +using iRLeagueApiCore.Services.ResultService.Extensions; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Cars; + +public record GetCarsFromEventRequest(long EventId) : IRequest; + +public class GetCarsFromEventHandler : HandlerBase, + IRequestHandler +{ + public GetCarsFromEventHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetCarsFromEventRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken).ConfigureAwait(false); + var eventCars = (await GetEventCarsPerMemberAsync(request.EventId, cancellationToken)); + var groupedCars = eventCars + .GroupBy(x => new { x.Number, x.Team?.TeamId }) + .Select(x => new EventCarInfoModel() + { + Number = x.First().Number, + Car = x.First().Car, + CarId = x.First().CarId, + Class = x.First().Class, + Members = x.SelectMany(x => x.Members), + Team = x.First().Team, + }); + bool isTeamEvent = groupedCars.Any(x => x.Members.Count() > 1) && groupedCars.None(x => x.Team == null); + return new CarListModel() + { + IsTeamEvent = isTeamEvent, + Cars = isTeamEvent ? groupedCars : eventCars, + }; + } + + private async Task> GetEventCarsPerMemberAsync(long eventId, CancellationToken cancellationToken) + { + var memberCarRows = await dbContext.EventResults + .Where(x => x.EventId == eventId) + .SelectMany(x => x.SessionResults) + .SelectMany(x => x.ResultRows) + .Select(MapToCarInfoModelExpression) + .ToListAsync(cancellationToken); + return memberCarRows + .DistinctBy(x => x.MemberId) + .Select(x => x.EventCar); + } + + private static Expression> MapToCarInfoModelExpression => row => new( + row.MemberId, + new() { + Car = row.Car, + CarId = row.CarId, + Class = row.CarClass, + Members = new[] { new MemberInfoModel() + { + MemberId = row.MemberId, + FirstName = row.Member.Firstname, + LastName = row.Member.Lastname, + } + }, + Team = row.Team == null ? default : new() + { + TeamId = row.Team.TeamId, + Name = row.Team.Name, + TeamColor = row.Team.TeamColor, + }, + Number = row.CarNumber, + } + ); + + private record MemberCarInfo(long MemberId, EventCarInfoModel EventCar); +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/ChampSeasonHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/ChampSeasonHandlerBase.cs new file mode 100644 index 00000000..71983e33 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/ChampSeasonHandlerBase.cs @@ -0,0 +1,129 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public class ChampSeasonHandlerBase : HandlerBase +{ public ChampSeasonHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetChampSeasonEntityAsync(long champSeasonId, CancellationToken cancellationToken) + { + return await ChampSeasonsQuery() + .Include(x => x.Championship) + .Include(x => x.StandingConfiguration) + .Include(x => x.ResultConfigurations) + .Include(x => x.DefaultResultConfig) + .Include(x => x.Filters) + .Where(x => x.ChampSeasonId == champSeasonId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task MapToChampSeasonEntityAsync(LeagueUser user, PutChampSeasonModel model, ChampSeasonEntity target, + CancellationToken cancellationToken) + { + target.Championship.Name = model.ChampionshipName; + target.Championship.DisplayName = model.ChampionshipDisplayName; + target.StandingConfiguration = await MapToStandingConfigurationAsync(user, model.StandingConfig, cancellationToken); + target.ResultConfigurations = await MapToResultConfigurationListAsync(model.ResultConfigs.Select(x => x.ResultConfigId), target.ResultConfigurations, cancellationToken); + target.DefaultResultConfig = target.ResultConfigurations.FirstOrDefault(x => x.ResultConfigId == model.DefaultResultConfig?.ResultConfigId); + target.ResultKind = model.ResultKind; + target.Filters = await MapToFilterOptionListAsync(user, model.Filters, target.Filters, cancellationToken); + return await Task.FromResult(target); + } + + protected async Task MapToStandingConfigurationAsync(LeagueUser user, StandingConfigModel? model, CancellationToken cancellationToken) + { + if (model is null) + { + return null; + } + + var entity = await dbContext.StandingConfigurations + .Where(x => x.StandingConfigId == model.StandingConfigId && model.StandingConfigId != 0) + .FirstOrDefaultAsync(cancellationToken); + entity ??= CreateVersionEntity(user, new StandingConfigurationEntity() + { + LeagueId = dbContext.LeagueProvider.LeagueId, + }); + entity.Name = model.Name; + entity.ResultKind = model.ResultKind; + entity.UseCombinedResult = model.UseCombinedResult; + entity.WeeksCounted = model.WeeksCounted; + entity.SortOptions = model.SortOptions; + UpdateVersionEntity(user, entity); + return entity; + } + + protected async Task> MapToResultConfigurationListAsync(IEnumerable resultConfigId, + ICollection target, CancellationToken cancellationToken) + { + target = await dbContext.ResultConfigurations + .Where(x => resultConfigId.Contains(x.ResultConfigId)) + .ToListAsync(cancellationToken); + return target; + } + + protected async Task MapToChampSeasonModel(long champSeasonId, CancellationToken cancellationToken) + { + return await ChampSeasonsQuery() + .Where(x => x.ChampSeasonId == champSeasonId) + .Select(MapToChampSeasonModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } + + protected IQueryable ChampSeasonsQuery() + { + return dbContext.ChampSeasons + .Where(x => x.IsActive); + } + + protected virtual Expression> MapToChampSeasonModelExpression => champSeason => new() + { + ChampionshipId = champSeason.ChampionshipId, + ChampSeasonId = champSeason.ChampSeasonId, + ChampionshipName = champSeason.Championship.Name, + ChampionshipDisplayName = champSeason.Championship.DisplayName, + ResultKind = champSeason.ResultKind, + ResultConfigs = champSeason.ResultConfigurations.Select(config => new ResultConfigInfoModel() + { + LeagueId = champSeason.LeagueId, + ResultConfigId = config.ResultConfigId, + ChampSeasonId = champSeason.ChampSeasonId, + ChampionshipName = champSeason.Championship.Name, + Name = config.Name, + DisplayName = config.DisplayName, + IsDefaultConfig = config.ResultConfigId == champSeason.DefaultResultConfigId, + }).ToList(), + DefaultResultConfig = champSeason.DefaultResultConfig == null ? null : new ResultConfigInfoModel() + { + LeagueId = champSeason.LeagueId, + ResultConfigId = champSeason.DefaultResultConfig.ResultConfigId, + ChampSeasonId = champSeason.ChampSeasonId, + ChampionshipName = champSeason.Championship.Name, + Name = champSeason.DefaultResultConfig.Name, + DisplayName = champSeason.DefaultResultConfig.DisplayName, + IsDefaultConfig = true, + }, + SeasonId = champSeason.SeasonId, + SeasonName = champSeason.Season.SeasonName, + StandingConfig = champSeason.StandingConfiguration == null ? null : new StandingConfigModel() + { + StandingConfigId = champSeason.StandingConfiguration.StandingConfigId, + Name = champSeason.StandingConfiguration.Name, + ResultKind = champSeason.StandingConfiguration.ResultKind, + UseCombinedResult = champSeason.StandingConfiguration.UseCombinedResult, + WeeksCounted = champSeason.StandingConfiguration.WeeksCounted, + SortOptions = champSeason.StandingConfiguration.SortOptions, + }, + Filters = champSeason.Filters.Select(filter => new ResultFilterModel() + { + LeagueId = filter.LeagueId, + FilterOptionId = filter.FilterOptionId, + Condition = filter.Conditions.FirstOrDefault() ?? new(), + }).ToList(), + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/ChampionshipHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/ChampionshipHandlerBase.cs new file mode 100644 index 00000000..23878aa8 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/ChampionshipHandlerBase.cs @@ -0,0 +1,57 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public class ChampionshipHandlerBase : HandlerBase +{ + public ChampionshipHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetChampionshipEntityAsync(long championshipId, CancellationToken cancellationToken) + { + return await dbContext.Championships + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.Filters) + .Where(x => x.ChampionshipId == championshipId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task MapToChampionshipEntityAsync(LeagueUser user, PostChampionshipModel postModel, ChampionshipEntity target, + CancellationToken cancellationToken) + { + target.Name = postModel.Name; + target.DisplayName = postModel.DisplayName; + UpdateVersionEntity(user, target); + return await Task.FromResult(target); + } + + protected virtual async Task MapToChampionshipModelAsync(long championshipId, CancellationToken cancellationToken) + { + return await dbContext.Championships + .Where(x => x.ChampionshipId == championshipId) + .Where(x => x.IsArchived == false) + .Select(MapToChampionshipModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual Expression> MapToChampionshipModelExpression => championship => new() + { + ChampionshipId = championship.ChampionshipId, + Name= championship.Name, + DisplayName = championship.DisplayName, + Seasons = championship.ChampSeasons + .Where(x => x.IsActive) + .Select(champSeason => new ChampSeasonInfoModel() + { + ChampionshipId = championship.ChampionshipId, + ChampionshipName = championship.Name, + ChampSeasonId = champSeason.ChampSeasonId, + SeasonId = champSeason.SeasonId, + SeasonName = champSeason.Season.SeasonName, + }).ToList(), + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/DeleteChampSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/DeleteChampSeasonHandler.cs new file mode 100644 index 00000000..d20143c6 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/DeleteChampSeasonHandler.cs @@ -0,0 +1,24 @@ +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record DeleteChampSeasonRequest(long ChampSeasonId) : IRequest; + +public sealed class DeleteChampSeasonHandler : ChampSeasonHandlerBase, + IRequestHandler +{ + public DeleteChampSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteChampSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteChampSeason = await GetChampSeasonEntityAsync(request.ChampSeasonId, cancellationToken) + ?? throw new ResourceNotFoundException(); + deleteChampSeason.IsActive = false; + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/DeleteChampionshipHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/DeleteChampionshipHandler.cs new file mode 100644 index 00000000..10c7412c --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/DeleteChampionshipHandler.cs @@ -0,0 +1,27 @@ +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record DeleteChampionshipRequest(long ChampionshipId) : IRequest; + +public class DeleteChampionshipHandler : ChampionshipHandlerBase, + IRequestHandler +{ + public DeleteChampionshipHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteChampionshipRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteChampionship = await GetChampionshipEntityAsync(request.ChampionshipId, cancellationToken) + ?? throw new ResourceNotFoundException(); + // only archive championship instead of deleting + deleteChampionship.IsArchived = true; + foreach(var champSeason in deleteChampionship.ChampSeasons) + { + champSeason.IsActive = false; + } + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonFromSeasonChampionshipHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonFromSeasonChampionshipHandler.cs new file mode 100644 index 00000000..c473b89d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonFromSeasonChampionshipHandler.cs @@ -0,0 +1,33 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record GetChampSeasonFromSeasonChampionshipRequest(long SeasonId, long ChampionshipId) : IRequest; + +public class GetChampSeasonFromSeasonChampionshipHandler : ChampSeasonHandlerBase, + IRequestHandler +{ + public GetChampSeasonFromSeasonChampionshipHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(GetChampSeasonFromSeasonChampionshipRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getChampSeason = await GetChampSeasonFromSeasonChampionship(request.SeasonId, request.ChampionshipId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getChampSeason; + } + + private async Task GetChampSeasonFromSeasonChampionship(long seasonId, long championshipId, CancellationToken cancellationToken) + { + return await dbContext.ChampSeasons + .Where(x => x.SeasonId == seasonId) + .Where(x => x.ChampionshipId == championshipId) + .Select(MapToChampSeasonModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonHandler.cs new file mode 100644 index 00000000..ed2b673b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonHandler.cs @@ -0,0 +1,23 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record GetChampSeasonRequest(long ChampSeasonId) : IRequest; + +public sealed class GetChampSeasonHandler : ChampSeasonHandlerBase, + IRequestHandler +{ + public GetChampSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(GetChampSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getChampSeason = await MapToChampSeasonModel(request.ChampSeasonId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getChampSeason; + } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonsFromChampionshipHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonsFromChampionshipHandler.cs new file mode 100644 index 00000000..ddb8ebac --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonsFromChampionshipHandler.cs @@ -0,0 +1,33 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record GetChampSeasonsFromChampionshipRequest(long ChampionshipId) : IRequest>; + +public sealed class GetChampSeasonFromChampionshipHandler : ChampSeasonHandlerBase, + IRequestHandler> +{ + public GetChampSeasonFromChampionshipHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetChampSeasonsFromChampionshipRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getChampSeasons = await MapToChampSeasonModelsFromChampionshipAsync(request.ChampionshipId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getChampSeasons; + } + + private async Task> MapToChampSeasonModelsFromChampionshipAsync(long championshipId, CancellationToken cancellationToken) + { + return await ChampSeasonsQuery() + .Where(x => x.ChampionshipId == championshipId) + .OrderByDescending(x => x.Season.SeasonStart) + .Select(MapToChampSeasonModelExpression) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonsFromSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonsFromSeasonHandler.cs new file mode 100644 index 00000000..9c029bc2 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampSeasonsFromSeasonHandler.cs @@ -0,0 +1,32 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record GetChampSeasonsFromSeasonRequest(long SeasonId) : IRequest>; + +public sealed class GetChampSeasonFromSeasonHandler : ChampSeasonHandlerBase, + IRequestHandler> +{ + public GetChampSeasonFromSeasonHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetChampSeasonsFromSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getChampSeasons = await MapToChampSeasonModelsFromSeasonAsync(request.SeasonId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getChampSeasons; + } + + private async Task> MapToChampSeasonModelsFromSeasonAsync(long seasonId, CancellationToken cancellationToken) + { + return await ChampSeasonsQuery() + .Where(x => x.SeasonId == seasonId) + .Select(MapToChampSeasonModelExpression) + .ToListAsync(cancellationToken); + } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampionshipHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampionshipHandler.cs new file mode 100644 index 00000000..9fb22e95 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampionshipHandler.cs @@ -0,0 +1,22 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record GetChampionshipRequest(long ChampionshipId) : IRequest; + +public class GetChampionshipHandler : ChampionshipHandlerBase, + IRequestHandler +{ + public GetChampionshipHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetChampionshipRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getChampionship = await MapToChampionshipModelAsync(request.ChampionshipId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getChampionship; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampionshipsFromLeagueHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampionshipsFromLeagueHandler.cs new file mode 100644 index 00000000..0013459d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/GetChampionshipsFromLeagueHandler.cs @@ -0,0 +1,30 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record GetChampionshipsFromLeagueRequest() : IRequest>; + +public sealed class GetChampionshipsFromLeagueHandler : ChampionshipHandlerBase, + IRequestHandler> +{ + public GetChampionshipsFromLeagueHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetChampionshipsFromLeagueRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getChampionships = await MapToChampionshipModelsFromLeagueAsync(cancellationToken); + return getChampionships; + } + + private async Task> MapToChampionshipModelsFromLeagueAsync(CancellationToken cancellationToken) + { + return await dbContext.Championships + .Where(x => x.IsArchived == false) + .Select(MapToChampionshipModelExpression) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/PostChampSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/PostChampSeasonHandler.cs new file mode 100644 index 00000000..03125045 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/PostChampSeasonHandler.cs @@ -0,0 +1,237 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueDatabaseCore; +using System.Threading; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record PostChampSeasonRequest(long ChampionshipId, long SeasonId, LeagueUser User, PostChampSeasonModel Model) : IRequest; + +public sealed class PostChampSeasonHandler : ChampSeasonHandlerBase, + IRequestHandler +{ + public PostChampSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(PostChampSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postChampSeason = await GetChampSeasonEntityAsync(request.ChampionshipId, request.SeasonId, cancellationToken) + ?? await CreateChampSeasonEntityAsync(request.User, request.ChampionshipId, request.SeasonId, cancellationToken); + postChampSeason.IsActive = true; + await dbContext.SaveChangesAsync(cancellationToken); + var getChampSeason = await MapToChampSeasonModel(postChampSeason.ChampSeasonId, cancellationToken) + ?? throw new InvalidOperationException("Created resource not found"); + return getChampSeason; + } + + private async Task GetChampSeasonEntityAsync(long championshipId, long seasonId, CancellationToken cancellationToken) + { + return await dbContext.ChampSeasons + .Where(x => x.ChampionshipId == championshipId) + .Where(x => x.SeasonId == seasonId) + .FirstOrDefaultAsync(cancellationToken); + } + + private async Task CreateChampSeasonEntityAsync(LeagueUser user, long championshipId, long seasonId, CancellationToken cancellationToken) + { + var championship = await dbContext.Championships + .Where(x => x.ChampionshipId == championshipId) + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.ResultConfigurations) + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.Season) + .ThenInclude(x => x.Schedules) + .ThenInclude(x => x.Events) + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.Filters) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var season = await dbContext.Seasons + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.ResultConfigurations) + .Where(x => x.SeasonId == seasonId) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var champSeason = CreateVersionEntity(user, new ChampSeasonEntity() + { + Championship = championship, + Season = season, + IsActive = true, + }); + var prevChampSeason = championship.ChampSeasons + .Select(x => new {ChampSeason = x, Events = x.Season.Schedules.SelectMany(x => x.Events)}) + .Where(x => x.Events.Any()) + .OrderByDescending(x => x.Events.Select(x => x.Date).Where(x => x < DateTime.UtcNow).Max()) + .Select(x => x.ChampSeason) + .FirstOrDefault(); + + // find previous season settings and copy + champSeason.StandingConfiguration = await CreateOrCopyStandingConfigEntity(user, prevChampSeason?.StandingConfigId, cancellationToken); + champSeason.ResultConfigurations = await CopyResultConfigurationEntities(user, champSeason, prevChampSeason?.ResultConfigurations.Select(x => x.ResultConfigId), cancellationToken); + champSeason.Filters = CopyChampSeasonFilterEntities(user, prevChampSeason?.Filters); + UpdateVersionEntity(user, champSeason); + + championship.ChampSeasons.Add(champSeason); + season.ChampSeasons.Add(champSeason); + //dbContext.ChampSeasons.Add(champSeason); + return champSeason; + } + + private ICollection CopyChampSeasonFilterEntities(LeagueUser user, ICollection? filters) + { + var copyFilters = filters?.Select(x => CreateVersionEntity(user, new FilterOptionEntity() + { + Conditions = x.Conditions, + + })) ?? new List(); + copyFilters.ForEach(x => UpdateVersionEntity(user, x)); + return copyFilters.ToList(); + } + + private async Task CreateOrCopyStandingConfigEntity(LeagueUser user, long? prevStandingConfigId, CancellationToken cancellationToken) + { + var target = CreateVersionEntity(user, new StandingConfigurationEntity() + { + LeagueId = dbContext.LeagueProvider.LeagueId, + }); + var source = await dbContext.StandingConfigurations + .Where(x => x.StandingConfigId == prevStandingConfigId) + .FirstOrDefaultAsync(cancellationToken); + if (source is not null) + { + target.Name = source.Name; + target.ResultKind = source.ResultKind; + target.UseCombinedResult = source.UseCombinedResult; + target.WeeksCounted = source.WeeksCounted; + } + UpdateVersionEntity(user, target); + return target; + } + + private FilterOptionEntity CopyFilterOptionEntity(LeagueUser user, FilterOptionEntity source) + { + var target = CreateVersionEntity(user, new FilterOptionEntity() + { + Conditions = source.Conditions, + }); + UpdateVersionEntity(user, target); + return target; + } + + private PointRuleEntity? CopyPointRuleEntity(LeagueUser user, PointRuleEntity? source) + { + if (source is null) + { + return null; + } + var target = CreateVersionEntity(user, new PointRuleEntity() + { + League = source.League, + BonusPoints = source.BonusPoints, + FinalSortOptions = source.FinalSortOptions, + MaxPoints = source.MaxPoints, + Name = source.Name, + PointDropOff = source.PointDropOff, + PointsPerPlace = source.PointsPerPlace, + PointsSortOptions = source.PointsSortOptions, + AutoPenalties = CopyAutoPenalties(source.AutoPenalties), + }); + UpdateVersionEntity(user, target); + return target; + } + + private static ICollection CopyAutoPenalties(ICollection autoPenalties) + { + return autoPenalties.Select(x => new AutoPenaltyConfigEntity() + { + Conditions = x.Conditions, + Description = x.Description, + Points = x.Points, + Positions = x.Positions, + Time = x.Time, + Type = x.Type, + }).ToList(); + } + + private ScoringEntity CopyScoringEntity(LeagueUser user, ScoringEntity source) + { + var target = CreateVersionEntity(user, new ScoringEntity() + { + IsCombinedResult = source.IsCombinedResult, + Index = source.Index, + Name = source.Name, + UpdateTeamOnRecalculation = source.UpdateTeamOnRecalculation, + UseExternalSourcePoints = source.UseExternalSourcePoints, + UseResultSetTeam = source.UseResultSetTeam, + MaxResultsPerGroup = source.MaxResultsPerGroup, + ShowResults = source.ShowResults, + PointsRule = CopyPointRuleEntity(user, source.PointsRule), + }); + UpdateVersionEntity(user, target); + return target; + } + + private ResultConfigurationEntity CopyResultConfigurationEntity(LeagueUser user, ChampSeasonEntity currentChampSeason, ResultConfigurationEntity source) + { + var target = CreateVersionEntity(user, new ResultConfigurationEntity() + { + DisplayName = source.DisplayName, + Name = source.Name, + ResultsPerTeam = source.ResultsPerTeam, + SourceResultConfig = GetSourceResultConfigurationEntity(currentChampSeason, source), + ResultFilters = source.ResultFilters.Select(x => CopyFilterOptionEntity(user, x)).ToList(), + PointFilters = source.PointFilters.Select(x => CopyFilterOptionEntity(user, x)).ToList(), + Scorings = source.Scorings.Select(x => CopyScoringEntity(user, x)).ToList(), + }); + UpdateVersionEntity(user, target); + return target; + } + + private ResultConfigurationEntity? GetSourceResultConfigurationEntity(ChampSeasonEntity currentChampSeason, ResultConfigurationEntity config) + { + if (config.SourceResultConfig is null) + { + return null; + } + var availableConfigs = currentChampSeason.Season.ChampSeasons.SelectMany(x => x.ResultConfigurations); + var sourceConfig = availableConfigs.FirstOrDefault(x => x.ResultConfigId == config.SourceResultConfigId) + ?? availableConfigs + .Where(x => x.Name == config.SourceResultConfig.Name) + .Where(x => x.ChampSeason.Championship.Name == config.SourceResultConfig.ChampSeason.Championship.Name) + .FirstOrDefault(); + return sourceConfig; + } + + private async Task> CopyResultConfigurationEntities(LeagueUser user, ChampSeasonEntity targetChampSeason, IEnumerable? prevResultConfigIds, + CancellationToken cancellationToken) + { + if (prevResultConfigIds is null) + { + return new List(); + } + + + var resultConfigs = await dbContext.ResultConfigurations + .Where(x => prevResultConfigIds.Contains(x.ResultConfigId)) + .Include(x => x.League) + .Include(x => x.ChampSeason) + .ThenInclude(x => x.Season) + .Include(x => x.ChampSeason) + .ThenInclude(x => x.Championship) + .Include(x => x.SourceResultConfig) + .ThenInclude(x => x.ChampSeason) + .ThenInclude(x => x.Championship) + .Include(x => x.PointFilters) + .Include(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .ThenInclude(x => x.AutoPenalties) + .Include(x => x.ResultFilters) + .ToListAsync(cancellationToken); + return resultConfigs.Select(x => CopyResultConfigurationEntity(user, targetChampSeason, x)).ToList(); + } + +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/PostChampionshipHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/PostChampionshipHandler.cs new file mode 100644 index 00000000..8fb5c4f4 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/PostChampionshipHandler.cs @@ -0,0 +1,36 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record PostChampionshipRequest(LeagueUser User, PostChampionshipModel Model) : IRequest; + +public sealed class PostChampionshipHandler : ChampionshipHandlerBase, + IRequestHandler +{ + public PostChampionshipHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PostChampionshipRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postChampionship = await CreateChampionshipEntityAsync(request.User, cancellationToken); + postChampionship = await MapToChampionshipEntityAsync(request.User, request.Model, postChampionship, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getChampionship = await MapToChampionshipModelAsync(postChampionship.ChampionshipId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getChampionship; + } + + private async Task CreateChampionshipEntityAsync(LeagueUser user, CancellationToken cancellationToken) + { + var league = await GetCurrentLeagueEntityAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var championship = CreateVersionEntity(user, new ChampionshipEntity()); + league.Championships.Add(championship); + dbContext.Championships.Add(championship); + return championship; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/PutChampSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/PutChampSeasonHandler.cs new file mode 100644 index 00000000..02b88987 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/PutChampSeasonHandler.cs @@ -0,0 +1,28 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record PutChampSeasonRequest(long ChampSeasonId, LeagueUser User, PutChampSeasonModel Model) : IRequest; + +public sealed class PutChampSeasonHandler : ChampSeasonHandlerBase, + IRequestHandler +{ + public PutChampSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(PutChampSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putChampSeason = await GetChampSeasonEntityAsync(request.ChampSeasonId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putChampSeason = await MapToChampSeasonEntityAsync(request.User, request.Model, putChampSeason, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getChampSeason = await MapToChampSeasonModel(putChampSeason.ChampSeasonId, cancellationToken) + ?? throw new InvalidOperationException("Updated resource not found"); + return getChampSeason; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Championships/PutChampionshipHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Championships/PutChampionshipHandler.cs new file mode 100644 index 00000000..eb4ad44d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Championships/PutChampionshipHandler.cs @@ -0,0 +1,27 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Championships; + +public record PutChampionshipRequest(long ChampionshipId, LeagueUser User, PutChampionshipModel Model) : IRequest; + +public sealed class PutChampionshipHandler : ChampionshipHandlerBase, + IRequestHandler +{ + public PutChampionshipHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutChampionshipRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putChampionship = await GetChampionshipEntityAsync(request.ChampionshipId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putChampionship = await MapToChampionshipEntityAsync(request.User, request.Model, putChampionship, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getChampionship = await MapToChampionshipModelAsync(request.ChampionshipId, cancellationToken) + ?? throw new InvalidOperationException("Updated resource was not found"); + return getChampionship; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Events/DeleteEventHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Events/DeleteEventHandler.cs new file mode 100644 index 00000000..4018c218 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Events/DeleteEventHandler.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Handlers.Events; + +public record DeleteEventRequest(long EventId) : IRequest; + +public sealed class DeleteEventHandler : EventHandlerBase, IRequestHandler +{ + public DeleteEventHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteEventRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteEvent = await GetEventEntityAsync(request.EventId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.Events + .Remove(deleteEvent); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Events/EventHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Events/EventHandlerBase.cs new file mode 100644 index 00000000..ca8bb011 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Events/EventHandlerBase.cs @@ -0,0 +1,166 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Events; + +public class EventHandlerBase : HandlerBase +{ + public EventHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetEventEntityAsync(long eventId, CancellationToken cancellationToken) + { + return await dbContext.Events + .Include(x => x.Sessions) + .Include(x => x.Track) + .Include(x => x.ResultConfigs) + .Where(x => x.EventId == eventId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task MapToEventEntityAsync(LeagueUser user, PostEventModel postEvent, EventEntity target, CancellationToken cancellationToken) + { + target.Date = postEvent.Date; + target.Duration = postEvent.Duration; + target.EventType = postEvent.EventType; + target.Name = postEvent.Name; + MapToSessionEntityCollection(user, postEvent.Sessions, target.Sessions); + target.Track = await GetTrackConfigEntityAsync(postEvent.TrackId, cancellationToken); + target.ResultConfigs = await GetResultConfigEntities(postEvent.ResultConfigs, cancellationToken); + return UpdateVersionEntity(user, target); + } + + protected virtual async Task MapToEventEntityAsync(LeagueUser user, PutEventModel putEvent, EventEntity target, CancellationToken cancellationToken) + { + return await MapToEventEntityAsync(user, (PostEventModel)putEvent, target, cancellationToken); + } + + protected virtual void MapToSessionEntityCollection(LeagueUser user, IEnumerable putSessions, + ICollection target) + { + List keepSubSessionIds = new List(); + foreach (var putSession in putSessions) + { + // try to find subsession in target collection + var sessionEntity = target + .FirstOrDefault(x => putSession.SessionId != 0 && x.SessionId == putSession.SessionId); + // create new subsession if no previous id was given + if (putSession.SessionId == 0) + { + sessionEntity = new SessionEntity(); + target.Add(sessionEntity); + } + if (sessionEntity == null) + { + throw new InvalidOperationException($"Error while mapping SessionEntities to Event: SessionId:{putSession.SessionId} does not exist in target collection Sessions"); + } + MapToSessionEntity(user, putSession, sessionEntity); + } + // remove subsessions that are not referenced + var removeSessions = target + .ExceptBy(putSessions.Select(x => x.SessionId), x => x.SessionId); + foreach (var removeSession in removeSessions) + { + target.Remove(removeSession); + } + } + + protected async Task> GetResultConfigEntities(IEnumerable resultConfigModels, CancellationToken cancellationToken) + { + var resultConfigIds = resultConfigModels.Select(x => x.ResultConfigId); + return await dbContext.ResultConfigurations + .Where(x => resultConfigIds.Contains(x.ResultConfigId)) + .ToListAsync(cancellationToken); + } + protected virtual SessionEntity MapToSessionEntity(LeagueUser user, PutSessionModel putSession, SessionEntity target) + { + target.Name = putSession.Name; + target.SessionType = putSession.SessionType; + target.SessionNr = putSession.SessionNr; + target.Laps = putSession.Laps; + target.Duration = putSession.Duration; + return UpdateVersionEntity(user, target); + } + + protected virtual async Task MapToEventModelAsync(long eventId, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var query = dbContext.Events + .Where(x => x.EventId == eventId) + .Select(MapToEventModelExpression(includeDetails)); + var sql = query.ToQueryString(); + return await query.FirstOrDefaultAsync(cancellationToken); + } + + protected virtual Expression> MapToEventModelExpression(bool includeDetails = false) => @event => new EventModel() + { + Date = TreatAsUTCDateTime(@event.Date), + Duration = @event.Duration, + EventType = @event.EventType, + Id = @event.EventId, + LeagueId = @event.LeagueId, + Name = @event.Name, + ScheduleId = @event.ScheduleId, + SeasonId = @event.Schedule.SeasonId, + HasResult = @event.ScoredEventResults.Any(), + TrackName = @event.Track.TrackGroup.TrackName, + ConfigName = @event.Track.ConfigName, + Sessions = @event.Sessions.Select(session => new SessionModel() + { + HasResult = session.SessionResult != null, + SessionNr = session.SessionNr, + LeagueId = session.LeagueId, + Name = session.Name, + Laps = session.Laps, + Duration = session.Duration, + SessionId = session.SessionId, + SessionType = session.SessionType, + CreatedOn = TreatAsUTCDateTime(session.CreatedOn), + CreatedByUserId = session.CreatedByUserId, + CreatedByUserName = session.CreatedByUserName, + LastModifiedOn = TreatAsUTCDateTime(session.LastModifiedOn), + LastModifiedByUserId = session.LastModifiedByUserId, + LastModifiedByUserName = session.LastModifiedByUserName + }).ToList(), + TrackId = @event.TrackId, + ResultConfigs = @event.ResultConfigs.Select(config => new ResultConfigInfoModel() + { + LeagueId = config.LeagueId, + ResultConfigId = config.ResultConfigId, + ChampSeasonId = config.ChampSeasonId, + ChampionshipName = config.ChampSeason.Championship.Name, + Name = config.Name, + DisplayName = config.DisplayName, + }).ToList(), + SimSessionDetails = (includeDetails == false || @event.SimSessionDetails.Any() == false) ? null : + @event.SimSessionDetails.Take(1).Select(details => new SimSessionDetailsModel() + { + EventAverageLap = details.EventAverageLap, + EndTime = details.EndTime, + EventLapsComplete = details.EventLapsComplete, + EventStrengthOfField = details.EventStrengthOfField, + Fog = details.Fog, + IRRaceWeek = details.IRRaceWeek, + IRSessionId = details.IRSessionId, + IRSubsessionId = details.IRSubsessionId, + LicenseCategory = details.LicenseCategory, + RelHumidity = details.RelHumidity, + SessionDetailsId = details.SessionDetailsId, + SessionName = details.SessionName, + SimStartUtcOffset = details.SimStartUtcOffset, + SimStartUtcTime = details.SimStartUtcTime, + Skies = details.Skies, + StartTime = details.StartTime, + TempUnits = details.TempUnits, + TempValue = details.TempValue, + TimeOfDay = details.TimeOfDay, + WeatherType = details.WeatherType, + WeatherVarInitial = details.WeatherVarInitial, + WeatherVarOngoing = details.WeatherVarOngoing, + WindDir = details.WindDir, + WindUnits = details.WindUnits, + }).First(), + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Events/GetEventHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Events/GetEventHandler.cs new file mode 100644 index 00000000..cd0f216b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Events/GetEventHandler.cs @@ -0,0 +1,21 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Events; + +public record GetEventRequest(long EventId, bool IncludeDetails) : IRequest; + +public sealed class GetEventHandler : EventHandlerBase, IRequestHandler +{ + public GetEventHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetEventRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getEvent = await MapToEventModelAsync(request.EventId, includeDetails: request.IncludeDetails, cancellationToken: cancellationToken) + ?? throw new ResourceNotFoundException(); + return getEvent; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Events/GetEventsFromScheduleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Events/GetEventsFromScheduleHandler.cs new file mode 100644 index 00000000..29599e9c --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Events/GetEventsFromScheduleHandler.cs @@ -0,0 +1,30 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Events; + +public record GetEventsFromScheduleRequest(long ScheduleId, bool IncludeDetails = false) : IRequest>; + +public sealed class GetEventsFromScheduleHandler : EventHandlerBase, + IRequestHandler> +{ + public GetEventsFromScheduleHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetEventsFromScheduleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getEvents = await MapToGetEventsFromScheduleAsync(request.ScheduleId, request.IncludeDetails, cancellationToken); + return getEvents; + } + + private async Task> MapToGetEventsFromScheduleAsync(long scheduleId, bool includeDetails = false, + CancellationToken cancellationToken = default) + { + return await dbContext.Events + .Where(x => x.ScheduleId == scheduleId) + .Select(MapToEventModelExpression(includeDetails)) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Events/GetEventsFromSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Events/GetEventsFromSeasonHandler.cs new file mode 100644 index 00000000..e1bfa81d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Events/GetEventsFromSeasonHandler.cs @@ -0,0 +1,30 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Events; + +public record GetEventsFromSeasonRequest(long SeasonId, bool IncludeDetails) : IRequest>; + +public sealed class GetEventsFromSeasonHandler : EventHandlerBase, + IRequestHandler> +{ + public GetEventsFromSeasonHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetEventsFromSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getEvents = await MapToEventsFromSeasonAsync(request.SeasonId, request.IncludeDetails, cancellationToken); + return getEvents; + } + + private async Task> MapToEventsFromSeasonAsync(long seasonId, bool includeDetails = false, + CancellationToken cancellationToken = default) + { + return await dbContext.Events + .Where(x => x.Schedule.SeasonId == seasonId) + .Select(MapToEventModelExpression(includeDetails)) + .ToListAsync(); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Events/PostEventToScheduleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Events/PostEventToScheduleHandler.cs new file mode 100644 index 00000000..deafbf1e --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Events/PostEventToScheduleHandler.cs @@ -0,0 +1,37 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Events; + +public record PostEventToScheduleRequest(long ScheduleId, LeagueUser User, PostEventModel Event) : IRequest; + +public sealed class PostEventToScheduleHandler : EventHandlerBase, IRequestHandler +{ + public PostEventToScheduleHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PostEventToScheduleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postEvent = await CreateEventOnScheduleAsync(request.User, request.ScheduleId, cancellationToken); + postEvent = await MapToEventEntityAsync(request.User, request.Event, postEvent, cancellationToken); + dbContext.Events.Add(postEvent); + await dbContext.SaveChangesAsync(); + var getEvent = await MapToEventModelAsync(postEvent.EventId, cancellationToken: cancellationToken) + ?? throw new ResourceNotFoundException(); + return getEvent; + } + + private async Task CreateEventOnScheduleAsync(LeagueUser user, long scheduleId, CancellationToken cancellationToken) + { + var schedule = await dbContext.Schedules + .Include(x => x.Events) + .SingleOrDefaultAsync(x => x.ScheduleId == scheduleId, cancellationToken) + ?? throw new ResourceNotFoundException(); + var @event = CreateVersionEntity(user, new EventEntity()); + schedule.Events.Add(@event); + return @event; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Events/PutEventHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Events/PutEventHandler.cs new file mode 100644 index 00000000..2c79da42 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Events/PutEventHandler.cs @@ -0,0 +1,26 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Events; + +public record PutEventRequest(long EventId, LeagueUser User, PutEventModel Event) : IRequest; + +public sealed class PutEventHandler : EventHandlerBase, IRequestHandler +{ + public PutEventHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutEventRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putEvent = await GetEventEntityAsync(request.EventId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putEvent = await MapToEventEntityAsync(request.User, request.Event, putEvent, cancellationToken); + dbContext.SaveChanges(); + var getEvent = await MapToEventModelAsync(putEvent.EventId, cancellationToken: cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getEvent; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/HandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/HandlerBase.cs new file mode 100644 index 00000000..860c2705 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/HandlerBase.cs @@ -0,0 +1,221 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Diagnostics.CodeAnalysis; + +namespace iRLeagueApiCore.Server.Handlers; + +public abstract class HandlerBase +{ + protected ILogger _logger; + protected LeagueDbContext dbContext; + protected IEnumerable> validators; + + protected HandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) + { + _logger = logger; + this.dbContext = dbContext; + this.validators = validators; + } + + protected virtual async Task GetCurrentLeagueEntityAsync(CancellationToken cancellationToken = default) + { + return await dbContext.Leagues + .FirstOrDefaultAsync(x => x.Id == dbContext.LeagueProvider.LeagueId, cancellationToken); + } + + protected virtual async Task GetLeagueEntityAsync(long leagueId, CancellationToken cancellationToken = default) + { + return await dbContext.Leagues + .IgnoreQueryFilters() + .FirstOrDefaultAsync(x => x.Id == leagueId, cancellationToken); + } + + protected virtual async Task GetScheduleEntityAsync(long? scheduleId, CancellationToken cancellationToken = default) + { + return await dbContext.Schedules + .FirstOrDefaultAsync(x => x.ScheduleId == scheduleId, cancellationToken); + } + + protected virtual async Task GetScoringEntityAsync(long? scoringId, CancellationToken cancellationToken = default) + { + return await dbContext.Scorings + .FirstOrDefaultAsync(x => x.ScoringId == scoringId, cancellationToken); + } + + protected virtual async Task GetSeasonEntityAsync(long? seasonId, CancellationToken cancellationToken = default) + { + return await dbContext.Seasons + .FirstOrDefaultAsync(x => x.SeasonId == seasonId, cancellationToken); + } + + protected virtual async Task GetTrackConfigEntityAsync(long? trackConfigId, CancellationToken cancellationToken = default) + { + return await dbContext.TrackConfigs + .FirstOrDefaultAsync(x => x.TrackId == trackConfigId, cancellationToken); + } + + protected virtual async Task GetMemberEntityAsync(long? memberId, CancellationToken cancellationToken = default) + { + return await dbContext.Members + .FirstOrDefaultAsync(x => x.Id == memberId, cancellationToken); + } + + protected virtual async Task GetTeamEntityAsync(long? teamId, CancellationToken cancellationToken = default) + { + return await dbContext.Teams + .FirstOrDefaultAsync(x => x.TeamId == teamId, cancellationToken); + } + + protected virtual async Task GetVoteCategoryEntityAsync(long leagueId, long? voteCategoryId, CancellationToken cancellationToken = default) + { + return await dbContext.VoteCategories + .FirstOrDefaultAsync(x => x.CatId == voteCategoryId, cancellationToken); + } + + protected virtual async Task> GetMemberListAsync(IEnumerable memberIds, CancellationToken cancellationToken = default) + { + return await dbContext.Members + .Where(x => memberIds.Contains(x.Id)) + .ToListAsync(cancellationToken); + } + + protected virtual async Task> GetTeamListAsync(IEnumerable teamIds, CancellationToken cancellationToken) + { + return await dbContext.Teams + .Where(x => teamIds.Contains(x.TeamId)) + .ToListAsync(cancellationToken); + } + + /// + /// Returns a utc date time from the provided datetime without performin a conversion + /// + /// + /// + [return: NotNullIfNotNull(nameof(dateTime))] + protected static DateTime? TreatAsUTCDateTime(DateTime? dateTime) + { + if (dateTime is null) + { + return null; + } + return new DateTime(dateTime!.Value.Ticks, DateTimeKind.Utc); + } + + protected virtual T CreateVersionEntity(LeagueUser user, T target) where T : IVersionEntity + { + target.CreatedOn = DateTime.UtcNow; + target.CreatedByUserId = user.Id; + target.CreatedByUserName = user.Name; + target.Version = 0; + return target; + } + + protected virtual T UpdateVersionEntity(LeagueUser user, T target) where T : IVersionEntity + { + target.LastModifiedOn = DateTime.UtcNow; + target.LastModifiedByUserId = user.Id; + target.LastModifiedByUserName = user.Name; + target.Version++; + return target; + } + + protected async Task> GetMemberSeasonStartIratingAsync(long seasonId, CancellationToken cancellationToken) + { + return (await dbContext.ResultRows + .Where(x => x.SubResult.Result.Event.Schedule.SeasonId == seasonId) + .OrderBy(x => x.SubResult.Result.Event.Date) + .Select(x => new { x.MemberId, x.OldIRating }) + .ToListAsync(cancellationToken)) + .DistinctBy(x => x.MemberId) + .ToDictionary(k => k.MemberId, k => k.OldIRating); + } + + protected static TimeSpan ParseTime(int value) => value < 0 ? TimeSpan.Zero : TimeSpan.FromSeconds(value / 10000D); + + protected static TimeSpan ParseTime(long value) => value < 0 ? TimeSpan.Zero : TimeSpan.FromSeconds(value / 10000D); + + protected static TimeSpan ParseInterval(int value, int completedLaps, int sessionLaps) + { + return ParseInterval(TimeSpan.FromSeconds(value / 10000D), completedLaps, sessionLaps); + } + + protected static TimeSpan ParseInterval(TimeSpan value, int completedLaps, int sessionLaps) + { + if (value > TimeSpan.Zero) + { + return value; + } + return TimeSpan.FromDays(sessionLaps - completedLaps); + } + + protected static (string, string) GetFirstnameLastname(string name) + { + var parts = name.Split(' ', 2); + var fullName = (parts[0], parts.ElementAt(1) ?? string.Empty); + return fullName; + } + + protected IEnumerable MapToSubSessions(IDictionary subResults, EventEntity @event, + ICollection<(int resultNr, int sessionNr)> map) + { + var mappedResults = new List(); + foreach ((var resultNr, var sessionNr) in map) + { + if (subResults.ContainsKey(resultNr) == false) + { + throw new InvalidOperationException($"Error while trying to map subResult Nr.{resultNr} to subSession Nr.{sessionNr}: no result with this subResultNr exists"); + } + var sessionResult = subResults[resultNr]; + var session = @event.Sessions + .SingleOrDefault(x => x.SessionNr == sessionNr) + ?? throw new InvalidOperationException($"Error while trying to map subResult Nr.{resultNr} to subSession Nr.{sessionNr}: no subSession with this subSessionNr exists"); + sessionResult.Session = session; + session.SessionResult = sessionResult; + mappedResults.Add(sessionResult); + } + return mappedResults; + } + + protected async Task> MapToFilterOptionListAsync(LeagueUser user, IEnumerable filterModels, + ICollection filterEntities, CancellationToken cancellationToken) + { + foreach (var filterModel in filterModels) + { + var filterOptionEntity = filterModel.FilterOptionId == 0 ? null : filterEntities + .FirstOrDefault(x => x.FilterOptionId == filterModel.FilterOptionId); + if (filterOptionEntity is null) + { + filterOptionEntity = CreateVersionEntity(user, new FilterOptionEntity()); + filterEntities.Add(filterOptionEntity); + filterOptionEntity.LeagueId = dbContext.LeagueProvider.LeagueId; + } + await MapToFilterOptionEntityAsync(user, filterModel, filterOptionEntity, cancellationToken); + } + var deleteFilterEntities = filterEntities + .Where(x => filterModels.Any(y => y.FilterOptionId == x.FilterOptionId) == false); + foreach (var deleteFilterEntity in deleteFilterEntities) + { + filterEntities.Remove(deleteFilterEntity); + } + return filterEntities; + } + + protected Task MapToFilterOptionEntityAsync(LeagueUser user, ResultFilterModel filterModel, FilterOptionEntity filterOptionEntity, + CancellationToken cancellationToken) + { + + filterOptionEntity.Conditions = new[] + { + new FilterConditionModel() + { + Comparator = filterModel.Condition.Comparator, + FilterType = filterModel.Condition.FilterType, + ColumnPropertyName = filterModel.Condition.ColumnPropertyName, + FilterValues = filterModel.Condition.FilterValues, + Action = filterModel.Condition.Action + } + }.ToList(); + UpdateVersionEntity(user, filterOptionEntity); + return Task.FromResult(filterOptionEntity); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Leagues/DeleteLeagueHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Leagues/DeleteLeagueHandler.cs new file mode 100644 index 00000000..767edca2 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Leagues/DeleteLeagueHandler.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Handlers.Leagues; + +public record DeleteLeagueRequest(long LeagueId) : IRequest; + +public sealed class DeleteLeagueHandler : LeagueHandlerBase, IRequestHandler +{ + public DeleteLeagueHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteLeagueRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + _logger.LogInformation("Deleted league id {LeagueId}", request.LeagueId); + var deleteLeague = await GetLeagueEntityAsync(request.LeagueId, cancellationToken) ?? throw new ResourceNotFoundException(); + dbContext.Remove(deleteLeague); + await dbContext.SaveChangesAsync(cancellationToken); + _logger.LogInformation("Deleted league {LeagueName} with league id {LeagueId} successfully", deleteLeague.Name, deleteLeague.Id); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Leagues/GetLeagueByNameHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Leagues/GetLeagueByNameHandler.cs new file mode 100644 index 00000000..c187f885 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Leagues/GetLeagueByNameHandler.cs @@ -0,0 +1,32 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Leagues; + +public sealed record GetLeagueByNameRequest(string LeagueName, bool IncludeSubscriptionDetails) : IRequest; + +public sealed class GetLeagueByNameHandler : LeagueHandlerBase, + IRequestHandler +{ + public GetLeagueByNameHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetLeagueByNameRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getLeague = await MapToLeagueModelFromName(request.LeagueName, request.IncludeSubscriptionDetails, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getLeague; + } + + private async Task MapToLeagueModelFromName(string leagueName, bool includeSubscriptionDetails, CancellationToken cancellationToken) + { + return await dbContext.Leagues + .IgnoreQueryFilters() + .Where(x => x.Name == leagueName) + .Select(MapToGetLeagueModelExpression(includeSubscriptionDetails)) + .FirstOrDefaultAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Leagues/GetLeagueHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Leagues/GetLeagueHandler.cs new file mode 100644 index 00000000..503f59a7 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Leagues/GetLeagueHandler.cs @@ -0,0 +1,21 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Leagues; + +public record GetLeagueRequest(long LeagueId, bool IncludeSubscriptionDetails) : IRequest; + +public sealed class GetLeagueHandler : LeagueHandlerBase, IRequestHandler +{ + public GetLeagueHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetLeagueRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getLeague = await MapToGetLeagueModelAsync(request.LeagueId, request.IncludeSubscriptionDetails, cancellationToken) ?? throw new ResourceNotFoundException(); + return getLeague; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Leagues/GetLeaguesHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Leagues/GetLeaguesHandler.cs new file mode 100644 index 00000000..76316e69 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Leagues/GetLeaguesHandler.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Leagues; + +public record GetLeaguesRequest(IEnumerable UserLeagues, bool IncludeHidden = false) : IRequest>; + +public sealed class GetLeaguesHandler : LeagueHandlerBase, IRequestHandler> +{ + public GetLeaguesHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetLeaguesRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getLeague = await MapToGetLeagueModelsAsync(request.UserLeagues, request.IncludeHidden, cancellationToken); + return getLeague; + } + + private async Task> MapToGetLeagueModelsAsync(IEnumerable userLeagues, bool includeHidden, CancellationToken cancellationToken) + { + return await dbContext.Leagues + .IgnoreQueryFilters() + .Where(x => userLeagues.Contains(x.Name) || x.LeaguePublic == Common.Enums.LeaguePublicSetting.PublicListed || includeHidden) + .Select(MapToGetLeagueModelExpression()) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Leagues/LeagueHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Leagues/LeagueHandlerBase.cs new file mode 100644 index 00000000..8ff6926c --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Leagues/LeagueHandlerBase.cs @@ -0,0 +1,81 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Leagues; + +public class LeagueHandlerBase : HandlerBase + +{ + public LeagueHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual LeagueEntity MapToLeagueEntity(LeagueUser user, PostLeagueModel postLeague, LeagueEntity leagueEntity) + { + leagueEntity.Name = postLeague.Name; + leagueEntity.NameFull = postLeague.NameFull; + leagueEntity.LeaguePublic = postLeague.LeaguePublic; + leagueEntity.Description = postLeague.Description; + leagueEntity.DescriptionPlain = postLeague.DescriptionPlain; + leagueEntity.ProtestFormAccess = postLeague.ProtestFormAccess; + leagueEntity.EnableLiveReviews = postLeague.EnableLiveReviews; + CreateVersionEntity(user, leagueEntity); + UpdateVersionEntity(user, leagueEntity); + return leagueEntity; + } + + protected virtual async Task MapToGetLeagueModelAsync(long leagueId, bool includeSubscriptionDetails, CancellationToken cancellationToken) + { + return await dbContext.Leagues + .IgnoreQueryFilters() + .Where(x => x.Id == leagueId) + .Select(MapToGetLeagueModelExpression(includeSubscriptionDetails)) + .SingleOrDefaultAsync(cancellationToken); + } + + protected Expression> MapToGetLeagueModelExpression(bool includeSubscriptionDetails = false) => x => new LeagueModel() + { + Id = x.Id, + Name = x.Name, + NameFull = x.NameFull, + Description = x.Description, + DescriptionPlain = x.DescriptionPlain, + IsInitialized = x.IsInitialized, + EnableProtests = x.EnableProtests, + EnableLiveReviews = x.EnableLiveReviews, + ProtestCoolDownPeriod = x.ProtestCoolDownPeriod, + ProtestsClosedAfter = x.ProtestsClosedAfter, + ProtestFormAccess = x.ProtestFormAccess, + ProtestsPublic = x.ProtestsPublic, + SeasonIds = x.Seasons + .Select(season => season.SeasonId) + .ToList(), + CreatedByUserId = x.CreatedByUserId, + CreatedByUserName = x.CreatedByUserName, + CreatedOn = TreatAsUTCDateTime(x.CreatedOn), + LastModifiedByUserId = x.LastModifiedByUserId, + LastModifiedByUserName = x.LastModifiedByUserName, + LastModifiedOn = TreatAsUTCDateTime(x.LastModifiedOn), + LeaguePublic = x.LeaguePublic, + SubscriptionStatus = includeSubscriptionDetails ? x.Subscription : default, + SubscriptionExpires = includeSubscriptionDetails ? x.Expires : default, + }; + + protected virtual LeagueEntity MapToLeagueEntity(long leagueId, LeagueUser user, PutLeagueModel putLeague, LeagueEntity leagueEntity) + { + leagueEntity.NameFull = putLeague.NameFull; + leagueEntity.Description = putLeague.Description; + leagueEntity.DescriptionPlain = putLeague.DescriptionPlain; + leagueEntity.EnableProtests = putLeague.EnableProtests; + leagueEntity.ProtestCoolDownPeriod = putLeague.ProtestCoolDownPeriod; + leagueEntity.ProtestsClosedAfter = putLeague.ProtestsClosedAfter; + leagueEntity.ProtestsPublic = putLeague.ProtestsPublic; + leagueEntity.LeaguePublic = putLeague.LeaguePublic; + leagueEntity.ProtestFormAccess = putLeague.ProtestFormAccess; + leagueEntity.EnableLiveReviews = putLeague.EnableLiveReviews; + UpdateVersionEntity(user, leagueEntity); + return leagueEntity; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Leagues/PostInitializeLeagueHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Leagues/PostInitializeLeagueHandler.cs new file mode 100644 index 00000000..ad286e7f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Leagues/PostInitializeLeagueHandler.cs @@ -0,0 +1,28 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Leagues; + +public record PostIntitializeLeagueRequest(long LeagueId) : IRequest; + +public class PostInitializeLeagueHandler : LeagueHandlerBase, + IRequestHandler +{ + public PostInitializeLeagueHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PostIntitializeLeagueRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var league = await GetLeagueEntityAsync(request.LeagueId, cancellationToken) + ?? throw new ResourceNotFoundException(); + league.IsInitialized = true; + await dbContext.SaveChangesAsync(cancellationToken); + var getLeague = await MapToGetLeagueModelAsync(request.LeagueId, true, cancellationToken) + ?? throw new InvalidOperationException("Updated resource not found"); + return getLeague; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Leagues/PostLeagueHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Leagues/PostLeagueHandler.cs new file mode 100644 index 00000000..668082b2 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Leagues/PostLeagueHandler.cs @@ -0,0 +1,71 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Leagues; + +public record PostLeagueRequest(LeagueUser User, PostLeagueModel Model) : IRequest; + +public sealed class PostLeagueHandler : LeagueHandlerBase, IRequestHandler +{ + private readonly UserManager userManager; + private readonly RoleManager roleManager; + + public PostLeagueHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators, UserManager userManager, + RoleManager roleManager) + : base(logger, dbContext, validators) + { + this.userManager = userManager; + this.roleManager = roleManager; + } + + public async Task Handle(PostLeagueRequest request, CancellationToken cancellationToken = default) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + _logger.LogInformation("Create league {LeagueName}", request.Model.Name); + var leagueEntity = MapToLeagueEntity(request.User, request.Model, new LeagueEntity()); + dbContext.Leagues.Add(leagueEntity); + if (await AssignOwnerRole(request.User, leagueEntity.Name) == false) + { + throw new InvalidOperationException("Failed to add owner rule to user. Aborting league creation"); + } + await dbContext.SaveChangesAsync(cancellationToken); + _logger.LogInformation("League {LeagueName} successfully created", request.Model.Name); + var getLeague = await MapToGetLeagueModelAsync(leagueEntity.Id, true, cancellationToken) + ?? throw new ResourceNotFoundException("Created resource not found!"); + return getLeague; + } + + /// + /// Assign the owner role to the new created league + /// + /// + /// + /// when role was assigned successfully; if role was not assigned + public async Task AssignOwnerRole(LeagueUser user, string leagueName) + { + // create owner role if not exists + var ownerRole = LeagueRoles.GetLeagueRoleName(leagueName, LeagueRoles.Owner); + if (await roleManager.RoleExistsAsync(ownerRole) == false) + { + var createdRole = await roleManager.CreateAsync(new(ownerRole)); + if (createdRole is null) + { + return false; + } + } + var applicationUser = await userManager.FindByIdAsync(user.Id); + if (applicationUser is null) + { + return false; + } + if (await userManager.IsInRoleAsync(applicationUser, ownerRole)) + { + return true; + } + var result = await userManager.AddToRoleAsync(applicationUser, ownerRole); + return result.Succeeded; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Leagues/PutLeagueHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Leagues/PutLeagueHandler.cs new file mode 100644 index 00000000..f12ab6e3 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Leagues/PutLeagueHandler.cs @@ -0,0 +1,25 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Leagues; + +public record PutLeagueRequest(long LeagueId, LeagueUser User, PutLeagueModel Model) : IRequest; + +public sealed class PutLeagueHandler : LeagueHandlerBase, IRequestHandler +{ + public PutLeagueHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutLeagueRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putLeague = await GetLeagueEntityAsync(request.LeagueId, cancellationToken) ?? throw new ResourceNotFoundException(); + MapToLeagueEntity(request.LeagueId, request.User, request.Model, putLeague); + await dbContext.SaveChangesAsync(cancellationToken); + var getLeague = await MapToGetLeagueModelAsync(putLeague.Id, true, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getLeague; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Members/GetMembersFromEventHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Members/GetMembersFromEventHandler.cs new file mode 100644 index 00000000..2407d466 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Members/GetMembersFromEventHandler.cs @@ -0,0 +1,44 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Members; + +public record GetMembersFromEventRequest(long EventId) : IRequest>; + +public sealed class GetMembersFromEventHandler : MembersHandlerBase, + IRequestHandler> +{ + public GetMembersFromEventHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetMembersFromEventRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getMembers = await GetMembersFromEvent(request.EventId, cancellationToken); + return getMembers; + } + + private async Task> GetMembersFromEvent(long eventId, CancellationToken cancellationToken) + { + var resultMembers = await dbContext.EventResults + .Where(x => x.EventId == eventId) + .Select(x => x.SessionResults + .SelectMany(y => y.ResultRows) + .Select(y => y.MemberId)) + .SelectMany(x => x!) + .ToListAsync(cancellationToken); + var scoredResultMembers = await dbContext.ScoredEventResults + .Where(x => x.EventId == eventId) + .Select(x => x.ScoredSessionResults + .SelectMany(y => y.ScoredResultRows) + .Where(y => y.MemberId != null) + .Select(y => y.MemberId.GetValueOrDefault())) + .SelectMany(x => x) + .ToListAsync(cancellationToken); + var memberIds = resultMembers + .Concat(scoredResultMembers) + .Distinct(); + + return await MapToMemberListAsync(memberIds, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Members/GetMembersFromLeagueHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Members/GetMembersFromLeagueHandler.cs new file mode 100644 index 00000000..70694426 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Members/GetMembersFromLeagueHandler.cs @@ -0,0 +1,27 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Members; + +public record GetMembersFromLeagueRequest() : IRequest>; + +public sealed class GetMembersFromLeagueHandler : MembersHandlerBase, + IRequestHandler> +{ + public GetMembersFromLeagueHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetMembersFromLeagueRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getMembers = await MapToMemberModels(cancellationToken); + return getMembers; + } + + private async Task> MapToMemberModels(CancellationToken cancellationToken) + { + return await dbContext.LeagueMembers + .Select(MapToMemberModelExpression) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Members/MembersHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Members/MembersHandlerBase.cs new file mode 100644 index 00000000..c36d3e03 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Members/MembersHandlerBase.cs @@ -0,0 +1,36 @@ +using iRLeagueApiCore.Common.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Members; + +public class MembersHandlerBase : HandlerBase +{ + public MembersHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected async Task> MapToMemberListAsync(IEnumerable memberIds, CancellationToken cancellationToken) + { + return await dbContext.LeagueMembers + .Where(x => memberIds.Contains(x.MemberId)) + .Select(MapToMemberModelExpression) + .ToListAsync(cancellationToken); + } + + protected Expression> MapToMemberInfoExpression => member => new() + { + MemberId = member.Id, + FirstName = member.Firstname, + LastName = member.Lastname, + }; + + protected Expression> MapToMemberModelExpression => member => new() + { + MemberId = member.Member.Id, + FirstName = member.Member.Firstname, + LastName= member.Member.Lastname, + IRacingId = member.Member.IRacingId, + TeamName = member.Team == null ? string.Empty : member.Team.Name, + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/DeleteResultConfigHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/DeleteResultConfigHandler.cs new file mode 100644 index 00000000..7ddb3ae6 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/DeleteResultConfigHandler.cs @@ -0,0 +1,25 @@ +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record DeleteResultConfigRequest(long ResultConfigId) : IRequest; + +public sealed class DeleteResultConfigHandler : ResultConfigHandlerBase, + IRequestHandler +{ + public DeleteResultConfigHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteResultConfigRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteResultConfig = await GetResultConfigEntity(request.ResultConfigId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.ResultConfigurations.Remove(deleteResultConfig); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/DeleteResultHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/DeleteResultHandler.cs new file mode 100644 index 00000000..1824025b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/DeleteResultHandler.cs @@ -0,0 +1,43 @@ +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record DeleteResultRequest(long EventId) : IRequest; + +public sealed class DeleteResultHandler : ResultHandlerBase, + IRequestHandler +{ + public DeleteResultHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteResultRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteEventResults = await GetScoredEventResults(request.EventId, cancellationToken); + var deleteStandings = await GetEventStandings(request.EventId, cancellationToken); + foreach (var result in deleteEventResults) + { + dbContext.ScoredEventResults.Remove(result); + } + foreach (var standing in deleteStandings) + { + dbContext.Standings.Remove(standing); + } + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } + + private async Task> GetScoredEventResults(long eventId, CancellationToken cancellationToken) + { + return await dbContext.ScoredEventResults + .Where(x => x.EventId == eventId) + .ToListAsync(cancellationToken); + } + + private async Task> GetEventStandings(long eventId, CancellationToken cancellationToken) + { + return await dbContext.Standings + .Where(x => x.EventId == eventId) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/FetchResultsFromIRacingAPIHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/FetchResultsFromIRacingAPIHandler.cs new file mode 100644 index 00000000..6c7588bc --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/FetchResultsFromIRacingAPIHandler.cs @@ -0,0 +1,296 @@ +using Aydsko.iRacingData; +using Aydsko.iRacingData.Results; +using iRLeagueApiCore.Client.ResultsParsing; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Excecution; +using System.Net; +using System.Transactions; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record FetchResultsFromIRacingAPIRequest(long EventId, int IRSubsessionId) : IRequest; + +public class FetchResultsFromIRacingAPIHandler : HandlerBase, + IRequestHandler +{ + private readonly ICredentials credentials; + private readonly IDataClient iRDataClient; + private IDictionary SeasonStartIratings; + private readonly IResultCalculationQueue calculationQueue; + + public FetchResultsFromIRacingAPIHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators, ICredentials credentials, IDataClient iRDataClient, IResultCalculationQueue calculationQueue) + : base(logger, dbContext, validators) + { + this.credentials = credentials; + this.iRDataClient = iRDataClient; + SeasonStartIratings = new Dictionary(); + this.calculationQueue = calculationQueue; + } + + public async Task Handle(FetchResultsFromIRacingAPIRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var @event = await GetResultEventEntityAsync(request.EventId, cancellationToken) + ?? throw new ResourceNotFoundException(); + SeasonStartIratings = await GetMemberSeasonStartIratingAsync(@event.Schedule.SeasonId, cancellationToken); + var credential = credentials.GetCredential(new Uri("https://members-ng.iracing.com/auth"), "Token") + ?? throw new InvalidOperationException("Could not find credentials for iracing service - check configuration"); + iRDataClient.UseUsernameAndPassword(credential.UserName, credential.Password); + var resultResponse = await iRDataClient.GetSubSessionResultAsync(request.IRSubsessionId, true, cancellationToken); + var resultData = resultResponse.Data; + using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + if (@event.EventResult is not null) + { + dbContext.Remove(@event.EventResult); + } + @event.SimSessionDetails.Clear(); + await dbContext.SaveChangesAsync(cancellationToken); + var result = await ReadResultsAsync(resultData, @event, cancellationToken); + @event.EventResult = result; + await dbContext.SaveChangesAsync(cancellationToken); + tx.Complete(); + } + // Queue result calculation for this event + await calculationQueue.QueueEventResultAsync(@event.EventId); + + return true; + } + + private async Task ReadResultsAsync(SubSessionResult data, EventEntity @event, + CancellationToken cancellationToken) + { + var map = CreateSessionMapping(data.SessionResults, @event); + // create entities + var result = @event.EventResult ?? new EventResultEntity(); + result.Event = @event; + var details = ReadDetails(data); + details.Event = @event; + IDictionary sessionResults = new Dictionary(); + foreach (var sessionResultData in data.SessionResults) + { + var sessionResult = await ReadSessionResultsAsync(@event.LeagueId, data, sessionResultData, details, cancellationToken); + sessionResults.Add(sessionResult); + } + var mappedSessionResults = MapToSubSessions(sessionResults, @event, map); + foreach (var subResult in mappedSessionResults) + { + result.SessionResults.Add(subResult); + } + return result; + } + + private static ICollection<(int resultNr, int sessionNr)> CreateSessionMapping(IEnumerable sessionResults, EventEntity @event) + { + var map = new List<(int resultNr, int sessionNr)>(); + + var practiceSessionTypes = new[] { SimSessionType.OpenPractice }.Cast(); + var practiceSession = @event.Sessions + .FirstOrDefault(x => x.SessionType == SessionType.Practice); + var practiceResult = sessionResults + .FirstOrDefault(x => practiceSessionTypes.Contains(x.SimSessionType) && x.SimSessionName == "PRACTICE"); + if (practiceSession is not null && practiceResult is not null) + { + map.Add((practiceResult.SimSessionNumber, practiceSession.SessionNr)); + } + + var qualySessionTypes = new[] { SimSessionType.LoneQualifying, SimSessionType.OpenQualifying }.Cast(); + var qualySession = @event.Sessions + .FirstOrDefault(x => x.SessionType == SessionType.Qualifying); + var qualyResult = sessionResults + .FirstOrDefault(x => qualySessionTypes.Contains(x.SimSessionType)); + if (qualySession is not null && qualyResult is not null) + { + map.Add((qualyResult.SimSessionNumber, qualySession.SessionNr)); + } + + var raceSessionTypes = new[] { SimSessionType.Race }.Cast(); + var raceSessions = @event.Sessions + .OrderBy(x => x.SessionNr) + .Where(x => x.SessionType == SessionType.Race); + var raceResults = sessionResults + .Where(x => raceSessionTypes.Contains(x.SimSessionType)); + foreach ((var session, var result) in raceSessions.Zip(raceResults)) + { + if (session is not null && result is not null) + { + map.Add((result.SimSessionNumber, session.SessionNr)); + } + } + + return map; + } + + private async Task GetOrCreateMemberAsync(long leagueId, Result row, CancellationToken cancellationToken) + { + var leagueMember = await dbContext.LeagueMembers + .Include(x => x.Team) + .Include(x => x.Member) + .Where(x => x.LeagueId == leagueId) + .Where(x => x.Member.IRacingId == row.CustomerId.ToString()) + .SingleOrDefaultAsync(cancellationToken) + ?? dbContext.LeagueMembers.Local + .SingleOrDefault(x => x.Member.IRacingId == row.CustomerId.ToString()); + if (leagueMember == null) + { + var league = await dbContext.Leagues + .FirstAsync(x => x.Id == leagueId); + var (firstname, lastname) = GetFirstnameLastname(row.DisplayName ?? string.Empty); + var member = new MemberEntity() + { + Firstname = firstname, + Lastname = lastname, + IRacingId = row.CustomerId.ToString(), + }; + leagueMember = new LeagueMemberEntity() + { + Member = member, + League = league, + }; + dbContext.LeagueMembers.Add(leagueMember); + } + else + { + // update member name + var (firstname, lastname) = GetFirstnameLastname(row.DisplayName ?? string.Empty); + leagueMember.Member.Firstname = firstname; + leagueMember.Member.Lastname = lastname; + } + return leagueMember; + } + + private async Task> ReadSessionResultsAsync(long leagueId, SubSessionResult sessionData, SessionResults data, + IRSimSessionDetailsEntity details, CancellationToken cancellationToken) + { + var sessionResult = new SessionResultEntity(); + sessionResult.LeagueId = leagueId; + sessionResult.IRSimSessionDetails = details; + sessionResult.SimSessionType = (SimSessionType)data.SimSessionType; + var laps = data.Results.Max(x => x.LapsComplete); + var resultRows = new List(); + foreach (var row in data.Results) + { + resultRows.Add(await ReadResultRowAsync(leagueId, sessionData, row, laps, cancellationToken)); + } + sessionResult.ResultRows = resultRows; + var sessionResultNr = data.SimSessionNumber; + return new KeyValuePair(sessionResultNr, sessionResult); + } + + private async Task ReadResultRowAsync(long leagueId, SubSessionResult sessionData, Result data, + int laps, CancellationToken cancellationToken) + { + var row = new ResultRowEntity(); + var leagueMember = await GetOrCreateMemberAsync(leagueId, data, cancellationToken); + row.LeagueId = leagueId; + row.AvgLapTime = data.AverageLap ?? TimeSpan.Zero; + //row.Car = FIXME is this data important?? + row.CarClass = sessionData.CarClasses.FirstOrDefault(x => x.CarClassId == data.CarClassId)?.ShortName ?? string.Empty; + row.CarId = data.CarId; + row.CarNumber = data.Livery.CarNumber ?? string.Empty; + row.ClassId = data.CarClassId; + row.ClubId = data.ClubId; + row.ClubName = data.ClubName; + row.CompletedLaps = data.LapsComplete; + row.CompletedPct = laps != 0 ? data.LapsComplete / (double)laps : 0; + row.ContactLaps = ""; + row.Division = data.Division; + row.FastestLapTime = data.BestLapTime ?? TimeSpan.Zero; + row.FastLapNr = data.BestLapNumber; + row.FinishPosition = data.Position + 1; + row.Incidents = data.Incidents; + row.Interval = ParseInterval(data.Interval ?? TimeSpan.Zero, data.LapsComplete, laps); + row.IRacingId = data.CustomerId.ToString(); + row.LeadLaps = data.LapsLead; + row.License = sessionData.LicenseCategory; + row.Member = leagueMember.Member; + row.NewCpi = (int)data.NewCornersPerIncident; + row.NewIRating = data.NewIRating; + row.NewLicenseLevel = data.NewLicenseLevel; + row.NewSafetyRating = data.NewSubLevel; + row.NumContactLaps = -1; + row.NumOfftrackLaps = -1; + row.NumPitStops = -1; + row.OfftrackLaps = ""; + row.OldCpi = (int)data.OldCornersPerIncident; + row.OldIRating = data.OldIRating; + row.OldLicenseLevel = data.OldLicenseLevel; + row.OldSafetyRating = data.OldSubLevel; + row.PittedLaps = ""; + row.PointsEligible = true; + row.PositionChange = data.Position - data.StartingPosition; + row.QualifyingTime = data.BestQualifyingLapTime ?? TimeSpan.Zero; + row.QualifyingTimeAt = data.BestQualifyingLapAt?.UtcDateTime; + row.SimSessionType = -1; + row.StartPosition = data.StartingPosition + 1; + row.Status = data.ReasonOutId; + row.Team = leagueMember.Team; + row.RacePoints = data.ChampPoints; + row.SeasonStartIRating = SeasonStartIratings.TryGetValue(row.Member.Id, out int irating) ? irating : row.OldIRating; + + return row; + } + + private IRSimSessionDetailsEntity ReadDetails(SubSessionResult data) + { + var details = new IRSimSessionDetailsEntity(); + + details.IRSessionId = data.SessionId; + details.IRSubsessionId = data.SubSessionId; + details.IRTrackId = data.Track.TrackId; + details.ConfigName = data.Track.ConfigName; + details.Category = data.Track.Category; + details.CornersPerLap = data.CornersPerLap; + details.NumCautionLaps = data.NumberOfCautionLaps; + details.NumCautions = data.NumberOfCautions; + details.NumLeadChanges = data.NumberOfLeadChanges; + details.WarmupRubber = data.TrackState.WarmupRubber; + details.RaceRubber = data.TrackState.RaceRubber; + details.DamageModel = data.DamageModel; + details.EndTime = data.EndTime.UtcDateTime; + details.EventAverageLap = ParseTime(data.EventAverageLap); + details.EventLapsComplete = data.EventLapsComplete; + details.EventStrengthOfField = data.EventStrengthOfField; + details.Fog = data.Weather.Fog; + details.IRRaceWeek = data.RaceWeekNumber; + details.IRSeasonId = data.SeasonId; + details.IRSeasonName = data.SeasonName; + details.IRSeasonQuarter = data.SeasonQuarter; + details.IRSeasonYear = data.SeasonYear; + details.KmDistPerLap = 0; + details.LeagueId = data.LeagueId ?? 0; + details.LeaveMarbles = data.TrackState.LeaveMarbles; + details.LicenseCategory = data.LicenseCategoryId; + details.PracticeGripCompound = data.TrackState.PracticeGripCompound; + details.PracticeRubber = data.TrackState.PracticeRubber; + details.QualifyGripCompund = data.TrackState.QualifyGripCompound; + details.QualifyRubber = data.TrackState.QualifyRubber; + details.RaceGripCompound = data.TrackState.RaceGripCompound; + details.RaceRubber = data.TrackState.RaceRubber; + details.RelHumidity = data.Weather.RelHumidity; + details.SessionName = data.SeasonName; + details.SimStartUtcOffset = ParseTime(data.Weather.SimulatedStartUtcOffset); + details.SimStartUtcTime = data.Weather.SimulatedStartUtcTime.UtcDateTime; + details.Skies = data.Weather.Skies; + details.StartTime = data.StartTime.UtcDateTime; + details.TempUnits = data.Weather.TempUnits; + details.TempValue = data.Weather.TempValue; + details.TimeOfDay = data.Weather.TimeOfDay; + details.TrackName = data.Track.TrackName; + return details; + } + + private async Task GetResultEventEntityAsync(long eventId, CancellationToken cancellationToken) + { + return await dbContext.Events + .Include(x => x.Schedule) + .Include(x => x.Sessions) + .Include(x => x.EventResult) + .ThenInclude(x => x.SessionResults) + .ThenInclude(x => x.IRSimSessionDetails) + .Include(x => x.SimSessionDetails) + .Where(x => x.EventId == eventId) + .FirstOrDefaultAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/GetLatestResultHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/GetLatestResultHandler.cs new file mode 100644 index 00000000..5774bee0 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/GetLatestResultHandler.cs @@ -0,0 +1,32 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record GetLatestResultRequest() : IRequest>; + +public class GetLatestResultHandler : ResultHandlerBase, IRequestHandler> +{ + public GetLatestResultHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetLatestResultRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var latestEventWithResult = await GetLatestEventWithResult(cancellationToken); + if (latestEventWithResult is null) + { + return Array.Empty(); + } + var getResult = await MapToGetResultModelsFromEventAsync(latestEventWithResult.EventId, cancellationToken); + return getResult; + } + + private async Task GetLatestEventWithResult(CancellationToken cancellationToken) + { + return await dbContext.Events + .Where(x => x.ScoredEventResults.Any()) + .OrderBy(x => x.Date) + .LastOrDefaultAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/GetResultConfigHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultConfigHandler.cs new file mode 100644 index 00000000..eddcb308 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultConfigHandler.cs @@ -0,0 +1,24 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record GetResultConfigRequest(long ResultConfigId) : IRequest; + +public sealed class GetResultConfigHandler : ResultConfigHandlerBase, + IRequestHandler +{ + public GetResultConfigHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(GetResultConfigRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getResultConfig = await MapToResultConfigModel(request.ResultConfigId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getResultConfig; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/GetResultConfigsFromLeagueHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultConfigsFromLeagueHandler.cs new file mode 100644 index 00000000..1443b764 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultConfigsFromLeagueHandler.cs @@ -0,0 +1,30 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record GetResultConfigsFromLeagueRequest() : IRequest>; + +public sealed class GetResultConfigsFromLeagueHandler : ResultConfigHandlerBase, + IRequestHandler> +{ + public GetResultConfigsFromLeagueHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetResultConfigsFromLeagueRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getResults = await MapToGetResultConfigsFromLeagueAsync(cancellationToken); + return getResults; + } + + private async Task> MapToGetResultConfigsFromLeagueAsync(CancellationToken cancellationToken) + { + return await dbContext.ResultConfigurations + .Select(MapToResultConfigModelExpression) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/GetResultConfigsFromSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultConfigsFromSeasonHandler.cs new file mode 100644 index 00000000..882f795c --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultConfigsFromSeasonHandler.cs @@ -0,0 +1,33 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record GetResultConfigsFromSeasonRequest(long SeasonId) : IRequest>; + +public class GetResultConfigsFromSeasonHandler : ResultConfigHandlerBase, + IRequestHandler> +{ + public GetResultConfigsFromSeasonHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetResultConfigsFromSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var configs = await GetResultConfigsFromSeasonAsync(request.SeasonId, cancellationToken); + return configs; + } + + private async Task> GetResultConfigsFromSeasonAsync(long seasonId, CancellationToken cancellationToken) + { + return await dbContext.ChampSeasons + .Where(x => x.SeasonId == seasonId) + .Where(x => x.IsActive) + .SelectMany(x => x.ResultConfigurations) + .Select(MapToResultConfigModelExpression) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/GetResultHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultHandler.cs new file mode 100644 index 00000000..1db87212 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultHandler.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record GetResultRequest(long ResultId) : IRequest; + +public sealed class GetResultHandler : ResultHandlerBase, IRequestHandler +{ + public GetResultHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetResultRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getResult = await MapToEventResultModelAsync(request.ResultId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getResult; + } + + private async Task MapToEventResultModelAsync(long resultId, CancellationToken cancellationToken) + { + return await dbContext.ScoredEventResults + .Where(x => x.ResultId == resultId) + .Select(MapToEventResultModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/GetResultsFromSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultsFromSeasonHandler.cs new file mode 100644 index 00000000..a4793c01 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultsFromSeasonHandler.cs @@ -0,0 +1,44 @@ +using iRLeagueApiCore.Common.Models; +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record GetResultsFromSeasonRequest(long SeasonId) : IRequest>; + +public sealed class GetResultsFromSeasonHandler : ResultHandlerBase, + IRequestHandler> +{ + public GetResultsFromSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetResultsFromSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getResults = await MapToGetResultModelsFromSeasonAsync(request.SeasonId, cancellationToken); + if (getResults.Count() == 0) + { + throw new ResourceNotFoundException(); + } + return getResults; + } + + private async Task> MapToGetResultModelsFromSeasonAsync(long seasonId, CancellationToken cancellationToken) + { + var seasonResults = await dbContext.ScoredEventResults + .Where(x => x.Event.Schedule.SeasonId == seasonId) + .OrderBy(x => x.Event.Date) + .Select(MapToEventResultModelExpression) + .ToListAsync(cancellationToken); + + var groupedResults = seasonResults.GroupBy(x => x.EventId); + var seasonEventResults = groupedResults.Select(x => new SeasonEventResultModel() + { + EventId = x.Key, + EventName = x.FirstOrDefault()?.EventName ?? string.Empty, + ConfigName = x.FirstOrDefault()?.ConfigName ?? string.Empty, + TrackName = x.FirstOrDefault()?.TrackName ?? string.Empty, + EventResults = x, + }).ToList(); + return seasonEventResults; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/GetResultsFromSessionHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultsFromSessionHandler.cs new file mode 100644 index 00000000..3ad3ab37 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/GetResultsFromSessionHandler.cs @@ -0,0 +1,25 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record GetResultsFromEventRequest(long EventId) : IRequest>; + +public sealed class GetResultsFromSessionHandler : ResultHandlerBase, + IRequestHandler> +{ + public GetResultsFromSessionHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetResultsFromEventRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getResults = await MapToGetResultModelsFromEventAsync(request.EventId, cancellationToken); + if (getResults.Count() == 0) + { + throw new ResourceNotFoundException(); + } + return getResults; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/PostResultConfigToChampSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/PostResultConfigToChampSeasonHandler.cs new file mode 100644 index 00000000..718aae21 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/PostResultConfigToChampSeasonHandler.cs @@ -0,0 +1,39 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record PostResultConfigToChampSeasonRequest(long ChampSeasonId, LeagueUser User, PostResultConfigModel Model) : IRequest; + +public sealed class PostResultConfigToChampSeasonHandler : ResultConfigHandlerBase, + IRequestHandler +{ + public PostResultConfigToChampSeasonHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PostResultConfigToChampSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postResultConfig = await CreateResultConfigEntity(request.ChampSeasonId, request.User, cancellationToken); + postResultConfig = await MapToResultConfigEntityAsync(request.User, request.Model, postResultConfig, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getResultConfig = await MapToResultConfigModel(postResultConfig.ResultConfigId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getResultConfig; + } + + private async Task CreateResultConfigEntity(long champSeasonId, LeagueUser user, CancellationToken cancellationToken) + { + var champSeason = await dbContext.ChampSeasons + .Where(x => x.ChampSeasonId == champSeasonId) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var resultConfig = CreateVersionEntity(user, new ResultConfigurationEntity()); + champSeason.ResultConfigurations.Add(resultConfig); + return await Task.FromResult(resultConfig); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/PutResultConfigHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/PutResultConfigHandler.cs new file mode 100644 index 00000000..7d5ddeb5 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/PutResultConfigHandler.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record PutResultConfigRequest(long ResultConfigId, LeagueUser User, PutResultConfigModel Model) : IRequest; + +public sealed class PutResultConfigHandler : ResultConfigHandlerBase, + IRequestHandler +{ + public PutResultConfigHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(PutResultConfigRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putResultConfig = await GetResultConfigEntity(request.ResultConfigId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putResultConfig = await MapToResultConfigEntityAsync(request.User, request.Model, putResultConfig, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getResultConfig = await MapToResultConfigModel(putResultConfig.ResultConfigId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getResultConfig; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/ResultConfigHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Results/ResultConfigHandlerBase.cs new file mode 100644 index 00000000..f9d0ca3d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/ResultConfigHandlerBase.cs @@ -0,0 +1,274 @@ +using Castle.Components.DictionaryAdapter.Xml; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore; +using System.Linq.Expressions; +using static Org.BouncyCastle.Math.EC.ECCurve; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public class ResultConfigHandlerBase : HandlerBase +{ + public ResultConfigHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetResultConfigEntity(long resultConfigId, CancellationToken cancellationToken) + { + return await dbContext.ResultConfigurations + .Include(x => x.ChampSeason) + .Include(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .ThenInclude(x => x.AutoPenalties) + .Include(x => x.SourceResultConfig) + .Include(x => x.ResultFilters) + .Include(x => x.PointFilters) + .Where(x => x.ResultConfigId == resultConfigId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task MapToResultConfigEntityAsync(LeagueUser user, PostResultConfigModel postResultConfig, + ResultConfigurationEntity resultConfigEntity, CancellationToken cancellationToken) + { + resultConfigEntity.DisplayName = postResultConfig.DisplayName; + resultConfigEntity.SourceResultConfig = postResultConfig.SourceResultConfig != null + ? await dbContext.ResultConfigurations + .FirstOrDefaultAsync(x => x.ResultConfigId == postResultConfig.SourceResultConfig.ResultConfigId, cancellationToken) + : null; + resultConfigEntity.Name = postResultConfig.Name; + resultConfigEntity.ResultsPerTeam = postResultConfig.ResultsPerTeam; + resultConfigEntity.Scorings = await MapToScoringList(user, postResultConfig.Scorings, resultConfigEntity.Scorings, cancellationToken); + resultConfigEntity.PointFilters = await MapToFilterOptionListAsync(user, postResultConfig.FiltersForPoints, + resultConfigEntity.PointFilters, cancellationToken); + resultConfigEntity.ResultFilters = await MapToFilterOptionListAsync(user, postResultConfig.FiltersForResult, + resultConfigEntity.ResultFilters, cancellationToken); + UpdateVersionEntity(user, resultConfigEntity); + return await Task.FromResult(resultConfigEntity); + } + + private async Task> MapToStandingConfigListAsync(LeagueUser user, StandingConfigModel? standingConfigModel, + ICollection standingConfigurationEntities, CancellationToken cancellationToken) + { + if (standingConfigModel is null) + { + return Array.Empty().ToList(); + } + + var standingConfigEntity = standingConfigurationEntities.FirstOrDefault(x => x.StandingConfigId == standingConfigModel.StandingConfigId); + if (standingConfigEntity is null) + { + standingConfigEntity = CreateVersionEntity(user, new StandingConfigurationEntity()); + standingConfigEntity.LeagueId = dbContext.LeagueProvider.LeagueId; + standingConfigurationEntities.Clear(); + standingConfigurationEntities.Add(standingConfigEntity); + } + standingConfigEntity.Name = standingConfigModel.Name; + standingConfigEntity.ResultKind = standingConfigModel.ResultKind; + standingConfigEntity.UseCombinedResult = standingConfigModel.UseCombinedResult; + standingConfigEntity.WeeksCounted = standingConfigModel.WeeksCounted; + UpdateVersionEntity(user, standingConfigEntity); + return await Task.FromResult(standingConfigurationEntities); + } + + private async Task> MapToScoringList(LeagueUser user, ICollection scoringModels, + ICollection scoringEntities, CancellationToken cancellationToken) + { + // Map votes + foreach (var scoringModel in scoringModels) + { + var scoringEntity = scoringModel.Id == 0 ? null : scoringEntities + .FirstOrDefault(x => x.ScoringId == scoringModel.Id); + if (scoringEntity == null) + { + scoringEntity = CreateVersionEntity(user, new ScoringEntity()); + scoringEntities.Add(scoringEntity); + scoringEntity.LeagueId = dbContext.LeagueProvider.LeagueId; + } + await MapToScoringEntityAsync(user, scoringModel, scoringEntity, cancellationToken); + } + // Delete votes that are no longer in source collection + var deleteScorings = scoringEntities + .Where(x => scoringModels.Any(y => y.Id == x.ScoringId) == false); + foreach (var deleteScoring in deleteScorings) + { + dbContext.Remove(deleteScoring); + } + return scoringEntities; + } + + private async Task MapToScoringEntityAsync(LeagueUser user, ScoringModel scoringModel, ScoringEntity scoringEntity, + CancellationToken cancellationToken) + { + scoringEntity.Index = scoringModel.Index; + scoringEntity.MaxResultsPerGroup = scoringModel.MaxResultsPerGroup; + scoringEntity.Name = scoringModel.Name; + scoringEntity.ShowResults = scoringModel.ShowResults; + scoringEntity.IsCombinedResult = scoringModel.IsCombinedResult; + scoringEntity.UseResultSetTeam = scoringModel.UseResultSetTeam; + scoringEntity.UpdateTeamOnRecalculation = scoringModel.UpdateTeamOnRecalculation; + scoringEntity.PointsRule = scoringModel.PointRule is not null ? await MapToPointRuleEntityAsync(user, scoringModel.PointRule, + scoringEntity.PointsRule ?? CreateVersionEntity(user, new PointRuleEntity() { LeagueId = dbContext.LeagueProvider.LeagueId }), cancellationToken) : null; + scoringEntity.UseExternalSourcePoints = scoringModel.UseSourcePoints; + UpdateVersionEntity(user, scoringEntity); + return await Task.FromResult(scoringEntity); + } + + private async Task MapToPointRuleEntityAsync(LeagueUser user, PointRuleModel pointRuleModel, PointRuleEntity pointRuleEntity, + CancellationToken cancellationToken) + { + pointRuleEntity.RuleType = pointRuleModel.RuleType; + pointRuleEntity.BonusPoints = pointRuleModel.BonusPoints; + pointRuleEntity.FinalSortOptions = pointRuleModel.FinalSortOptions; + pointRuleEntity.MaxPoints = pointRuleModel.MaxPoints; + pointRuleEntity.Name = pointRuleModel.Name; + pointRuleEntity.PointDropOff = pointRuleModel.PointDropOff; + pointRuleEntity.PointsPerPlace = pointRuleModel.PointsPerPlace; + pointRuleEntity.PointsSortOptions = pointRuleModel.PointsSortOptions; + pointRuleEntity.Formula = pointRuleModel.Formula; + pointRuleEntity.AutoPenalties = await MapToAutoPenaltyCollection(pointRuleModel.AutoPenalties, pointRuleEntity.AutoPenalties, cancellationToken); + UpdateVersionEntity(user, pointRuleEntity); + return pointRuleEntity; + } + + private async Task> MapToAutoPenaltyCollection(IEnumerable models, ICollection entities, + CancellationToken cancellationToken) + { + foreach(var model in models) + { + var entity = entities + .Where(x => x.PenaltyConfigId != 0 && x.PenaltyConfigId == model.PenaltyConfigId) + .FirstOrDefault(); + if (entity is null) + { + entity = new() { LeagueId = dbContext.LeagueProvider.LeagueId }; + entities.Add(entity); + } + await MapToAutoPenaltyConfigEntity(model, entity, cancellationToken); + } + var delete = entities + .Where(x => models.Any(y => y.PenaltyConfigId == x.PenaltyConfigId) == false); + foreach (var deleteEntity in delete) + { + dbContext.Remove(deleteEntity); + } + return entities; + } + + private async Task MapToAutoPenaltyConfigEntity(AutoPenaltyConfiguration model, AutoPenaltyConfigEntity entity, + CancellationToken cancellationToken) + { + entity.Conditions = model.Conditions; + entity.Description = model.Description; + entity.Points = model.Points; + entity.Positions = model.Positions; + entity.Time = model.Time; + entity.Type = model.Type; + return await Task.FromResult(entity); + } + + private static FilterCondition MapToFilterCondition(FilterConditionModel model) => new() + { + ColumnPropertyName = model.ColumnPropertyName, + Comparator = model.Comparator, + FilterType = model.FilterType, + FilterValues = model.FilterValues, + }; + + protected virtual async Task MapToResultConfigEntityAsync(LeagueUser user, PutResultConfigModel putResultConfig, ResultConfigurationEntity resultConfigEntity, CancellationToken cancellationToken) + { + return await MapToResultConfigEntityAsync(user, (PostResultConfigModel)putResultConfig, resultConfigEntity, cancellationToken); + } + + protected virtual async Task MapToResultConfigModel(long resultConfigId, CancellationToken cancellationToken) + { + return await dbContext.ResultConfigurations + .Where(x => x.ResultConfigId == resultConfigId) + .Select(MapToResultConfigModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } + + public Expression> MapToResultConfigModelExpression => resultConfig => new ResultConfigModel() + { + LeagueId = resultConfig.LeagueId, + ResultConfigId = resultConfig.ResultConfigId, + ChampSeasonId = resultConfig.ChampSeasonId, + ChampionshipName = resultConfig.ChampSeason.Championship.Name, + SourceResultConfig = resultConfig.SourceResultConfig != null + ? new ResultConfigInfoModel() + { + ResultConfigId = resultConfig.SourceResultConfig.ResultConfigId, + ChampSeasonId = resultConfig.SourceResultConfig.ChampSeasonId, + ChampionshipName = resultConfig.SourceResultConfig.ChampSeason.Championship.Name, + DisplayName = resultConfig.SourceResultConfig.DisplayName, + LeagueId = resultConfig.SourceResultConfig.LeagueId, + Name = resultConfig.SourceResultConfig.Name, + } + : null, + Name = resultConfig.Name, + DisplayName = resultConfig.DisplayName, + IsDefaultConfig = resultConfig.ResultConfigId == resultConfig.ChampSeason.DefaultResultConfigId, + ResultsPerTeam = resultConfig.ResultsPerTeam, + Scorings = resultConfig.Scorings.Select(scoring => new ScoringModel() + { + Id = scoring.ScoringId, + Index = scoring.Index, + MaxResultsPerGroup = scoring.MaxResultsPerGroup, + Name = scoring.Name, + ShowResults = scoring.ShowResults, + IsCombinedResult = scoring.IsCombinedResult, + UpdateTeamOnRecalculation = scoring.UpdateTeamOnRecalculation, + UseResultSetTeam = scoring.UseResultSetTeam, + UseSourcePoints = scoring.UseExternalSourcePoints, + PointRule = scoring.PointsRule != null ? new PointRuleModel() + { + RuleType = scoring.PointsRule.RuleType, + BonusPoints = scoring.PointsRule.BonusPoints, + FinalSortOptions = scoring.PointsRule.FinalSortOptions, + LeagueId = scoring.LeagueId, + MaxPoints = scoring.PointsRule.MaxPoints, + PointDropOff = scoring.PointsRule.PointDropOff, + PointRuleId = scoring.PointsRule.PointRuleId, + PointsPerPlace = scoring.PointsRule.PointsPerPlace.ToList(), + PointsSortOptions = scoring.PointsRule.PointsSortOptions, + Name = scoring.PointsRule.Name, + Formula = scoring.PointsRule.Formula, + AutoPenalties = scoring.PointsRule.AutoPenalties.Select(penalty => new AutoPenaltyConfiguration() + { + Conditions = penalty.Conditions, + Description = penalty.Description, + LeagueId = penalty.LeagueId, + PenaltyConfigId = penalty.PenaltyConfigId, + Points = penalty.Points, + Positions = penalty.Positions, + Time = penalty.Time, + Type = penalty.Type, + }).ToList(), + } : null, + }).OrderBy(x => x.Index).ToList(), + FiltersForPoints = resultConfig.PointFilters + .Select(filter => new ResultFilterModel() + { + LeagueId = filter.LeagueId, + FilterOptionId = filter.FilterOptionId, + Condition = filter.Conditions.FirstOrDefault() ?? new(), + }).ToList(), + FiltersForResult = resultConfig.ResultFilters + .Select(filter => new ResultFilterModel() + { + LeagueId = filter.LeagueId, + FilterOptionId = filter.FilterOptionId, + Condition = filter.Conditions.FirstOrDefault() ?? new(), + }).ToList(), + }; + + public Expression> MapToGetScoringModelExpression => source => new ScoringModel() + { + Id = source.ScoringId, + MaxResultsPerGroup = source.MaxResultsPerGroup, + Name = source.Name, + ShowResults = source.ShowResults, + UpdateTeamOnRecalculation = source.UpdateTeamOnRecalculation, + UseResultSetTeam = source.UseResultSetTeam, + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/ResultHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Results/ResultHandlerBase.cs new file mode 100644 index 00000000..cf820046 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/ResultHandlerBase.cs @@ -0,0 +1,112 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public class ResultHandlerBase : HandlerBase +{ + public ResultHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + protected async Task> MapToGetResultModelsFromEventAsync(long eventId, CancellationToken cancellationToken) + { + return await dbContext.ScoredEventResults + .Where(x => x.EventId == eventId) + .Select(MapToEventResultModelExpression) + .ToListAsync(cancellationToken); + } + + public Expression> MapToEventResultModelExpression => result => new EventResultModel() + { + EventId = result.EventId, + LeagueId = result.LeagueId, + EventName = result.Event.Name, + DisplayName = result.Name, + ResultId = result.ResultId, + SeasonId = result.Event.Schedule.SeasonId, + Date = result.Event.Date.GetValueOrDefault(), + TrackId = result.Event.TrackId.GetValueOrDefault(), + TrackName = result.Event.Track.TrackGroup.TrackName, + ConfigName = result.Event.Track.ConfigName, + StrengthOfField = result.Event.SimSessionDetails.Any() ? result.Event.SimSessionDetails.First().EventStrengthOfField : 0, + SessionResults = result.ScoredSessionResults.Select(sessionResult => new ResultModel() + { + LeagueId = sessionResult.LeagueId, + ScoringId = sessionResult.ScoringId, + SessionResultId = sessionResult.SessionResultId, + SessionName = sessionResult.Name, + SessionNr = sessionResult.SessionNr, + ResultRows = sessionResult.ScoredResultRows + .OrderBy(x => x.FinalPosition) + .Select(row => new ResultRowModel() + { + ScoredResultRowId = row.ScoredResultRowId, + MemberId = row.MemberId, + Interval = new Interval(row.Interval), + FastestLapTime = row.FastestLapTime, + AvgLapTime = row.AvgLapTime, + Firstname = (row.Member != null) ? row.Member.Firstname : string.Empty, + Lastname = (row.Member != null) ? row.Member.Lastname : string.Empty, + TeamName = (row.Team != null) ? row.Team.Name : string.Empty, + StartPosition = row.StartPosition, + FinishPosition = row.FinishPosition, + FinalPosition = row.FinalPosition, + RacePoints = row.RacePoints, + PenaltyPoints = row.PenaltyPoints, + BonusPoints = row.BonusPoints, + TotalPoints = row.TotalPoints, + Car = row.Car, + CarClass = row.CarClass, + CarId = row.CarId, + CarNumber = row.CarNumber, + ClassId = row.ClassId, + ClubId = row.ClubId, + ClubName = row.ClubName, + CompletedLaps = row.CompletedLaps, + CompletedPct = row.CompletedPct, + Division = row.Division, + FastLapNr = row.FastLapNr, + FinalPositionChange = row.FinalPositionChange, + Incidents = row.Incidents, + LeadLaps = row.LeadLaps, + License = row.License, + NewIrating = row.NewIRating, + NewLicenseLevel = row.NewLicenseLevel, + NewSafetyRating = row.NewSafetyRating, + OldIrating = row.OldIRating, + OldLicenseLevel = row.OldLicenseLevel, + OldSafetyRating = row.OldSafetyRating, + PositionChange = row.PositionChange, + QualifyingTime = row.QualifyingTime, + SeasonStartIrating = row.SeasonStartIRating, + Status = (RaceStatus)row.Status, + TeamId = row.TeamId, + TeamColor = (row.Team != null) ? row.Team.TeamColor : string.Empty, + }), + FastestLapTime = sessionResult.FastestLap, + FastestLapDriver = sessionResult.FastestLapDriver == null ? null : new() + { + FirstName = sessionResult.FastestLapDriver.Firstname, + LastName = sessionResult.FastestLapDriver.Lastname, + MemberId = sessionResult.FastestLapDriver.Id, + }, + PoleLapTime = sessionResult.FastestQualyLap, + PoleLapDriver = sessionResult.FastestQualyLapDriver == null ? null : new() + { + FirstName = sessionResult.FastestQualyLapDriver.Firstname, + LastName = sessionResult.FastestQualyLapDriver.Lastname, + MemberId = sessionResult.FastestQualyLapDriver.Id, + }, + CleanestDrivers = sessionResult.CleanestDrivers.Select(member => new MemberInfoModel() + { + FirstName = member.Firstname, + LastName = member.Lastname, + MemberId = member.Id, + }).ToList(), + CreatedOn = TreatAsUTCDateTime(sessionResult.CreatedOn), + LastModifiedOn = TreatAsUTCDateTime(sessionResult.LastModifiedOn), + }), + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/TriggerResultCalculationHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/TriggerResultCalculationHandler.cs new file mode 100644 index 00000000..a19f8800 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/TriggerResultCalculationHandler.cs @@ -0,0 +1,32 @@ +using iRLeagueApiCore.Services.ResultService.Excecution; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record TriggerResultCalculationCommand(long EventId) : IRequest; + +public sealed class TriggerResultCalculationHandler : ResultHandlerBase, + IRequestHandler +{ + private readonly IResultCalculationQueue calculationQueue; + + public TriggerResultCalculationHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators, IResultCalculationQueue calculationQueue) : base(logger, dbContext, validators) + { + this.calculationQueue = calculationQueue; + } + + public async Task Handle(TriggerResultCalculationCommand request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var @event = await dbContext.Events + .Where(x => x.EventId == request.EventId) + .FirstOrDefaultAsync(cancellationToken); + if (@event is null) + { + return Unit.Value; + } + + await calculationQueue.QueueEventResultAsync(@event.EventId); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Results/UploadResultHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Results/UploadResultHandler.cs new file mode 100644 index 00000000..43d10212 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Results/UploadResultHandler.cs @@ -0,0 +1,358 @@ +using iRLeagueApiCore.Client.ResultsParsing; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Excecution; +using Microsoft.AspNetCore.Connections.Features; +using System.Text.Json; +using System.Threading; +using System.Transactions; + +namespace iRLeagueApiCore.Server.Handlers.Results; + +public record UploadResultRequest(long EventId, ParseSimSessionResult ResultData) : IRequest; + +public sealed class UploadResultHandler : HandlerBase, + IRequestHandler +{ + private readonly IResultCalculationQueue calculationQueue; + private IDictionary SeasonStartIratings; + + public UploadResultHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators, + IResultCalculationQueue calculationQueue) : + base(logger, dbContext, validators) + { + this.calculationQueue = calculationQueue; + SeasonStartIratings = new Dictionary(); + } + + public async Task Handle(UploadResultRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + + // add to database + var @event = await GetEventEntityAsync(request.EventId, cancellationToken) + ?? throw new ResourceNotFoundException(); + SeasonStartIratings = await GetMemberSeasonStartIratingAsync(@event.Schedule.SeasonId, cancellationToken); + using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + if (@event.EventResult is not null) + { + dbContext.Remove(@event.EventResult); + } + @event.SimSessionDetails.Clear(); + await dbContext.SaveChangesAsync(cancellationToken); + var result = await ReadResultsAsync(request.ResultData, @event, cancellationToken); + @event.EventResult = result; + await dbContext.SaveChangesAsync(cancellationToken); + tx.Complete(); + } + // Queue result calculation for this event + await calculationQueue.QueueEventResultAsync(@event.EventId); + + return true; + } + + private async Task GetEventEntityAsync(long eventId, CancellationToken cancellationToken) + { + // search for session first to check if result will be valid + return await dbContext.Events + .Where(x => x.EventId == eventId) + .Include(x => x.Schedule) + .Include(x => x.Sessions) + .Include(x => x.EventResult) + .ThenInclude(x => x.SessionResults) + .ThenInclude(x => x.IRSimSessionDetails) + .Include(x => x.SimSessionDetails) + .FirstOrDefaultAsync(cancellationToken); + } + + private async Task ParseDataStream(Stream dataStream, CancellationToken cancellationToken) + { + return await JsonSerializer.DeserializeAsync(dataStream, cancellationToken: cancellationToken) + ?? throw new InvalidOperationException("Failed to parse results from json"); + } + + private async Task ReadResultsAsync(ParseSimSessionResult data, EventEntity @event, + CancellationToken cancellationToken) + { + var map = CreateSessionMapping(data.session_results, @event); + // create entities + var result = @event.EventResult ?? new EventResultEntity(); + var details = ReadDetails(data); + details.Event = @event; + IDictionary sessionResults = new Dictionary(); + foreach (var sessionResultData in data.session_results) + { + var sessionResult = await ReadSessionResultsAsync(@event.LeagueId, data, sessionResultData, details, cancellationToken); + sessionResults.Add(sessionResult); + } + var mappedSessionResults = MapToSubSessions(sessionResults, @event, map); + foreach (var subResult in mappedSessionResults) + { + result.SessionResults.Add(subResult); + } + return result; + } + + private static ICollection<(int resultNr, int sessionNr)> CreateSessionMapping(IEnumerable sessionResults, EventEntity @event) + { + var map = new List<(int resultNr, int sessionNr)>(); + + var practiceSessionTypes = new[] { SimSessionType.OpenPractice }.Cast(); + var practiceSession = @event.Sessions + .FirstOrDefault(x => x.SessionType == SessionType.Practice); + var practiceResult = sessionResults + .FirstOrDefault(x => practiceSessionTypes.Contains(x.simsession_type) && x.simsession_name == "PRACTICE"); + if (practiceSession is not null && practiceResult is not null) + { + map.Add((practiceResult.simsession_number, practiceSession.SessionNr)); + } + + var qualySessionTypes = new[] { SimSessionType.LoneQualifying, SimSessionType.OpenQualifying }.Cast(); + var qualySession = @event.Sessions + .FirstOrDefault(x => x.SessionType == SessionType.Qualifying); + var qualyResult = sessionResults + .FirstOrDefault(x => qualySessionTypes.Contains(x.simsession_type)); + if (qualySession is not null && qualyResult is not null) + { + map.Add((qualyResult.simsession_number, qualySession.SessionNr)); + } + + var raceSessionTypes = new[] { SimSessionType.Race }.Cast(); + var raceSessions = @event.Sessions + .OrderBy(x => x.SessionNr) + .Where(x => x.SessionType == SessionType.Race); + var raceResults = sessionResults + .Where(x => raceSessionTypes.Contains(x.simsession_type)).Reverse(); + foreach ((var session, var result) in raceSessions.Zip(raceResults)) + { + if (session is not null && result is not null) + { + map.Add((result.simsession_number, session.SessionNr)); + } + } + + return map; + } + + private async Task GetOrCreateMemberAsync(long leagueId, ParseSessionResultRow row, CancellationToken cancellationToken) + { + var custId = row.cust_id.ToString(); + var displayName = row.display_name ?? string.Empty; + var leagueMember = await dbContext.LeagueMembers + .Include(x => x.Team) + .Include(x => x.Member) + .Where(x => x.LeagueId == leagueId) + .Where(x => x.Member.IRacingId == custId) + .SingleOrDefaultAsync(cancellationToken) + ?? dbContext.LeagueMembers.Local + .SingleOrDefault(x => x.Member.IRacingId == custId); + if (leagueMember == null) + { + var league = await dbContext.Leagues + .FirstAsync(x => x.Id == leagueId); + var (firstname, lastname) = GetFirstnameLastname(displayName); + var member = new MemberEntity() + { + Firstname = firstname, + Lastname = lastname, + IRacingId = custId.ToString(), + }; + leagueMember = new LeagueMemberEntity() + { + Member = member, + League = league, + }; + dbContext.LeagueMembers.Add(leagueMember); + } + else + { + // update member name + var (firstname, lastname) = GetFirstnameLastname(displayName); + leagueMember.Member.Firstname = firstname; + leagueMember.Member.Lastname = lastname; + } + return leagueMember; + } + + private async Task GetTeamAsync(long? iracingTeamId, CancellationToken cancellationToken) + { + if (iracingTeamId is null) + { + return null; + } + + iracingTeamId = Math.Abs(iracingTeamId.Value); // get positive value because team is negative in result + return await dbContext.Teams + .SingleOrDefaultAsync(x => x.IRacingTeamId == iracingTeamId, cancellationToken) + ?? dbContext.Teams.Local + .SingleOrDefault(x => x.IRacingTeamId == iracingTeamId); + } + + private async Task UpdateOrCreateTeamAsync(long leagueId, ParseSessionResultRow row, CancellationToken cancellationToken) + { + if (row.team_id is null) + { + return; + } + + var iracingTeamId = Math.Abs(row.team_id.Value); // get positive value because team is negative in result + var teamName = row.display_name ?? string.Empty; + var team = await GetTeamAsync(iracingTeamId, cancellationToken); + if (team is null) + { + var league = await dbContext.Leagues + .FirstAsync(x => x.Id == leagueId, cancellationToken); + team = new TeamEntity() + { + League = league, + LeagueId = league.Id, + IRacingTeamId = iracingTeamId, + Name = teamName, + }; + dbContext.Teams.Add(team); + } + + foreach(var driverRow in row.driver_results) + { + var member = await GetOrCreateMemberAsync(leagueId, driverRow, cancellationToken); + member.Team = team; + } + } + + private async Task> ReadSessionResultsAsync(long leagueId, ParseSimSessionResult sessionData, ParseSessionResult data, + IRSimSessionDetailsEntity details, CancellationToken cancellationToken) + { + var sessionResult = new SessionResultEntity + { + LeagueId = leagueId, + IRSimSessionDetails = details, + SimSessionType = (SimSessionType)data.simsession_type + }; + var laps = data.results.Max(x => x.laps_complete); + var resultRows = new List(); + bool isTeamResult = data.results.Any(x => x.driver_results.Any()); + var dataRows = data.results.AsEnumerable(); + if (isTeamResult) + { + foreach(var teamRow in dataRows) + { + await UpdateOrCreateTeamAsync(leagueId, teamRow, cancellationToken); + } + dataRows = data.results.SelectMany(x => x.driver_results); + } + foreach (var row in dataRows) + { + resultRows.Add(await ReadResultRowAsync(leagueId, sessionData, row, laps, cancellationToken)); + } + sessionResult.ResultRows = resultRows; + var sessionResultNr = data.simsession_number; + return new KeyValuePair(sessionResultNr, sessionResult); + } + + private IRSimSessionDetailsEntity ReadDetails(ParseSimSessionResult data) + { + var details = new IRSimSessionDetailsEntity + { + IRSessionId = data.session_id, + IRSubsessionId = data.subsession_id, + IRTrackId = data.track.track_id, + ConfigName = data.track.config_name, + Category = data.track.category, + CornersPerLap = data.corners_per_lap, + NumCautionLaps = data.num_caution_laps, + NumCautions = data.num_cautions, + NumLeadChanges = data.num_lead_changes, + WarmupRubber = data.track_state.warmup_rubber, + RaceRubber = data.track_state.race_rubber, + DamageModel = data.damage_model, + EndTime = data.end_time, + EventAverageLap = ParseTime(data.event_average_lap), + EventLapsComplete = data.event_laps_complete, + EventStrengthOfField = data.event_strength_of_field, + Fog = data.weather.fog, + IRRaceWeek = data.race_week_num, + IRSeasonId = data.season_id, + IRSeasonName = data.season_name, + IRSeasonQuarter = data.season_quarter, + IRSeasonYear = data.season_year, + KmDistPerLap = 0, + LeagueId = data.league_id, + LeaveMarbles = data.track_state.leave_marbles, + LicenseCategory = data.license_category_id, + PracticeGripCompound = data.track_state.practice_grip_compound, + PracticeRubber = data.track_state.practice_rubber, + QualifyGripCompund = data.track_state.qualify_grip_compound, + QualifyRubber = data.track_state.qualify_rubber, + RaceGripCompound = data.track_state.race_grip_compound, + RelHumidity = data.weather.rel_humidity, + SessionName = data.session_name, + SimStartUtcOffset = ParseTime(data.weather.simulated_start_utc_offset), + SimStartUtcTime = data.weather.simulated_start_utc_time, + Skies = data.weather.skies, + StartTime = data.start_time, + TempUnits = data.weather.temp_units, + TempValue = data.weather.temp_value, + TimeOfDay = data.weather.time_of_day, + TrackName = data.track.track_name + }; + return details; + } + + private async Task ReadResultRowAsync(long leagueId, ParseSimSessionResult sessionData, ParseSessionResultRow data, + int laps, CancellationToken cancellationToken) + { + var leagueMember = await GetOrCreateMemberAsync(leagueId, data, cancellationToken); + var team = await GetTeamAsync(data.team_id, cancellationToken) + ?? leagueMember.Team; + var row = new ResultRowEntity + { + LeagueId = leagueId, + AvgLapTime = ParseTime(data.average_lap), + Car = data.car_name, + CarClass = sessionData.car_classes.FirstOrDefault(x => x.car_class_id == data.car_class_id)?.short_name ?? string.Empty, + CarId = data.car_id, + CarNumber = data.livery.car_number ?? string.Empty, + ClassId = data.car_class_id, + ClubId = data.club_id, + ClubName = data.club_name, + CompletedLaps = data.laps_complete, + CompletedPct = laps != 0 ? data.laps_complete / (double)laps : 0, + ContactLaps = "", + Division = data.division, + FastestLapTime = ParseTime(data.best_lap_time), + FastLapNr = data.best_lap_num, + FinishPosition = data.position + 1, + Incidents = data.incidents, + Interval = ParseInterval(data.class_interval, data.laps_complete, laps), + IRacingId = data.cust_id.ToString(), + LeadLaps = data.laps_lead, + License = sessionData.license_category, + Member = leagueMember.Member, + NewCpi = (int)data.new_cpi, + NewIRating = data.newi_rating, + NewLicenseLevel = data.new_license_level, + NewSafetyRating = data.new_sub_level, + NumContactLaps = -1, + NumOfftrackLaps = -1, + NumPitStops = -1, + OfftrackLaps = "", + OldCpi = (int)data.old_cpi, + OldIRating = data.oldi_rating, + OldLicenseLevel = data.old_license_level, + OldSafetyRating = data.old_sub_level, + PittedLaps = "", + PointsEligible = true, + PositionChange = data.position - data.starting_position, + QualifyingTime = ParseTime(data.best_qual_lap_time), + QualifyingTimeAt = data.best_qual_lap_at, + SimSessionType = -1, + StartPosition = data.starting_position + 1, + Status = data.reason_out_id, + Team = team, + RacePoints = data.champ_points + }; + row.SeasonStartIRating = SeasonStartIratings.TryGetValue(row.Member.Id, out int irating) ? irating : row.OldIRating; + + return row; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/CommentHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/CommentHandlerBase.cs new file mode 100644 index 00000000..11f77a6e --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/CommentHandlerBase.cs @@ -0,0 +1,115 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public class CommentHandlerBase : HandlerBase +{ + public CommentHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetCommentEntityAsync(long commentId, CancellationToken cancellationToken) + { + return await dbContext.ReviewComments + .Include(x => x.ReviewCommentVotes) + .Where(x => x.CommentId == commentId) + .FirstOrDefaultAsync(cancellationToken: cancellationToken); + } + + protected virtual async Task MapToReviewCommentEntityAsync(LeagueUser user, PostReviewCommentModel postComment, + ReviewCommentEntity commentEntity, CancellationToken cancellationToken) + { + commentEntity.Text = postComment.Text; + commentEntity.ReviewCommentVotes = await MapCommentVoteList(postComment.Votes, commentEntity.ReviewCommentVotes, cancellationToken); + return UpdateVersionEntity(user, commentEntity); + } + + protected virtual async Task MapToReviewCommentEntityAsync(LeagueUser user, PutReviewCommentModel putComment, + ReviewCommentEntity commentEntity, CancellationToken cancellationToken) + { + return await MapToReviewCommentEntityAsync(user, (PostReviewCommentModel)putComment, commentEntity, cancellationToken); + } + + protected virtual async Task MapToCommentVoteEntityAsync(VoteModel voteModel, ReviewCommentVoteEntity voteEntity, + CancellationToken cancellationToken) + { + voteEntity.Description = voteModel.Description; + voteEntity.MemberAtFault = await GetMemberEntityAsync(voteModel.MemberAtFault?.MemberId, cancellationToken); + voteEntity.TeamAtFault = await GetTeamEntityAsync(voteModel.TeamAtFault?.TeamId, cancellationToken); + voteEntity.VoteCategory = await GetVoteCategoryEntityAsync(voteEntity.LeagueId, voteModel.VoteCategoryId, cancellationToken); + return voteEntity; + } + + protected virtual async Task> MapCommentVoteList(IEnumerable voteModels, + ICollection voteEntities, CancellationToken cancellationToken) + { + // Map votes + foreach (var voteModel in voteModels) + { + var voteEntity = voteEntities + .FirstOrDefault(x => x.ReviewVoteId == voteModel.Id && voteModel.Id != 0); + if (voteEntity == null) + { + voteEntity = new ReviewCommentVoteEntity(); + voteEntities.Add(voteEntity); + } + await MapToCommentVoteEntityAsync(voteModel, voteEntity, cancellationToken); + } + // Delete votes that are no longer in source collection + var deleteVotes = voteEntities + .Where(x => voteModels.Any(y => y.Id == x.ReviewVoteId) == false); + foreach (var deleteVote in deleteVotes) + { + dbContext.Remove(deleteVote); + } + return voteEntities; + } + + protected virtual async Task MapToReviewCommentModelAsync(long commentId, CancellationToken cancellationToken) + { + return await dbContext.ReviewComments + .Where(x => x.CommentId == commentId) + .Select(MapToReviewCommentModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } + + protected Expression> MapToReviewCommentModelExpression => comment => new ReviewCommentModel() + { + LeagueId = comment.LeagueId, + CommentId = comment.CommentId, + AuthorName = comment.AuthorName, + AuthorUserId = comment.AuthorUserId, + Date = TreatAsUTCDateTime(comment.Date), + ReviewId = comment.ReviewId.GetValueOrDefault(), + Text = comment.Text, + Votes = comment.ReviewCommentVotes.Select(vote => new VoteModel() + { + Id = vote.ReviewVoteId, + Description = vote.Description, + VoteCategoryId = vote.VoteCategoryId.GetValueOrDefault(), + VoteCategoryText = vote.VoteCategory.Text, + MemberAtFault = vote.MemberAtFault == null ? default : new() + { + MemberId = vote.MemberAtFault.Id, + FirstName = vote.MemberAtFault.Firstname, + LastName = vote.MemberAtFault.Lastname + }, + TeamAtFault = vote.TeamAtFault == null ? default : new() + { + TeamId = vote.TeamAtFault.TeamId, + Name = vote.TeamAtFault.Name, + TeamColor = vote.TeamAtFault.TeamColor, + }, + }).ToList(), + CreatedByUserId = comment.CreatedByUserId, + CreatedByUserName = comment.CreatedByUserName, + CreatedOn = TreatAsUTCDateTime(comment.CreatedOn), + LastModifiedByUserId = comment.LastModifiedByUserId, + LastModifiedByUserName = comment.LastModifiedByUserName, + LastModifiedOn = TreatAsUTCDateTime(comment.LastModifiedOn), + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/DeletePenaltyHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeletePenaltyHandler.cs new file mode 100644 index 00000000..17171ea1 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeletePenaltyHandler.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record DeletePenaltyRequest(long PenaltyId) : IRequest; + +public class DeletePenaltyHandler : ReviewsHandlerBase, + IRequestHandler +{ + public DeletePenaltyHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(DeletePenaltyRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deletePenalty = await GetAddPenaltyEntity(request.PenaltyId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.Remove(deletePenalty); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteProtestHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteProtestHandler.cs new file mode 100644 index 00000000..38a03f1d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteProtestHandler.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record DeleteProtestRequest(long ProtestId) : IRequest; + +public class DeleteProtestHandler : ProtestsHandlerBase, + IRequestHandler +{ + public DeleteProtestHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteProtestRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteProtest = await GetProtestEntityAsync(request.ProtestId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.Protests.Remove(deleteProtest); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteReviewCommentHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteReviewCommentHandler.cs new file mode 100644 index 00000000..d2c9667f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteReviewCommentHandler.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record DeleteReviewCommentRequest(long CommentId) : IRequest; + +public sealed class DeleteReviewCommentHandler : CommentHandlerBase, + IRequestHandler +{ + public DeleteReviewCommentHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteReviewCommentRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteComment = await GetCommentEntityAsync(request.CommentId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.Remove(deleteComment); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteReviewHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteReviewHandler.cs new file mode 100644 index 00000000..024648ab --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteReviewHandler.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record DeleteReviewRequest(long ReviewId) : IRequest; + +public sealed class DeleteReviewHandler : ReviewsHandlerBase, + IRequestHandler +{ + public DeleteReviewHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteReviewRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteReview = await GetReviewEntity(request.ReviewId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.Remove(deleteReview); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteVoteCategoryHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteVoteCategoryHandler.cs new file mode 100644 index 00000000..56760921 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/DeleteVoteCategoryHandler.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record DeleteVoteCategoryRequest(long CatId) : IRequest; + +public class DeleteVoteCategoryHandler : VoteCategoriesHandlerBase, + IRequestHandler +{ + public DeleteVoteCategoryHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteVoteCategoryRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteVoteCategory = await GetVoteCategoryEntityAsync(request.CatId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.Remove(deleteVoteCategory); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/GetLeagueVoteCategoriesHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetLeagueVoteCategoriesHandler.cs new file mode 100644 index 00000000..68956799 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetLeagueVoteCategoriesHandler.cs @@ -0,0 +1,30 @@ +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record GetLeagueVoteCategoriesRequest() : IRequest>; + +public sealed class GetLeagueVoteCategoriesHandler : VoteCategoriesHandlerBase, + IRequestHandler> +{ + public GetLeagueVoteCategoriesHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetLeagueVoteCategoriesRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + + var getVoteCategories = await MapToLeagueVoteCategoryModels(cancellationToken); + return getVoteCategories; + } + + private async Task> MapToLeagueVoteCategoryModels(CancellationToken cancellationToken) + { + return await dbContext.VoteCategories + .OrderBy(x => x.Index) + .Select(MapToVoteCategoryModelExpression) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/GetPenaltiesFromEventResultHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetPenaltiesFromEventResultHandler.cs new file mode 100644 index 00000000..48326b9a --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetPenaltiesFromEventResultHandler.cs @@ -0,0 +1,35 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record GetPenaltiesFromEventResultRequest(long ResultId) : IRequest>; + +public class GetPenaltiesFromEventResultHandler : ReviewsHandlerBase, + IRequestHandler> +{ + public GetPenaltiesFromEventResultHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetPenaltiesFromEventResultRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getPenalties = await GetPenaltiesFromEventResult(request.ResultId, cancellationToken); + return getPenalties; + } + + private async Task> GetPenaltiesFromEventResult(long resultId, CancellationToken cancellationToken) + { + var addPenalties = await dbContext.AddPenaltys + .Where(x => x.ScoredResultRow.ScoredSessionResult.ResultId == resultId) + .Select(MapToAddPenaltyModelExpression) + .ToListAsync(cancellationToken); + var reviewPenalties = await dbContext.ReviewPenaltys + .Where(x => x.ResultRow.ScoredSessionResult.ResultId == resultId) + .Select(MapToReviewPenaltyModelExpression) + .ToListAsync(cancellationToken); + return addPenalties.Concat(reviewPenalties); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/GetPenaltiesFromSessionResultHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetPenaltiesFromSessionResultHandler.cs new file mode 100644 index 00000000..578605ce --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetPenaltiesFromSessionResultHandler.cs @@ -0,0 +1,36 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record GetPenaltiesFromSessionResultRequest(long SessionResultId) : IRequest>; +public sealed class GetPenaltiesFromSessionResultHandler : ReviewsHandlerBase, + IRequestHandler> +{ + public GetPenaltiesFromSessionResultHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetPenaltiesFromSessionResultRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getReviews = await GetReviewPenaltiesFromSessionResult(request.SessionResultId, cancellationToken); + return getReviews; + } + + private async Task> GetReviewPenaltiesFromSessionResult(long sessionResultId, CancellationToken cancellationToken) + { + var addPenalties = await dbContext.AddPenaltys + .Where(x => x.ScoredResultRow.SessionResultId == sessionResultId) + .Select(MapToAddPenaltyModelExpression) + .ToListAsync(cancellationToken); + + var reviewPenalties = await dbContext.ReviewPenaltys + .Where(x => x.ResultRow.SessionResultId == sessionResultId) + .Select(MapToReviewPenaltyModelExpression) + .ToListAsync(cancellationToken); + + return addPenalties.Concat(reviewPenalties); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/GetProtestsFromEventHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetProtestsFromEventHandler.cs new file mode 100644 index 00000000..6dff6613 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetProtestsFromEventHandler.cs @@ -0,0 +1,49 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record GetProtestsFromEventRequest(LeagueUser User, long EventId) : IRequest>; + +public class GetProtestsFromEventHandler : ProtestsHandlerBase, IRequestHandler> +{ + public GetProtestsFromEventHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetProtestsFromEventRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var league = await GetCurrentLeagueEntityAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var isSteward = request.User.IsInRole(LeagueRoles.Admin, LeagueRoles.Steward); + + // return unauthorized if protests are not public and user is not a steward + if (isSteward == false && league.ProtestsPublic == ProtestPublicSetting.Hidden) + { + return Array.Empty(); + } + + var includeAuthor = GetIncludeName(league, isSteward); + var getProtests = await MapToProtestModelsFromEvent(request.EventId, includeAuthor, cancellationToken); + return getProtests; + } + + private bool GetIncludeName(LeagueEntity league, bool isSteward) => league.ProtestsPublic switch + { + ProtestPublicSetting.WithProtester => true, + _ => isSteward + }; + +private async Task> MapToProtestModelsFromEvent(long eventId, bool includeAuthor, CancellationToken cancellationToken) + { + return await dbContext.Protests + .Where(x => x.Session.EventId == eventId) + .Select(MapToProtestModelExpression(includeAuthor)) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewCommentHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewCommentHandler.cs new file mode 100644 index 00000000..ef5c59b5 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewCommentHandler.cs @@ -0,0 +1,22 @@ +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record GetReviewCommentRequest(long CommentId) : IRequest; + +public sealed class GetReviewCommentHandler : CommentHandlerBase, + IRequestHandler +{ + public GetReviewCommentHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetReviewCommentRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getComment = await MapToReviewCommentModelAsync(request.CommentId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getComment; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewHandler.cs new file mode 100644 index 00000000..eeabdf44 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewHandler.cs @@ -0,0 +1,21 @@ +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record GetReviewRequest(long ReviewId, bool IncludeComments) : IRequest; + +public sealed class GetReviewHandler : ReviewsHandlerBase, IRequestHandler +{ + public GetReviewHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetReviewRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getReview = await MapToReviewModel(request.ReviewId, request.IncludeComments, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getReview; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewsFromEventHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewsFromEventHandler.cs new file mode 100644 index 00000000..7bf88acc --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewsFromEventHandler.cs @@ -0,0 +1,33 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Extensions; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record GetReviewsFromEventRequest(long EventId, bool IncludeComments) : IRequest>; +public sealed class GetReviewsFromEventHandler : ReviewsHandlerBase, + IRequestHandler> +{ + public GetReviewsFromEventHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetReviewsFromEventRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getReviews = await MapToGetReviewsFromEventAsync(request.EventId, request.IncludeComments, cancellationToken); + return getReviews.OrderBy(x => x.SessionNr).ThenBy(x => x.IncidentNr); + } + + private async Task> MapToGetReviewsFromEventAsync(long EventId, bool includeComments, CancellationToken cancellationToken) + { + return (await dbContext.IncidentReviews + .Where(x => x.Session.EventId == EventId) + .Select(MapToReviewModelExpression(includeComments)) + .ToListAsync(cancellationToken)) + .OrderBy(x => x.SessionNr) + .ThenBy(x => x.IncidentNr.PadNumbers()) + .ThenBy(x => x.OnLap.PadNumbers()) + .ThenBy(x => x.Corner.PadNumbers()); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewsFromSessionHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewsFromSessionHandler.cs new file mode 100644 index 00000000..626f0186 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetReviewsFromSessionHandler.cs @@ -0,0 +1,33 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Extensions; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record GetReviewsFromSessionRequest(long SessionId, bool IncludeComments) : IRequest>; +public sealed class GetReviewsFromSessionHandler : ReviewsHandlerBase, + IRequestHandler> +{ + public GetReviewsFromSessionHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetReviewsFromSessionRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getReviews = await MapToGetReviewsFromSessionAsync(request.SessionId, request.IncludeComments, cancellationToken); + return getReviews; + } + + private async Task> MapToGetReviewsFromSessionAsync(long sessionId, bool includeComments, CancellationToken cancellationToken) + { + return (await dbContext.IncidentReviews + .Where(x => x.SessionId == sessionId) + .Select(MapToReviewModelExpression(includeComments)) + .ToListAsync(cancellationToken)) + .OrderBy(x => x.SessionNr) + .ThenBy(x => x.IncidentNr.PadNumbers()) + .ThenBy(x => x.OnLap.PadNumbers()) + .ThenBy(x => x.Corner.PadNumbers()); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/GetVoteCategoryHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetVoteCategoryHandler.cs new file mode 100644 index 00000000..e32c521b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/GetVoteCategoryHandler.cs @@ -0,0 +1,22 @@ +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record GetVoteCategoryRequest(long CatId) : IRequest; + +public class GetVoteCategoryHandler : VoteCategoriesHandlerBase, + IRequestHandler +{ + public GetVoteCategoryHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetVoteCategoryRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getVoteCategory = await MapToVoteCategoryModel(request.CatId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getVoteCategory; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/MoveReviewToSessionHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/MoveReviewToSessionHandler.cs new file mode 100644 index 00000000..166c2bbc --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/MoveReviewToSessionHandler.cs @@ -0,0 +1,46 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record MoveReviewToSessionRequest(long SessionId, long ReviewId, LeagueUser User) : IRequest; +public sealed class MoveReviewToSessionHandler : ReviewsHandlerBase, + IRequestHandler +{ + /// + /// Always include comments because this can only be called by an authorized user + /// + private const bool includeComments = true; + + public MoveReviewToSessionHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(MoveReviewToSessionRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var moveReview = await GetReviewEntity(request.ReviewId, cancellationToken) + ?? throw new ResourceNotFoundException(); + var toSession = await GetSessionEntityAsync(request.SessionId, cancellationToken) + ?? throw new ResourceNotFoundException(); + moveReview = await MoveToSessionAsync(request.User, moveReview, toSession, cancellationToken); + await dbContext.SaveChangesAsync(); + var getReview = await MapToReviewModel(moveReview.ReviewId, includeComments, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getReview; + } + + private async Task MoveToSessionAsync(LeagueUser user, IncidentReviewEntity review, SessionEntity session, CancellationToken cancellationToken) + { + review.Session = session; + return await Task.FromResult(UpdateVersionEntity(user, review)); + } + + private async Task GetSessionEntityAsync(long sessionId, CancellationToken cancellationToken) + { + return await dbContext.Sessions + .Where(x => x.SessionId == sessionId) + .FirstOrDefaultAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/PostPenaltyToResultHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostPenaltyToResultHandler.cs new file mode 100644 index 00000000..40696e2a --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostPenaltyToResultHandler.cs @@ -0,0 +1,50 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record PostPenaltyToResultRequest(long ResultId, long ScoredResultRowId, PostPenaltyModel Model) : IRequest; +public class PostPenaltyToResultHandler : ReviewsHandlerBase, + IRequestHandler +{ + public PostPenaltyToResultHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(PostPenaltyToResultRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postPenalty = await CreatePenalty(request.ResultId, request.ScoredResultRowId, cancellationToken); + postPenalty = await MapToAddPenaltyEntity(request.Model, postPenalty, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getPenaltyEntity = await dbContext.AddPenaltys + .Where(x => x.AddPenaltyId == postPenalty.AddPenaltyId) + .FirstAsync(cancellationToken); + var getPenalty = await MapToAddPenaltyModel(postPenalty.AddPenaltyId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getPenalty; + } + + private async Task CreatePenalty(long resultId, long scoredResultRowId, CancellationToken cancellationToken) + { + var result = await dbContext.ScoredSessionResults + .Include(x => x.ScoredResultRows) + .ThenInclude(x => x.Member) + .Where(x => x.SessionResultId == resultId) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var resultRow = result.ScoredResultRows + .Where(x => x.ScoredResultRowId == scoredResultRowId) + .FirstOrDefault() + ?? throw new ResourceNotFoundException(); + + var penalty = new AddPenaltyEntity() + { + LeagueId = result.LeagueId, + ScoredResultRow = resultRow, + }; + dbContext.AddPenaltys.Add(penalty); + + return penalty; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/PostProtestToSessionHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostProtestToSessionHandler.cs new file mode 100644 index 00000000..6d98b276 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostProtestToSessionHandler.cs @@ -0,0 +1,41 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record PostProtestToSessionRequest(long SessionId, LeagueUser User, PostProtestModel Model) : IRequest; + +public class PostProtestToSessionHandler : ProtestsHandlerBase, + IRequestHandler +{ + public PostProtestToSessionHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PostProtestToSessionRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postProtest = await CreateProtestEntity(request.User, request.SessionId, cancellationToken); + postProtest = await MapToProtestEntity(request.User, request.Model, postProtest, cancellationToken); + dbContext.Protests.Add(postProtest); + await dbContext.SaveChangesAsync(cancellationToken); + var getProtest = await MapToProtestModel(postProtest.ProtestId, includeAuthor: true, cancellationToken: cancellationToken) + ?? throw new InvalidOperationException("Could not find created resource"); + return getProtest; + } + + private async Task CreateProtestEntity(LeagueUser user, long sessionId, CancellationToken cancellationToken) + { + var session = await dbContext.Sessions + .Where(x => x.SessionId == sessionId) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var protest = new ProtestEntity() + { + LeagueId = session.LeagueId, + Session = session, + }; + return protest; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/PostReviewCommentToReviewHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostReviewCommentToReviewHandler.cs new file mode 100644 index 00000000..4ca21f2e --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostReviewCommentToReviewHandler.cs @@ -0,0 +1,40 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record PostReviewCommentToReviewRequest(long ReviewId, LeagueUser User, PostReviewCommentModel Model) : IRequest; + +public sealed class PostReviewCommentToReviewHandler : CommentHandlerBase, + IRequestHandler +{ + public PostReviewCommentToReviewHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PostReviewCommentToReviewRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postComment = await CreateCommentEntityOnReviewAsync(request.ReviewId, request.User, cancellationToken); + postComment = await MapToReviewCommentEntityAsync(request.User, request.Model, postComment, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getComment = await MapToReviewCommentModelAsync(postComment.CommentId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getComment; + } + + private async Task CreateCommentEntityOnReviewAsync(long reviewId, LeagueUser user, + CancellationToken cancellationToken) + { + var review = await dbContext.IncidentReviews + .Where(x => x.ReviewId == reviewId) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var commentEntity = CreateVersionEntity(user, new ReviewCommentEntity()); + commentEntity.AuthorName = user.Name; + commentEntity.AuthorUserId = user.Id; + review.Comments.Add(commentEntity); + return commentEntity; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/PostReviewToSessionHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostReviewToSessionHandler.cs new file mode 100644 index 00000000..f307bdfa --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostReviewToSessionHandler.cs @@ -0,0 +1,40 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record PostReviewToSessionRequest(long SessionId, LeagueUser User, PostReviewModel Model) : IRequest; +public sealed class PostReviewToSessionHandler : ReviewsHandlerBase, IRequestHandler +{ + /// + /// Always include comments because this can only be called by an authorized user + /// + private const bool includeComments = true; + + public PostReviewToSessionHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PostReviewToSessionRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postReview = await CreateReviewEntityOnSession(request.SessionId, request.User, cancellationToken); + postReview = await MapToReviewEntity(request.User, request.Model, postReview, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getReview = await MapToReviewModel(postReview.ReviewId, includeComments, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getReview; + } + + private async Task CreateReviewEntityOnSession(long sessionId, LeagueUser user, CancellationToken cancellationToken) + { + var session = await dbContext.Sessions + .Where(x => x.SessionId == sessionId) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var review = CreateVersionEntity(user, new IncidentReviewEntity()); + session.IncidentReviews.Add(review); + return review; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/PostVoteCategoryHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostVoteCategoryHandler.cs new file mode 100644 index 00000000..63e5dbac --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/PostVoteCategoryHandler.cs @@ -0,0 +1,37 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Models; +using Microsoft.OpenApi.Any; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record PostVoteCategoryRequest(PostVoteCategoryModel Model) : IRequest; + +public sealed class PostVoteCategoryHandler : VoteCategoriesHandlerBase, + IRequestHandler +{ + public PostVoteCategoryHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PostVoteCategoryRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postVoteCategory = await CreateVoteCategoryEntityAsync(cancellationToken); + postVoteCategory = await MapToVoteCategoryEntityAsync(request.Model, postVoteCategory, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getVoteCategory = await MapToVoteCategoryModel(postVoteCategory.CatId, cancellationToken) + ?? throw new InvalidOperationException("Created resource not found"); + return getVoteCategory; + } + + private async Task CreateVoteCategoryEntityAsync(CancellationToken cancellationToken) + { + var league = await GetCurrentLeagueEntityAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var voteCategory = new VoteCategoryEntity(); + league.VoteCategories.Add(voteCategory); + dbContext.VoteCategories.Add(voteCategory); + return voteCategory; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/ProtestsHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/ProtestsHandlerBase.cs new file mode 100644 index 00000000..6739485c --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/ProtestsHandlerBase.cs @@ -0,0 +1,73 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public class ProtestsHandlerBase : HandlerBase +{ + public ProtestsHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetProtestEntityAsync(long protestId, CancellationToken cancellationToken) + { + return await dbContext.Protests + .Where(x => x.ProtestId == protestId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task MapToProtestEntity(LeagueUser user, PostProtestModel model, ProtestEntity entity, CancellationToken cancellationToken) + { + entity.Author = await dbContext.LeagueMembers + .Where(x => x.MemberId == model.AuthorMemberId) + .FirstAsync(cancellationToken); + entity.Corner = model.Corner; + entity.FullDescription = model.FullDescription; + entity.OnLap = model.OnLap; + entity.InvolvedMembers = await MapToLeagueMemberList(model.InvolvedMembers.Select(x => x.MemberId), entity.InvolvedMembers, cancellationToken); + return entity; + } + + protected virtual async Task> MapToLeagueMemberList(IEnumerable involvedMemberIds, + ICollection involvedMembers, CancellationToken cancellationToken) + { + var members = await dbContext.LeagueMembers + .Where(x => involvedMemberIds.Contains(x.MemberId)) + .ToListAsync(cancellationToken); + return members; + } + + protected virtual async Task MapToProtestModel(long protestId, bool includeAuthor, CancellationToken cancellationToken) + { + return await dbContext.Protests + .Where(x => x.ProtestId == protestId) + .Select(MapToProtestModelExpression(includeAuthor)) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual Expression> MapToProtestModelExpression(bool includeAutho = false) => protest => new() + { + Author = includeAutho == false ? new() : new() + { + FirstName = protest.Author.Member.Firstname, + LastName = protest.Author.Member.Lastname, + MemberId = protest.Author.MemberId, + }, + Corner = protest.Corner, + EventId = protest.Session.EventId, + FullDescription = protest.FullDescription, + InvolvedMembers = protest.InvolvedMembers.Select(leagueMember => new MemberInfoModel() + { + FirstName = leagueMember.Member.Firstname, + LastName = leagueMember.Member.Lastname, + MemberId = leagueMember.MemberId, + }).ToList(), + OnLap = protest.OnLap, + ProtestId = protest.ProtestId, + SessionId = protest.SessionId, + SessionNr = protest.Session.SessionNr, + SessionName = protest.Session.Name, + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/PutPenaltyHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/PutPenaltyHandler.cs new file mode 100644 index 00000000..022e1991 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/PutPenaltyHandler.cs @@ -0,0 +1,26 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record PutPenaltyRequest(long PenaltyId, PutPenaltyModel Model) : IRequest; + +public class PutPenaltyHandler : ReviewsHandlerBase, + IRequestHandler +{ + public PutPenaltyHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(PutPenaltyRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putPenalty = await GetAddPenaltyEntity(request.PenaltyId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putPenalty = await MapToAddPenaltyEntity(request.Model, putPenalty, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getPenalty = await MapToAddPenaltyModel(putPenalty.AddPenaltyId, cancellationToken) + ?? throw new InvalidOperationException("Updated resource not found"); + return getPenalty; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/PutReviewCommentHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/PutReviewCommentHandler.cs new file mode 100644 index 00000000..56d5ff8f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/PutReviewCommentHandler.cs @@ -0,0 +1,27 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record PutReviewCommentRequest(long CommentId, LeagueUser User, PutReviewCommentModel Model) : IRequest; + +public sealed class PutReviewCommentHandler : CommentHandlerBase, + IRequestHandler +{ + public PutReviewCommentHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutReviewCommentRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putComment = await GetCommentEntityAsync(request.CommentId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putComment = await MapToReviewCommentEntityAsync(request.User, request.Model, putComment, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getComment = await MapToReviewCommentModelAsync(putComment.CommentId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getComment; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/PutReviewHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/PutReviewHandler.cs new file mode 100644 index 00000000..3a37c930 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/PutReviewHandler.cs @@ -0,0 +1,31 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record PutReviewRequest(long ReviewId, LeagueUser User, PutReviewModel Model) : IRequest; + +public sealed class PutReviewHandler : ReviewsHandlerBase, IRequestHandler +{ + /// + /// Always include comments because this can only be called by an authorized user + /// + private const bool includeComments = true; + + public PutReviewHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutReviewRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putReview = await GetReviewEntity(request.ReviewId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putReview = await MapToReviewEntity(request.User, request.Model, putReview, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getReview = await MapToReviewModel(putReview.ReviewId, includeComments, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getReview; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/PutVoteCategoryHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/PutVoteCategoryHandler.cs new file mode 100644 index 00000000..effe068e --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/PutVoteCategoryHandler.cs @@ -0,0 +1,27 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public record PutVoteCategoryRequest(long CatId, PutVoteCategoryModel Model) : IRequest; + +public class PutVoteCategoryHandler : VoteCategoriesHandlerBase, + IRequestHandler +{ + public PutVoteCategoryHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutVoteCategoryRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putVoteCategory = await GetVoteCategoryEntityAsync(request.CatId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putVoteCategory = await MapToVoteCategoryEntityAsync(request.Model, putVoteCategory, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getVoteCategory = await MapToVoteCategoryModel(putVoteCategory.CatId, cancellationToken) + ?? throw new InvalidOperationException("Updated resource not found"); + return getVoteCategory; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/ReviewsHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/ReviewsHandlerBase.cs new file mode 100644 index 00000000..f6249fe6 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/ReviewsHandlerBase.cs @@ -0,0 +1,257 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public class ReviewsHandlerBase : HandlerBase +{ + public ReviewsHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetReviewEntity(long reviewId, CancellationToken cancellationToken) + { + return await dbContext.IncidentReviews + .Include(x => x.InvolvedMembers) + .Include(x => x.InvolvedTeams) + .Include(x => x.AcceptedReviewVotes) + .ThenInclude(x => x.ReviewPenaltys) + .Where(x => x.ReviewId == reviewId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task MapToReviewEntity(LeagueUser user, PostReviewModel postModel, IncidentReviewEntity reviewEntity, CancellationToken cancellationToken) + { + reviewEntity.AuthorName = user.Name; + reviewEntity.AuthorUserId = user.Id; + reviewEntity.Corner = postModel.Corner; + reviewEntity.OnLap = postModel.OnLap; + reviewEntity.FullDescription = postModel.FullDescription; + reviewEntity.IncidentKind = postModel.IncidentKind; + reviewEntity.IncidentNr = postModel.IncidentNr; + reviewEntity.TimeStamp = postModel.TimeStamp; + reviewEntity.InvolvedMembers = await GetMemberListAsync(postModel.InvolvedMembers.Select(x => x.MemberId), cancellationToken); + reviewEntity.InvolvedTeams = await GetTeamListAsync(postModel.InvolvedTeams.Select(x => x.TeamId), cancellationToken); + reviewEntity.ResultLongText = postModel.ResultText; + reviewEntity.AcceptedReviewVotes = await MapToAcceptedVoteList(postModel.VoteResults, reviewEntity.AcceptedReviewVotes, cancellationToken); + return UpdateVersionEntity(user, reviewEntity); + } + + protected virtual async Task GetAddPenaltyEntity(long addPenaltyId, CancellationToken cancellationToken) + { + return await dbContext.AddPenaltys + .Where(x => x.AddPenaltyId == addPenaltyId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task MapToAddPenaltyEntity(PostPenaltyModel postPenalty, AddPenaltyEntity penaltyEntity, CancellationToken cancellationToken) + { + penaltyEntity.Corner = postPenalty.Corner; + penaltyEntity.Lap = postPenalty.Lap; + penaltyEntity.Reason = postPenalty.Reason; + penaltyEntity.Value = new() + { + Type = postPenalty.Type, + Points = postPenalty.Points, + Positions = postPenalty.Positions, + Time = postPenalty.Time, + }; + return await Task.FromResult(penaltyEntity); + } + + protected virtual async Task> MapToAcceptedVoteList(IEnumerable voteModels, + ICollection voteEntities, CancellationToken cancellationToken) + { + // Map votes + foreach (var voteModel in voteModels) + { + var voteEntity = voteEntities + .FirstOrDefault(x => x.ReviewVoteId == voteModel.Id && voteModel.Id != 0); + if (voteEntity == null) + { + voteEntity = new AcceptedReviewVoteEntity(); + voteEntities.Add(voteEntity); + } + await MapToAcceptedReviewVoteEntityAsync(voteModel, voteEntity, cancellationToken); + } + // Delete votes that are no longer in source collection + var deleteVotes = voteEntities + .Where(x => voteModels.Any(y => y.Id == x.ReviewVoteId) == false); + foreach (var deleteVote in deleteVotes) + { + dbContext.Remove(deleteVote); + } + return voteEntities; + } + + protected virtual async Task MapToAcceptedReviewVoteEntityAsync(VoteModel voteModel, AcceptedReviewVoteEntity voteEntity, + CancellationToken cancellationToken) + { + voteEntity.Description = voteModel.Description; + voteEntity.MemberAtFault = await GetMemberEntityAsync(voteModel.MemberAtFault?.MemberId, cancellationToken); + voteEntity.TeamAtFault = await GetTeamEntityAsync(voteModel.TeamAtFault?.TeamId, cancellationToken); + voteEntity.VoteCategory = await GetVoteCategoryEntityAsync(voteEntity.LeagueId, voteModel.VoteCategoryId, cancellationToken); + return voteEntity; + } + + protected virtual async Task MapToReviewModel(long reviewId, bool includeComments, CancellationToken cancellationToken) + { + var query = dbContext.IncidentReviews + .Where(x => x.ReviewId == reviewId) + .Select(MapToReviewModelExpression(includeComments)); + return await query.FirstOrDefaultAsync(cancellationToken); + } + + protected Expression> MapToReviewModelExpression(bool includeComments) => review => new ReviewModel() + { + LeagueId = review.LeagueId, + ReviewId = review.ReviewId, + SessionId = review.SessionId, + SessionNr = review.Session.SessionNr, + SessionName = review.Session.Name, + EventId = review.Session.EventId, + SeasonId = review.Session.Event.Schedule.SeasonId, + AuthorName = review.AuthorName, + AuthorUserId = review.AuthorUserId, + Corner = review.Corner, + FullDescription = review.FullDescription, + IncidentKind = review.IncidentKind, + IncidentNr = review.IncidentNr, + OnLap = review.OnLap, + ReviewComments = includeComments ? review.Comments.Select(comment => new ReviewCommentModel() + { + CommentId = comment.CommentId, + AuthorName = comment.AuthorName, + AuthorUserId = comment.AuthorUserId, + Date = TreatAsUTCDateTime(comment.Date), + LeagueId = comment.LeagueId, + ReviewId = comment.ReviewId.GetValueOrDefault(), + Text = comment.Text, + Votes = comment.ReviewCommentVotes.Select(vote => new VoteModel() + { + Id = vote.ReviewVoteId, + VoteCategoryId = vote.VoteCategoryId.GetValueOrDefault(), + VoteCategoryText = vote.VoteCategory.Text, + Description = vote.Description, + MemberAtFault = vote.MemberAtFault == null ? null : new MemberInfoModel() + { + MemberId = vote.MemberAtFault.Id, + FirstName = vote.MemberAtFault.Firstname, + LastName = vote.MemberAtFault.Lastname, + }, + }).ToList(), + CreatedByUserId = comment.CreatedByUserId, + CreatedByUserName = comment.CreatedByUserName, + CreatedOn = TreatAsUTCDateTime(comment.CreatedOn), + LastModifiedByUserId = comment.LastModifiedByUserId, + LastModifiedByUserName = comment.LastModifiedByUserName, + LastModifiedOn = TreatAsUTCDateTime(comment.LastModifiedOn), + }) : Array.Empty(), + InvolvedMembers = review.InvolvedMembers.Select(member => new MemberInfoModel() + { + MemberId = member.Id, + FirstName = member.Firstname, + LastName = member.Lastname, + }).ToList(), + InvolvedTeams = review.InvolvedTeams.Select(team => new TeamInfoModel() + { + TeamId = team.TeamId, + Name = team.Name, + TeamColor = team.TeamColor, + }).ToList(), + ResultText = review.ResultLongText, + VoteResults = review.AcceptedReviewVotes.Select(vote => new VoteModel() + { + Id = vote.ReviewVoteId, + VoteCategoryId = vote.VoteCategoryId.GetValueOrDefault(), + VoteCategoryText = vote.VoteCategory.Text, + Description = vote.Description, + MemberAtFault = vote.MemberAtFault != null ? new MemberInfoModel() + { + MemberId = vote.MemberAtFault.Id, + FirstName = vote.MemberAtFault.Firstname, + LastName = vote.MemberAtFault.Lastname, + } : default, + TeamAtFault = vote.TeamAtFault != null ? new TeamInfoModel() + { + TeamId = vote.TeamAtFault.TeamId, + Name = vote.TeamAtFault.Name, + TeamColor = vote.TeamAtFault.TeamColor, + } : default, + }).ToList(), + TimeStamp = review.TimeStamp, + CreatedByUserId = review.CreatedByUserId, + CreatedByUserName = review.CreatedByUserName, + CreatedOn = TreatAsUTCDateTime(review.CreatedOn), + LastModifiedByUserId = review.LastModifiedByUserId, + LastModifiedByUserName = review.LastModifiedByUserName, + LastModifiedOn = TreatAsUTCDateTime(review.LastModifiedOn), + }; + + protected Expression> MapToReviewPenaltyModelExpression => penalty => new() + { + ResultRowId = penalty.ResultRowId, + ReviewId = penalty.ReviewId, + ReviewVoteId = penalty.ReviewVoteId, + Lap = penalty.Review.OnLap, + Corner = penalty.Review.Corner, + EventId = penalty.ResultRow.ScoredSessionResult.ScoredEventResult.EventId, + SessionNr = penalty.ResultRow.ScoredSessionResult.SessionNr, + SessionName = penalty.ResultRow.ScoredSessionResult.Name, + Member = penalty.ResultRow.Member == null ? default : new() + { + MemberId = penalty.ResultRow.Member.Id, + FirstName = penalty.ResultRow.Member.Firstname, + LastName = penalty.ResultRow.Member.Lastname, + }, + Team = penalty.ResultRow.Team == null ? default : new() + { + TeamId = penalty.ResultRow.Team.TeamId, + Name = penalty.ResultRow.Team.Name, + TeamColor = penalty.ResultRow.Team.TeamColor, + }, + Reason = $"{penalty.ReviewVote.VoteCategory.Text} - {penalty.Review.IncidentKind}", + Type = penalty.Value.Type, + Points = (int)penalty.Value.Points, + Time = penalty.Value.Time, + Positions = penalty.Value.Positions, + }; + + protected async Task MapToAddPenaltyModel(long addPenaltyId, CancellationToken cancellationToken) + { + return await dbContext.AddPenaltys + .Where(x => x.AddPenaltyId == addPenaltyId) + .Select(MapToAddPenaltyModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } + protected Expression> MapToAddPenaltyModelExpression => penalty => new() + { + ResultRowId = penalty.ScoredResultRowId, + AddPenaltyId = penalty.AddPenaltyId, + Lap = penalty.Lap, + Corner = penalty.Corner, + Member = penalty.ScoredResultRow.Member == null ? default : new() + { + MemberId = penalty.ScoredResultRow.Member.Id, + FirstName = penalty.ScoredResultRow.Member.Firstname, + LastName = penalty.ScoredResultRow.Member.Lastname, + }, + Team = penalty.ScoredResultRow.Team == null ? default : new() + { + TeamId = penalty.ScoredResultRow.Team.TeamId, + Name = penalty.ScoredResultRow.Team.Name, + TeamColor = penalty.ScoredResultRow.Team.TeamColor, + }, + EventId = penalty.ScoredResultRow.ScoredSessionResult.ScoredEventResult.EventId, + SessionNr = penalty.ScoredResultRow.ScoredSessionResult.SessionNr, + SessionName = penalty.ScoredResultRow.ScoredSessionResult.Name, + Reason = penalty.Reason, + Type = penalty.Value.Type, + Points = (int)penalty.Value.Points, + Time = penalty.Value.Time, + Positions = penalty.Value.Positions, + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Reviews/VoteCategoriesHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Reviews/VoteCategoriesHandlerBase.cs new file mode 100644 index 00000000..afa0ef94 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Reviews/VoteCategoriesHandlerBase.cs @@ -0,0 +1,49 @@ +using iRLeagueApiCore.Common.Models.Reviews; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Reviews; + +public class VoteCategoriesHandlerBase : HandlerBase +{ + public VoteCategoriesHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetVoteCategoryEntityAsync(long catId, CancellationToken cancellationToken) + { + return await dbContext.VoteCategories + .Where(x => x.CatId == catId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task> GetCategoryEntitiesAsync(CancellationToken cancellationToken) + { + return await dbContext.VoteCategories + .ToListAsync(cancellationToken); + } + + protected virtual async Task MapToVoteCategoryEntityAsync(PostVoteCategoryModel model, VoteCategoryEntity target, CancellationToken cancellationToken) + { + target.DefaultPenalty = model.DefaultPenalty; + target.Index = model.Index; + target.Text = model.Text; + return await Task.FromResult(target); + } + + protected virtual async Task MapToVoteCategoryModel(long catId, CancellationToken cancellationToken) + { + return await dbContext.VoteCategories + .Where(x => x.CatId == catId) + .Select(MapToVoteCategoryModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual Expression> MapToVoteCategoryModelExpression => cat => new VoteCategoryModel() + { + Id = cat.CatId, + DefaultPenalty = cat.DefaultPenalty, + Index = cat.Index, + Text = cat.Text, + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Schedules/DeleteScheduleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Schedules/DeleteScheduleHandler.cs new file mode 100644 index 00000000..8c988fe7 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Schedules/DeleteScheduleHandler.cs @@ -0,0 +1,27 @@ +namespace iRLeagueApiCore.Server.Handlers.Schedules; + +public record DeleteScheduleRequest(long ScheduleId) : IRequest; + +public sealed class DeleteScheduleHandler : ScheduleHandlerBase, IRequestHandler +{ + public DeleteScheduleHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteScheduleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + await DeleteSchedule(request.ScheduleId, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } + + private async Task DeleteSchedule(long scheduleId, CancellationToken cancellationToken) + { + var schedule = await dbContext.Schedules + .SingleOrDefaultAsync(x => x.ScheduleId == scheduleId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.Remove(schedule); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Schedules/GetScheduleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Schedules/GetScheduleHandler.cs new file mode 100644 index 00000000..647f88ae --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Schedules/GetScheduleHandler.cs @@ -0,0 +1,21 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Schedules; + +public record GetScheduleRequest(long ScheduleId) : IRequest; + +public sealed class GetScheduleHandler : ScheduleHandlerBase, + IRequestHandler +{ + public GetScheduleHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task Handle(GetScheduleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getSchedule = await MapToGetScheduleModelAsync(request.ScheduleId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getSchedule; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Schedules/GetSchedulesFromSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Schedules/GetSchedulesFromSeasonHandler.cs new file mode 100644 index 00000000..7d2f20e7 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Schedules/GetSchedulesFromSeasonHandler.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Schedules; + +public record GetSchedulesFromSeasonRequest(long SeasonId) : IRequest>; + +public sealed class GetSchedulesFromSeasonHandler : ScheduleHandlerBase, + IRequestHandler> +{ + public GetSchedulesFromSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetSchedulesFromSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getSchedules = await MapToGetScheduleModelsAsync(request.SeasonId, cancellationToken); + return getSchedules; + } + + private async Task> MapToGetScheduleModelsAsync(long seasonId, CancellationToken cancellationToken) + { + return await dbContext.Schedules + .Where(x => x.SeasonId == seasonId) + .Select(MapToGetScheduleModelExpression) + .ToListAsync(); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Schedules/GetSchedulesHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Schedules/GetSchedulesHandler.cs new file mode 100644 index 00000000..446d84e5 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Schedules/GetSchedulesHandler.cs @@ -0,0 +1,30 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Schedules; + +public record GetSchedulesRequest() : IRequest>; + +public sealed class GetSchedulesHandler : ScheduleHandlerBase, IRequestHandler> +{ + public GetSchedulesHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetSchedulesRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getSchedules = await MapToGetScheduleModelsAsync(cancellationToken); + if (getSchedules.Count() == 0) + { + throw new ResourceNotFoundException(); + } + return getSchedules; + } + + private async Task> MapToGetScheduleModelsAsync(CancellationToken cancellationToken) + { + return await dbContext.Schedules + .Select(MapToGetScheduleModelExpression) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Schedules/PostScheduleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Schedules/PostScheduleHandler.cs new file mode 100644 index 00000000..5d77e901 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Schedules/PostScheduleHandler.cs @@ -0,0 +1,40 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Schedules; + +public record PostScheduleRequest(long seasonId, LeagueUser User, PostScheduleModel Model) : IRequest; + +public sealed class PostScheduleHandler : ScheduleHandlerBase, + IRequestHandler +{ + public PostScheduleHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task Handle(PostScheduleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postSchedule = await CreateScheduleEntityAsync(request.seasonId, request.User, cancellationToken); + postSchedule = MapToScheduleEntity(request.User, request.Model, postSchedule); + await dbContext.SaveChangesAsync(cancellationToken); + var getSchedule = await MapToGetScheduleModelAsync(postSchedule.ScheduleId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getSchedule; + } + + private async Task CreateScheduleEntityAsync(long seasonId, LeagueUser user, CancellationToken cancellationToken) + { + var scheduleEntity = new ScheduleEntity() + { + CreatedByUserId = user.Id, + CreatedByUserName = user.Name, + CreatedOn = DateTime.UtcNow + }; + var season = await dbContext.Seasons + .SingleOrDefaultAsync(x => x.SeasonId == seasonId) + ?? throw new ResourceNotFoundException(); + season.Schedules.Add(scheduleEntity); + return scheduleEntity; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Schedules/PutScheduleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Schedules/PutScheduleHandler.cs new file mode 100644 index 00000000..4d498a02 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Schedules/PutScheduleHandler.cs @@ -0,0 +1,26 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Schedules; + +public record PutScheduleRequest(LeagueUser User, long ScheduleId, PutScheduleModel Model) : IRequest; + +public sealed class PutScheduleHandler : ScheduleHandlerBase, + IRequestHandler +{ + public PutScheduleHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task Handle(PutScheduleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putSchedule = await GetScheduleEntityAsync(request.ScheduleId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putSchedule = MapToScheduleEntity(request.User, request.Model, putSchedule); + await dbContext.SaveChangesAsync(cancellationToken); + var getSchedule = await MapToGetScheduleModelAsync(request.ScheduleId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getSchedule; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Schedules/ScheduleHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Schedules/ScheduleHandlerBase.cs new file mode 100644 index 00000000..ea42d743 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Schedules/ScheduleHandlerBase.cs @@ -0,0 +1,46 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Schedules; + +public class ScheduleHandlerBase : HandlerBase +{ + public ScheduleHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual ScheduleEntity MapToScheduleEntity(LeagueUser user, PutScheduleModel postSchedule, ScheduleEntity target) + { + target.Name = postSchedule.Name; + target.LastModifiedByUserId = user.Id; + target.LastModifiedByUserName = user.Name; + target.LastModifiedOn = DateTime.UtcNow; + target.Version++; + return target; + } + + protected virtual async Task MapToGetScheduleModelAsync(long scheduleId, CancellationToken cancellationToken) + { + return await dbContext.Schedules + .Where(x => x.ScheduleId == scheduleId) + .Select(MapToGetScheduleModelExpression) + .SingleOrDefaultAsync(cancellationToken); + } + + protected virtual Expression> MapToGetScheduleModelExpression => x => new ScheduleModel() + { + LeagueId = x.LeagueId, + ScheduleId = x.ScheduleId, + SeasonId = x.SeasonId, + Name = x.Name, + EventIds = x.Events.Select(x => x.EventId), + CreatedOn = TreatAsUTCDateTime(x.CreatedOn), + CreatedByUserId = x.CreatedByUserId, + CreatedByUserName = x.CreatedByUserName, + LastModifiedOn = TreatAsUTCDateTime(x.LastModifiedOn), + LastModifiedByUserId = x.LastModifiedByUserId, + LastModifiedByUserName = x.LastModifiedByUserName + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/DeletePointRuleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/DeletePointRuleHandler.cs new file mode 100644 index 00000000..bfd7ab8b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/DeletePointRuleHandler.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public record DeletePointRuleRequest(long PointRuleId) : IRequest; + +public sealed class DeletePointRuleHandler : PointRuleHandlerBase, + IRequestHandler +{ + public DeletePointRuleHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeletePointRuleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deletePointRule = await GetPointRuleEntityAsync(request.PointRuleId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.PointRules.Remove(deletePointRule); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/DeleteScoringHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/DeleteScoringHandler.cs new file mode 100644 index 00000000..0546d9a6 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/DeleteScoringHandler.cs @@ -0,0 +1,21 @@ +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public record DeleteScoringRequest(long ScoringId) : IRequest; + +public sealed class DeleteScoringHandler : ScoringHandlerBase, IRequestHandler +{ + public DeleteScoringHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteScoringRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var scoring = await GetScoringEntityAsync(request.ScoringId) ?? throw new ResourceNotFoundException(); + dbContext.Scorings.Remove(scoring); + await dbContext.SaveChangesAsync(); + _logger.LogInformation("Removed scoring {ScoringId} inside league {LeagueId} from database", + scoring.ScoringId, scoring.LeagueId); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/GetPointRuleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/GetPointRuleHandler.cs new file mode 100644 index 00000000..8170665c --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/GetPointRuleHandler.cs @@ -0,0 +1,22 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public record GetPointRuleRequest(long PointRuleId) : IRequest; + +public sealed class GetPointRuleHandler : PointRuleHandlerBase, + IRequestHandler +{ + public GetPointRuleHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetPointRuleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getPointRule = await MapToPointRuleModel(request.PointRuleId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getPointRule; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/GetScoringHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/GetScoringHandler.cs new file mode 100644 index 00000000..a2780e5f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/GetScoringHandler.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public record GetScoringRequest(long ScoringId) : IRequest; + +public sealed class GetScoringHandler : ScoringHandlerBase, IRequestHandler +{ + public GetScoringHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetScoringRequest request, CancellationToken cancellationToken = default) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + return await MapToGetScoringModelAsync(request.ScoringId, cancellationToken) ?? throw new ResourceNotFoundException(); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/GetScoringsHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/GetScoringsHandler.cs new file mode 100644 index 00000000..cb070d62 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/GetScoringsHandler.cs @@ -0,0 +1,26 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public record GetScoringsRequest() : IRequest>; + +public sealed class GetScoringsHandler : ScoringHandlerBase, IRequestHandler> +{ + public GetScoringsHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetScoringsRequest request, CancellationToken cancellationToken = default) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + return await MapToGetScoringModelsAsync(cancellationToken); + } + + private async Task> MapToGetScoringModelsAsync(CancellationToken cancellationToken = default) + { + return await dbContext.Scorings + .Select(MapToGetScoringModelExpression) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/PointRuleHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/PointRuleHandlerBase.cs new file mode 100644 index 00000000..f8bcb821 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/PointRuleHandlerBase.cs @@ -0,0 +1,55 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public class PointRuleHandlerBase : HandlerBase +{ + public PointRuleHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetPointRuleEntityAsync(long pointRuleId, CancellationToken cancellationToken) + { + return await dbContext.PointRules + .Where(x => x.PointRuleId == pointRuleId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task MapToPointRuleEntityAsync(LeagueUser user, PostPointRuleModel postPointRule, PointRuleEntity pointRuleEntity, + CancellationToken cancellationToken) + { + pointRuleEntity.BonusPoints = postPointRule.BonusPoints; + pointRuleEntity.FinalSortOptions = postPointRule.FinalSortOptions.ToList(); + pointRuleEntity.MaxPoints = postPointRule.MaxPoints; + pointRuleEntity.Name = postPointRule.Name; + pointRuleEntity.PointDropOff = postPointRule.PointDropOff; + pointRuleEntity.PointsPerPlace = postPointRule.PointsPerPlace.ToList(); + pointRuleEntity.PointsSortOptions = postPointRule.PointsSortOptions.ToList(); + UpdateVersionEntity(user, pointRuleEntity); + return await Task.FromResult(pointRuleEntity); + } + + protected virtual async Task MapToPointRuleModel(long pointRuleId, CancellationToken cancellationToken) + { + return await dbContext.PointRules + .Where(x => x.PointRuleId == pointRuleId) + .Select(MapToPointRuleModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } + + private Expression> MapToPointRuleModelExpression => pointRule => new PointRuleModel() + { + BonusPoints = pointRule.BonusPoints, + FinalSortOptions = pointRule.FinalSortOptions, + LeagueId = pointRule.LeagueId, + MaxPoints = pointRule.MaxPoints, + Name = pointRule.Name, + PointDropOff = pointRule.PointDropOff, + PointRuleId = pointRule.PointRuleId, + PointsPerPlace = pointRule.PointsPerPlace.ToList(), + PointsSortOptions = pointRule.PointsSortOptions, + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/PostPointRuleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/PostPointRuleHandler.cs new file mode 100644 index 00000000..b6efd562 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/PostPointRuleHandler.cs @@ -0,0 +1,37 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public record PostPointRuleRequest(LeagueUser User, PostPointRuleModel Model) : IRequest; + +public sealed class PostPointRuleHandler : PointRuleHandlerBase, + IRequestHandler +{ + public PostPointRuleHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(PostPointRuleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postPointRule = await CreatePointRuleEntityAsync(request.User, cancellationToken); + postPointRule = await MapToPointRuleEntityAsync(request.User, request.Model, postPointRule, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getPointRule = await MapToPointRuleModel(postPointRule.PointRuleId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getPointRule; + } + + private async Task CreatePointRuleEntityAsync(LeagueUser user, CancellationToken cancellationToken) + { + var league = await GetCurrentLeagueEntityAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var pointRule = CreateVersionEntity(user, new PointRuleEntity()); + league.PointRules.Add(pointRule); + return pointRule; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/PutPointRuleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/PutPointRuleHandler.cs new file mode 100644 index 00000000..3e7b8d6a --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/PutPointRuleHandler.cs @@ -0,0 +1,27 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public record PutPointRuleRequest(long PointRuleId, LeagueUser User, PutPointRuleModel Model) : IRequest; + +public sealed class PutPointRuleHandler : PointRuleHandlerBase, + IRequestHandler +{ + public PutPointRuleHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutPointRuleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putPointRule = await GetPointRuleEntityAsync(request.PointRuleId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putPointRule = await MapToPointRuleEntityAsync(request.User, request.Model, putPointRule, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getPointRule = await MapToPointRuleModel(putPointRule.PointRuleId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getPointRule; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/PutScoringHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/PutScoringHandler.cs new file mode 100644 index 00000000..d83d822a --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/PutScoringHandler.cs @@ -0,0 +1,25 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public record PutScoringRequest(long ScoringId, LeagueUser User, PutScoringModel Model) : IRequest; + +public sealed class PutScoringHandler : ScoringHandlerBase, IRequestHandler +{ + public PutScoringHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutScoringRequest request, CancellationToken cancellationToken = default) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putScoring = await GetScoringEntityAsync(request.ScoringId) ?? throw new ResourceNotFoundException(); + await MapToScoringEntityAsync(request.User, request.Model, putScoring, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getScoring = await MapToGetScoringModelAsync(putScoring.ScoringId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getScoring; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Scorings/ScoringHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Scorings/ScoringHandlerBase.cs new file mode 100644 index 00000000..66b469c0 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Scorings/ScoringHandlerBase.cs @@ -0,0 +1,80 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Scorings; + +public class ScoringHandlerBase : HandlerBase +{ + protected const char pointsDelimiter = ';'; + + public ScoringHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected static string ConvertBasePoints(IEnumerable points) + { + return string.Join(pointsDelimiter, points.Select(x => x.ToString())); + } + + protected static IEnumerable ConvertBasePoints(string points) + { + return points?.Split(pointsDelimiter) + .Where(x => string.IsNullOrEmpty(x) == false) + .Select(x => double.Parse(x)) ?? new double[0]; + } + + protected static string ConvertBonusPoints(IEnumerable points) + { + return string.Join(pointsDelimiter, points); + } + + protected static IEnumerable ConvertBonusPoints(string points) + { + return points? + .Split(pointsDelimiter) + .Where(x => string.IsNullOrEmpty(x) == false) ?? new string[0]; + } + + protected virtual async Task MapToScoringEntityAsync(LeagueUser user, PostScoringModel source, ScoringEntity target, + CancellationToken cancellationToken = default) + { + target.ExtScoringSource = await GetScoringEntityAsync(source.ExtScoringSourceId, cancellationToken); + target.MaxResultsPerGroup = source.MaxResultsPerGroup; + target.Name = source.Name; + target.ShowResults = source.ShowResults; + target.IsCombinedResult = source.IsCombinedResult; + target.UpdateTeamOnRecalculation = source.UpdateTeamOnRecalculation; + target.UseResultSetTeam = source.UseResultSetTeam; + return UpdateVersionEntity(user, target); + } + + protected virtual async Task MapToGetScoringModelAsync(long scoringId, CancellationToken cancellationToken = default) + { + return await dbContext.Scorings + .Where(x => x.ScoringId == scoringId) + .Select(MapToGetScoringModelExpression) + .SingleOrDefaultAsync(cancellationToken); + } + + protected Expression> MapToGetScoringModelExpression => scoring => new ScoringModel() + { + Id = scoring.ScoringId, + LeagueId = scoring.LeagueId, + ResultConfigId = scoring.ResultConfigId, + ExtScoringSourceId = scoring.ExtScoringSourceId, + MaxResultsPerGroup = scoring.MaxResultsPerGroup, + Name = scoring.Name, + ShowResults = scoring.ShowResults, + IsCombinedResult = scoring.IsCombinedResult, + UpdateTeamOnRecalculation = scoring.UpdateTeamOnRecalculation, + UseResultSetTeam = scoring.UseResultSetTeam, + CreatedByUserId = scoring.CreatedByUserId, + CreatedByUserName = scoring.CreatedByUserName, + CreatedOn = TreatAsUTCDateTime(scoring.CreatedOn), + LastModifiedByUserId = scoring.LastModifiedByUserId, + LastModifiedByUserName = scoring.LastModifiedByUserName, + LastModifiedOn = TreatAsUTCDateTime(scoring.LastModifiedOn), + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Seasons/DeleteSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Seasons/DeleteSeasonHandler.cs new file mode 100644 index 00000000..e51f6aa3 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Seasons/DeleteSeasonHandler.cs @@ -0,0 +1,41 @@ +using iRLeagueApiCore.Services.ResultService.Extensions; + +namespace iRLeagueApiCore.Server.Handlers.Seasons; + +public record DeleteSeasonRequest(long SeasonId) : IRequest; + +public sealed class DeleteSeasonHandler : SeasonHandlerBase, IRequestHandler +{ + public DeleteSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + await DeleteSeasonEntity(request.SeasonId, cancellationToken); + await dbContext.SaveChangesAsync(); + return Unit.Value; + } + + private async Task DeleteSeasonEntity(long seasonId, CancellationToken cancellationToken) + { + var deleteSeason = await dbContext.Seasons + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.ResultConfigurations) + .ThenInclude(x => x.PointFilters) + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.ResultConfigurations) + .ThenInclude(x => x.ResultFilters) + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.DefaultResultConfig) + .SingleOrDefaultAsync(x => x.SeasonId == seasonId) + ?? throw new ResourceNotFoundException(); + dbContext.RemoveRange(deleteSeason.ChampSeasons.SelectMany(x => x.ResultConfigurations).SelectMany(x => x.PointFilters)); + dbContext.RemoveRange(deleteSeason.ChampSeasons.SelectMany(x => x.ResultConfigurations).SelectMany(x => x.ResultFilters)); + dbContext.RemoveRange(deleteSeason.ChampSeasons.SelectMany(x => x.ResultConfigurations)); + deleteSeason.ChampSeasons.ForEach(x => x.DefaultResultConfig = null); + dbContext.Seasons.Remove(deleteSeason); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Seasons/GetCurrentSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Seasons/GetCurrentSeasonHandler.cs new file mode 100644 index 00000000..c38943d6 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Seasons/GetCurrentSeasonHandler.cs @@ -0,0 +1,28 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Seasons; + +public record GetCurrentSeasonRequest() : IRequest; + +public sealed class GetCurrentSeasonHandler : SeasonHandlerBase, + IRequestHandler +{ + public GetCurrentSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetCurrentSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getSeasonId = await dbContext.Events + .Where(x => x.Date < DateTime.UtcNow) + .OrderByDescending(x => x.Date) + .Select(x => (long?)x.Schedule.SeasonId) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new ResourceNotFoundException(); + var getSeason = await MapToGetSeasonModel(getSeasonId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getSeason; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Seasons/GetSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Seasons/GetSeasonHandler.cs new file mode 100644 index 00000000..92f7f2e8 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Seasons/GetSeasonHandler.cs @@ -0,0 +1,21 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Seasons; + +public record GetSeasonRequest(long SeasonId) : IRequest; + +public sealed class GetSeasonHandler : SeasonHandlerBase, IRequestHandler +{ + public GetSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getSeason = await MapToGetSeasonModel(request.SeasonId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getSeason; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Seasons/GetSeasonsHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Seasons/GetSeasonsHandler.cs new file mode 100644 index 00000000..3e178f52 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Seasons/GetSeasonsHandler.cs @@ -0,0 +1,32 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Seasons; + +public record GetSeasonsRequest() : IRequest>; + +public sealed class GetSeasonsHandler : SeasonHandlerBase, IRequestHandler> +{ + public GetSeasonsHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetSeasonsRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getSeasons = await GetSeasonsEntityAsync(cancellationToken); + if (getSeasons.Count() == 0) + { + throw new ResourceNotFoundException(); + } + return getSeasons; + } + + private async Task> GetSeasonsEntityAsync(CancellationToken cancellationToken) + { + return (await dbContext.Seasons + .Select(MapToGetSeasonModelExpression) + .ToListAsync(cancellationToken)) + .OrderBy(x => x.SeasonStart); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Seasons/PostSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Seasons/PostSeasonHandler.cs new file mode 100644 index 00000000..8927543e --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Seasons/PostSeasonHandler.cs @@ -0,0 +1,36 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Handlers.Seasons; + +public record PostSeasonRequest(LeagueUser User, PostSeasonModel Model) : IRequest; + +public sealed class PostSeasonHandler : SeasonHandlerBase, IRequestHandler +{ + public PostSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) + : base(logger, dbContext, validators) + { + } + + public async Task Handle(PostSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + + var postSeason = await CreateSeasonEntity(request.User, dbContext.LeagueProvider.LeagueId, cancellationToken); + await MapToSeasonEntityAsync(request.User, request.Model, postSeason, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getSeason = await MapToGetSeasonModel(postSeason.SeasonId, cancellationToken) + ?? throw new InvalidOperationException($"Creating season {request.Model.SeasonName} failed"); + return getSeason; + } + + private async Task CreateSeasonEntity(LeagueUser user, long leagueId, CancellationToken cancellationToken = default) + { + var league = await dbContext.Leagues + .SingleOrDefaultAsync(x => x.Id == leagueId, cancellationToken) ?? throw new ResourceNotFoundException(); + var seasonEntity = CreateVersionEntity(user, new SeasonEntity()); + league.Seasons.Add(seasonEntity); + return seasonEntity; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Seasons/PutSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Seasons/PutSeasonHandler.cs new file mode 100644 index 00000000..1f01a09f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Seasons/PutSeasonHandler.cs @@ -0,0 +1,26 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Seasons; + +public record PutSeasonRequest(LeagueUser User, long SeasonId, PutSeasonModel Model) : IRequest; + +public sealed class PutSeasonHandler : SeasonHandlerBase, IRequestHandler +{ + public PutSeasonHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putSeason = await GetSeasonEntityAsync(request.SeasonId, cancellationToken) + ?? throw new ResourceNotFoundException(); + await MapToSeasonEntityAsync(request.User, request.Model, putSeason, cancellationToken); + await dbContext.SaveChangesAsync(); + var getSeason = await MapToGetSeasonModel(request.SeasonId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getSeason; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Seasons/SeasonHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Seasons/SeasonHandlerBase.cs new file mode 100644 index 00000000..6df734fc --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Seasons/SeasonHandlerBase.cs @@ -0,0 +1,57 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Seasons; + +public abstract class SeasonHandlerBase : HandlerBase +{ + protected SeasonHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task MapToSeasonEntityAsync(LeagueUser user, PostSeasonModel putSeason, + SeasonEntity target, CancellationToken cancellationToken) + { + target.Finished = putSeason.Finished; + target.HideCommentsBeforeVoted = putSeason.HideComments; + target.MainScoring = await GetScoringEntityAsync(putSeason.MainScoringId, cancellationToken); + target.SeasonName = putSeason.SeasonName; + return UpdateVersionEntity(user, target); + } + + protected virtual async Task MapToGetSeasonModel(long seasonId, CancellationToken cancellationToken) + { + return await dbContext.Seasons + .Where(x => x.SeasonId == seasonId) + .Select(MapToGetSeasonModelExpression) + .SingleOrDefaultAsync(); + } + + protected Expression> MapToGetSeasonModelExpression => x => new SeasonModel() + { + SeasonId = x.SeasonId, + Finished = x.Finished, + HideComments = x.HideCommentsBeforeVoted, + LeagueId = x.LeagueId, + ScheduleIds = x.Schedules.Select(x => x.ScheduleId).ToList(), + SeasonEnd = x.Schedules + .SelectMany(x => x.Events) + .Select(x => x.Date) + .OrderByDescending(x => x) + .FirstOrDefault(), + SeasonStart = x.Schedules + .SelectMany(x => x.Events) + .Select(x => x.Date) + .OrderBy(x => x) + .FirstOrDefault(), + SeasonName = x.SeasonName, + CreatedByUserId = x.CreatedByUserId, + CreatedByUserName = x.CreatedByUserName, + CreatedOn = TreatAsUTCDateTime(x.CreatedOn), + LastModifiedByUserId = x.LastModifiedByUserId, + LastModifiedByUserName = x.LastModifiedByUserName, + LastModifiedOn = TreatAsUTCDateTime(x.LastModifiedOn), + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Standings/GetStandingsFromEventHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Standings/GetStandingsFromEventHandler.cs new file mode 100644 index 00000000..0d08e6b8 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Standings/GetStandingsFromEventHandler.cs @@ -0,0 +1,35 @@ +using iRLeagueApiCore.Common.Models.Standings; + +namespace iRLeagueApiCore.Server.Handlers.Standings; + +public record GetStandingsFromEventRequest(long EventId) : IRequest>; + +public sealed class GetStandingsFromEventHandler : StandingsHandlerBase, + IRequestHandler> +{ + public GetStandingsFromEventHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetStandingsFromEventRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getStandings = await MapToStandingModelFromEventAsync(request.EventId, cancellationToken); + return getStandings; + } + + private async Task> MapToStandingModelFromEventAsync(long eventId, CancellationToken cancellationToken) + { + var standings = await dbContext.Standings + .Where(x => x.EventId == eventId) + .Select(MapToStandingModelExpression) + .ToListAsync(cancellationToken); + if (standings.Any() == false) + { + return standings; + } + standings = (await AlignStandingResultRows(standings.Select(x => x.SeasonId).First(), standings, cancellationToken)).ToList(); + return standings; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Standings/GetStandingsFromSeasonHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Standings/GetStandingsFromSeasonHandler.cs new file mode 100644 index 00000000..c3a7e3da --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Standings/GetStandingsFromSeasonHandler.cs @@ -0,0 +1,40 @@ +using iRLeagueApiCore.Common.Models.Standings; + +namespace iRLeagueApiCore.Server.Handlers.Standings; + +public record GetStandingsFromSeasonRequest(long SeasonId) : IRequest>; + +public sealed class GetStandingsFromSeasonHandler : StandingsHandlerBase, + IRequestHandler> +{ + public GetStandingsFromSeasonHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetStandingsFromSeasonRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getStandings = await MapToStandingModelFromSeasonAsync(request.SeasonId, cancellationToken); + return getStandings; + } + + private async Task> MapToStandingModelFromSeasonAsync(long seasonId, CancellationToken cancellationToken) + { + var lastEventWithStandingsId = await dbContext.Standings + .Where(x => x.SeasonId == seasonId) + .OrderByDescending(x => x.Event.Date) + .Select(x => x.EventId) + .FirstOrDefaultAsync(cancellationToken); + var standings = await dbContext.Standings + .Where(x => x.EventId == lastEventWithStandingsId) + .Select(MapToStandingModelExpression) + .ToListAsync(cancellationToken); + if (standings.Any() == false) + { + return standings; + } + standings = (await AlignStandingResultRows(seasonId, standings, cancellationToken)).ToList(); + return standings; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Standings/StandingsHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Standings/StandingsHandlerBase.cs new file mode 100644 index 00000000..172ff024 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Standings/StandingsHandlerBase.cs @@ -0,0 +1,110 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Standings; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Standings; + +public class StandingsHandlerBase : HandlerBase +{ + public StandingsHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + /// + /// Align the result rows of each standing row so that the sequence in the collection is + /// correlating with the event calendar. + /// That means that for each event in the calendar an entry in the resultRows collection will be created but it will be + /// null if the driver did not participate in this event. + /// + /// + /// + /// + /// + protected async Task> AlignStandingResultRows(long seasonId, IEnumerable standings, + CancellationToken cancellationToken) + { + var events = await dbContext.Events + .Where(x => x.Schedule.SeasonId == seasonId) + .OrderBy(x => x.Date) + .ToListAsync(cancellationToken); + foreach (var standingRow in standings.SelectMany(x => x.StandingRows)) + { + standingRow.ResultRows = events.Select(x => standingRow.ResultRows.FirstOrDefault(y => y?.EventId == x.EventId)).ToList(); + } + return standings; + } + + protected Expression> MapToStandingModelExpression => standing => new StandingsModel() + { + LeagueId = standing.LeagueId, + SeasonId = standing.SeasonId, + Name = standing.Name, + IsTeamStanding = standing.IsTeamStanding, + StandingId = standing.StandingId, + StandingRows = standing.StandingRows + .OrderBy(x => x.Position) + .Select(standingRow => new StandingRowModel() + { + CarClass = standingRow.CarClass, + ClassId = standingRow.ClassId, + CompletedLaps = standingRow.CompletedLaps, + CompletedLapsChange = standingRow.CompletedLapsChange, + DroppedResultCount = standingRow.DroppedResultCount, + FastestLapsChange = standingRow.FastestLapsChange, + FastestLaps = standingRow.FastestLaps, + Firstname = standingRow.Member == null ? string.Empty : standingRow.Member.Firstname, + Incidents = standingRow.Incidents, + IncidentsChange = standingRow.IncidentsChange, + MemberId = standingRow.MemberId, + StandingRowId = standingRow.StandingRowId, + Lastname = standingRow.Member == null ? string.Empty : standingRow.Member.Lastname, + LastIrating = standingRow.LastIrating, + LastPosition = standingRow.LastPosition, + LeadLaps = standingRow.LeadLaps, + LeadLapsChange = standingRow.LeadLapsChange, + PenaltyPoints = standingRow.PenaltyPoints, + PenaltyPointsChange = standingRow.PenaltyPointsChange, + PolePositions = standingRow.PolePositions, + PolePositionsChange = standingRow.PolePositionsChange, + Position = standingRow.Position, + PositionChange = standingRow.PositionChange, + RacePoints = standingRow.RacePoints, + RacePointsChange = standingRow.RacePointsChange, + Races = standingRow.Races, + RacesCounted = standingRow.RacesCounted, + RacesScored = standingRow.RacesScored, + RacesInPoints = standingRow.RacesInPoints, + StartIrating = standingRow.StartIrating, + TeamColor = standingRow.Team == null ? string.Empty : standingRow.Team.TeamColor, + TeamId = standingRow.TeamId, + TeamName = standingRow.Team == null ? string.Empty : standingRow.Team.Name, + Top10 = standingRow.Top10, + Top3 = standingRow.Top3, + Top5 = standingRow.Top5, + TotalPoints = standingRow.TotalPoints, + TotalPointsChange = standingRow.TotalPointsChange, + Wins = standingRow.Wins, + WinsChange = standingRow.WinsChange, + ResultRows = standingRow.ResultRows.Select(standingResultRow => new StandingResultRowModel() + { + EventId = standingResultRow.ScoredResultRow.ScoredSessionResult.ScoredEventResult.EventId, + Date = standingResultRow.ScoredResultRow.ScoredSessionResult.ScoredEventResult.Event.Date != null ? + standingResultRow.ScoredResultRow.ScoredSessionResult.ScoredEventResult.Event.Date!.Value : DateTime.MinValue, + BonusPoints = standingResultRow.ScoredResultRow.BonusPoints, + CompletedLaps = standingResultRow.ScoredResultRow.CompletedLaps, + FinalPosition = standingResultRow.ScoredResultRow.FinalPosition, + FinishPosition = standingResultRow.ScoredResultRow.FinishPosition, + Incidents = standingResultRow.ScoredResultRow.Incidents, + Irating = standingResultRow.ScoredResultRow.OldIRating, + PenaltyPoints = standingResultRow.ScoredResultRow.PenaltyPoints, + RacePoints = standingResultRow.ScoredResultRow.RacePoints, + SeasonStartIrating = standingResultRow.ScoredResultRow.SeasonStartIRating, + StartPosition = standingResultRow.ScoredResultRow.StartPosition, + Status = standingResultRow.ScoredResultRow.Status, + TotalPoints = standingResultRow.ScoredResultRow.TotalPoints, + IsScored = standingResultRow.IsScored, + }).ToList(), + }).ToList(), + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Teams/DeleteTeamHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Teams/DeleteTeamHandler.cs new file mode 100644 index 00000000..0781f073 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Teams/DeleteTeamHandler.cs @@ -0,0 +1,22 @@ +namespace iRLeagueApiCore.Server.Handlers.Teams; + +public record DeleteTeamRequest(long TeamId) : IRequest; + +public class DeleteTeamHandler : TeamsHandlerBase, + IRequestHandler +{ + public DeleteTeamHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(DeleteTeamRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var deleteTeam = await GetTeamEntity(request.TeamId, cancellationToken) + ?? throw new ResourceNotFoundException(); + dbContext.Teams.Remove(deleteTeam); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Teams/GetTeamHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Teams/GetTeamHandler.cs new file mode 100644 index 00000000..1e1e6c05 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Teams/GetTeamHandler.cs @@ -0,0 +1,22 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Teams; + +public record GetTeamRequest(long teamId) : IRequest; + +public class GetTeamHandler : TeamsHandlerBase, + IRequestHandler +{ + public GetTeamHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(GetTeamRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getTeam = await MapToTeamModel(request.teamId, cancellationToken) + ?? throw new ResourceNotFoundException(); + return getTeam; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Teams/GetTeamsFromLeagueHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Teams/GetTeamsFromLeagueHandler.cs new file mode 100644 index 00000000..fd1f5b43 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Teams/GetTeamsFromLeagueHandler.cs @@ -0,0 +1,28 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Handlers.Teams; + +public record GetTeamsFromLeagueRequest() : IRequest>; + +public sealed class GetTeamsFromLeagueHandler : TeamsHandlerBase, + IRequestHandler> +{ + public GetTeamsFromLeagueHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetTeamsFromLeagueRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getTeams = await MapToTeamModels(cancellationToken); + return getTeams; + } + + private async Task> MapToTeamModels(CancellationToken cancellationToken) + { + return await dbContext.Teams + .Select(MapToTeamModelExpression) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Teams/PostTeamHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Teams/PostTeamHandler.cs new file mode 100644 index 00000000..e3699a48 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Teams/PostTeamHandler.cs @@ -0,0 +1,26 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Teams; + +public record PostTeamRequest(LeagueUser User, PostTeamModel Model) : IRequest; + +public class PostTeamHandler : TeamsHandlerBase, + IRequestHandler +{ + public PostTeamHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PostTeamRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var postTeam = await CreateTeamEntity(request.User, cancellationToken); + postTeam = await MapToTeamEntityAsync(request.User, request.Model, postTeam, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getTeam = await MapToTeamModel(postTeam.TeamId, cancellationToken) + ?? throw new InvalidOperationException("Failed to fetch created team resource"); + return getTeam; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Teams/PutTeamHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Teams/PutTeamHandler.cs new file mode 100644 index 00000000..ea350d41 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Teams/PutTeamHandler.cs @@ -0,0 +1,27 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; + +namespace iRLeagueApiCore.Server.Handlers.Teams; + +public record PutTeamRequest(long TeamId, LeagueUser User, PutTeamModel Model) : IRequest; + +public class PutTeamHandler : TeamsHandlerBase, + IRequestHandler +{ + public PutTeamHandler(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + public async Task Handle(PutTeamRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var putTeam = await GetTeamEntity(request.TeamId, cancellationToken) + ?? throw new ResourceNotFoundException(); + putTeam = await MapToTeamEntityAsync(request.User, request.Model, putTeam, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + var getTeam = await MapToTeamModel(request.TeamId, cancellationToken) + ?? throw new InvalidOperationException("Created resource was not found"); + return getTeam; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Teams/TeamsHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Teams/TeamsHandlerBase.cs new file mode 100644 index 00000000..8aefd852 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Teams/TeamsHandlerBase.cs @@ -0,0 +1,84 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Models; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Teams; + +public abstract class TeamsHandlerBase : HandlerBase +{ + protected TeamsHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected virtual async Task GetTeamEntity(long teamId, CancellationToken cancellationToken) + { + return await dbContext.Teams + .Include(x => x.Members) + .Where(x => x.TeamId == teamId) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual async Task CreateTeamEntity(LeagueUser user, CancellationToken cancellationToken) + { + var leagueId = dbContext.LeagueProvider.LeagueId; + var league = await dbContext.Leagues + .FirstOrDefaultAsync(x => x.Id == leagueId, cancellationToken); + if (league is null) + { + throw new InvalidOperationException($"League with id: {leagueId} does not exist"); + } + + var team = CreateVersionEntity(user, new TeamEntity()); + team.League = league; + team.LeagueId = leagueId; + league.Teams.Add(team); + return team; + } + + protected virtual async Task MapToTeamEntityAsync(LeagueUser user, PostTeamModel model, TeamEntity entity, CancellationToken cancellationToken) + { + entity.Name = model.Name; + entity.Profile = model.Profile; + entity.TeamColor = model.TeamColor; + entity.TeamHomepage = model.TeamHomepage; + entity.Members = await MapToTeamMemberListAsync(model.Members, entity.Members, cancellationToken); + entity.IRacingTeamId = model.IRacingTeamId; + return UpdateVersionEntity(user, entity); + } + + private async Task> MapToTeamMemberListAsync(ICollection memberModels, + ICollection memberEntities, CancellationToken cancellationToken) + { + var memberIds = memberModels.Select(x => x.MemberId); + var leagueMembers = await dbContext.LeagueMembers + .Where(x => memberIds.Contains(x.MemberId)) + .ToListAsync(cancellationToken); + + return leagueMembers.ToList(); + } + + protected virtual async Task MapToTeamModel(long teamId, CancellationToken cancellationToken) + { + return await dbContext.Teams + .Where(x => teamId == x.TeamId) + .Select(MapToTeamModelExpression) + .FirstOrDefaultAsync(cancellationToken); + } + + protected virtual Expression> MapToTeamModelExpression => team => new() + { + Members = team.Members.Select(leagueMember => new MemberInfoModel() + { + FirstName = leagueMember.Member.Firstname, + LastName = leagueMember.Member.Lastname, + MemberId = leagueMember.Member.Id, + }).ToList(), + TeamColor = team.TeamColor, + TeamHomepage = team.TeamHomepage, + TeamId = team.TeamId, + IRacingTeamId = team.IRacingTeamId, + Name = team.Name, + Profile = team.Profile, + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Tracks/GetTracksHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Tracks/GetTracksHandler.cs new file mode 100644 index 00000000..f3559bab --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Tracks/GetTracksHandler.cs @@ -0,0 +1,21 @@ +using iRLeagueApiCore.Common.Models.Tracks; + +namespace iRLeagueApiCore.Server.Handlers.Tracks; + +public record GetTracksRequest() : IRequest>; + +public sealed class GetTracksHandler : TracksHandlerBase, + IRequestHandler> +{ + public GetTracksHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators) : base(logger, dbContext, validators) + { + } + + public async Task> Handle(GetTracksRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var getTracks = await MapToTrackGroupModels(cancellationToken); + return getTracks; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Tracks/ImportTracksHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Tracks/ImportTracksHandler.cs new file mode 100644 index 00000000..d44beb5d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Tracks/ImportTracksHandler.cs @@ -0,0 +1,104 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Server.Models; +using iRLeagueApiCore.TrackImport.Models; +using iRLeagueApiCore.TrackImport.Service; + +namespace iRLeagueApiCore.Server.Handlers.Tracks; + +public record ImportTracksCommand(IracingAuthModel Model) : IRequest; + +public sealed class ImportTracksHandler : HandlerBase, + IRequestHandler +{ + private readonly TrackImportService trackImportService; + + public ImportTracksHandler(ILogger logger, LeagueDbContext dbContext, + IEnumerable> validators, TrackImportService trackImportService) : base(logger, dbContext, validators) + { + this.trackImportService = trackImportService; + } + + public async Task Handle(ImportTracksCommand request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + await AuthenticateService(request.Model, trackImportService, cancellationToken); + var importTracks = await trackImportService.GetTracksData(cancellationToken); + await UpdateTracksInDatabase(dbContext, importTracks, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + return Unit.Value; + } + + private static async Task AuthenticateService(IracingAuthModel authData, TrackImportService trackImportService, CancellationToken cancellationToken) + { + var userName = authData.UserName; + var password = authData.Password; + var result = await trackImportService.Authenticate(userName, password, cancellationToken); + return true; + } + + private async Task UpdateTracksInDatabase(LeagueDbContext dbContext, IEnumerable importTracks, CancellationToken cancellationToken) + { + foreach (var importTrack in importTracks) + { + var trackConfig = dbContext.TrackConfigs.Local + .FirstOrDefault(x => x.TrackId == importTrack.track_id) + ?? await dbContext.TrackConfigs + .Include(x => x.TrackGroup) + .FirstOrDefaultAsync(x => x.TrackId == importTrack.track_id, cancellationToken); + var trackGroup = trackConfig?.TrackGroup + ?? dbContext.TrackGroups.Local.FirstOrDefault(x => x.TrackName == importTrack.track_name) + ?? await dbContext.TrackGroups.FirstOrDefaultAsync(x => x.TrackName == importTrack.track_name, cancellationToken); + if (trackGroup == null) + { + _logger.LogInformation("Track {TrackName} does not exist and will be created", importTrack.track_name); + trackGroup = new TrackGroupEntity() + { + Location = importTrack.location, + TrackName = importTrack.track_name, + }; + dbContext.TrackGroups.Add(trackGroup); + } + if (trackConfig == null) + { + _logger.LogInformation("TrackConfig with id: {TrackId} does not exist and will be created", importTrack.track_id); + trackConfig = new TrackConfigEntity() + { + TrackGroup = trackGroup, + TrackId = importTrack.track_id, + }; + dbContext.TrackConfigs.Add(trackConfig); + } + + trackConfig = MapToTrackConfigEntity(importTrack, trackConfig); + _logger.LogInformation("Updated data for track id: {TrackId}, track: {TrackName}, config: {ConfigName}", + trackConfig.TrackId, trackConfig.TrackGroup.TrackName, trackConfig.ConfigName); + } + } + + private static TrackConfigEntity MapToTrackConfigEntity(TrackImportModel importTrack, TrackConfigEntity entity) + { + entity.ConfigName = importTrack.config_name ?? "-"; + entity.ConfigType = GetConfigType(importTrack.track_types?[0].track_type ?? string.Empty); + entity.HasNightLighting = importTrack.night_lighting; + entity.LengthKm = importTrack.track_config_length * TrackImportService.m2km; + entity.Turns = importTrack.corners_per_lap; + return entity; + } + + private static ConfigType GetConfigType(string typeString) + { + switch (typeString) + { + case "road": + return ConfigType.Road; + case "oval": + return ConfigType.Oval; + case "dirt_oval": + return ConfigType.DirtOval; + case "dirt_road": + return ConfigType.DirtRoad; + default: + return ConfigType.Unknown; + } + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Tracks/TracksHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Tracks/TracksHandlerBase.cs new file mode 100644 index 00000000..fcd51bdd --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Tracks/TracksHandlerBase.cs @@ -0,0 +1,35 @@ +using iRLeagueApiCore.Common.Models.Tracks; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Server.Handlers.Tracks; + +public class TracksHandlerBase : HandlerBase +{ + public TracksHandlerBase(ILogger logger, LeagueDbContext dbContext, IEnumerable> validators) : + base(logger, dbContext, validators) + { + } + + protected async Task> MapToTrackGroupModels(CancellationToken cancellationToken) + { + return await dbContext.TrackGroups + .Select(MapToTrackGroupExpression) + .ToListAsync(cancellationToken); + } + + protected static Expression> MapToTrackGroupExpression => group => new TrackGroupModel() + { + TrackGroupId = group.TrackGroupId, + TrackName = group.TrackName, + Configs = group.TrackConfigs.Select(config => new TrackConfigModel() + { + TrackId = config.TrackId, + ConfigName = config.ConfigName, + Turns = config.Turns, + TrackName = group.TrackName, + Type = config.ConfigType, + HasNightLighting = config.HasNightLighting, + Length = config.LengthKm, + }) + }; +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/AddLeagueRoleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/AddLeagueRoleHandler.cs new file mode 100644 index 00000000..547c64ef --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/AddLeagueRoleHandler.cs @@ -0,0 +1,39 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record AddLeagueRoleRequest(string LeagueName, string UserId, string RoleName) : IRequest; + +public sealed class AddLeagueRoleHandler : UsersHandlerBase, + IRequestHandler +{ + private readonly RoleManager roleManager; + + public AddLeagueRoleHandler(ILogger logger, UserManager userManager, + RoleManager roleManager, IEnumerable> validators) : base(logger, userManager, validators) + { + this.roleManager = roleManager; + } + + public async Task Handle(AddLeagueRoleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await GetUserAsync(request.UserId) + ?? throw new ResourceNotFoundException(); + await AddLeagueRoleToUser(user, request.LeagueName, request.RoleName); + var getUser = await MapToLeagueUserModelAsync(user, request.LeagueName, new()); + return getUser; + } + + private async Task AddLeagueRoleToUser(ApplicationUser user, string leagueName, string roleName) + { + var leagueRoleName = LeagueRoles.GetLeagueRoleName(leagueName, roleName); + if (await roleManager.RoleExistsAsync(leagueRoleName) == false) + { + await roleManager.CreateAsync(new() { Name = leagueRoleName }); + } + await userManager.AddToRoleAsync(user, leagueRoleName); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/ConfirmEmailHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/ConfirmEmailHandler.cs new file mode 100644 index 00000000..3d2ec8c7 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/ConfirmEmailHandler.cs @@ -0,0 +1,31 @@ +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record ConfirmEmailRequest(string UserId, string EmailConfirmationToken) : IRequest<(bool success, string status)>; + +public class ConfirmEmailHandler : IRequestHandler +{ + private readonly UserManager userManager; + private readonly IEnumerable> validators; + + public ConfirmEmailHandler(UserManager userManager, IEnumerable> validators) + { + this.userManager = userManager; + this.validators = validators; + } + + public async Task<(bool success, string status)> Handle(ConfirmEmailRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await userManager.FindByIdAsync(request.UserId) + ?? throw new ResourceNotFoundException(); + var result = await userManager.ConfirmEmailAsync(user, request.EmailConfirmationToken); + if (result.Succeeded == false) + { + return (false, string.Join("\n", result.Errors.Select(x => x.Description))); + } + return (true, "Success"); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/GetAdminUserHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/GetAdminUserHandler.cs new file mode 100644 index 00000000..2766028e --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/GetAdminUserHandler.cs @@ -0,0 +1,24 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record GetAdminUserRequest(string UserId) : IRequest; + +public sealed class GetAdminUserHandler : UsersHandlerBase, IRequestHandler +{ + public GetAdminUserHandler(ILogger logger, UserDbContext userDbContext, UserManager userManager, + IEnumerable> validators) : base(logger, userManager, validators) + { + } + + public async Task Handle(GetAdminUserRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await GetUserAsync(request.UserId) + ?? throw new ResourceNotFoundException(); + var getUser = await MapToAdminUserModelAsync(user, new()); + return getUser; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/GetLeagueUserHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/GetLeagueUserHandler.cs new file mode 100644 index 00000000..1e4889aa --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/GetLeagueUserHandler.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record GetLeagueUserRequest(string LeagueName, string UserId) : IRequest; +public sealed class GetLeagueUserHandler : UsersHandlerBase, IRequestHandler +{ + public GetLeagueUserHandler(ILogger logger, UserDbContext userDbContext, UserManager userManager, + IEnumerable> validators) : base(logger, userManager, validators) + { + } + + public async Task Handle(GetLeagueUserRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await GetUserAsync(request.UserId) + ?? throw new ResourceNotFoundException(); + var getUser = await MapToLeagueUserModelAsync(user, request.LeagueName, new()); + if (getUser.LeagueRoles.Any() == false) + { + // return not found if user does not have any league role + // meaning this is not a LeagueUser (yet) + throw new ResourceNotFoundException(); + } + return getUser; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/GetPrivateUserHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/GetPrivateUserHandler.cs new file mode 100644 index 00000000..f1637bce --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/GetPrivateUserHandler.cs @@ -0,0 +1,24 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record GetPrivateUserRequest(string UserId) : IRequest; + +public sealed class GetPrivateUserHandler : UsersHandlerBase, IRequestHandler +{ + public GetPrivateUserHandler(ILogger logger, UserDbContext userDbContext, UserManager userManager, + IEnumerable> validators) : base(logger, userManager, validators) + { + } + + public async Task Handle(GetPrivateUserRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await GetUserAsync(request.UserId) + ?? throw new ResourceNotFoundException(); + var getUser = MapToPrivateUserModel(user, new()); + return getUser; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/GetUserHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/GetUserHandler.cs new file mode 100644 index 00000000..cd0fdee9 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/GetUserHandler.cs @@ -0,0 +1,25 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record GetUserRequest(string UserId) : IRequest; + +public sealed class GetUserHandler : UsersHandlerBase, + IRequestHandler +{ + public GetUserHandler(ILogger logger, UserManager userManager, + IEnumerable> validators) : base(logger, userManager, validators) + { + } + + public async Task Handle(GetUserRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await userManager.FindByIdAsync(request.UserId) + ?? throw new ResourceNotFoundException(); + var getUser = MapToUserModel(user, new()); + return getUser; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/GetUserListHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/GetUserListHandler.cs new file mode 100644 index 00000000..2907300a --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/GetUserListHandler.cs @@ -0,0 +1,47 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record GetUserListRequest(string LeagueName) : IRequest>; + +public sealed class GetUserListHandler : UsersHandlerBase, + IRequestHandler> +{ + public GetUserListHandler(ILogger logger, UserManager userManager, + IEnumerable> validators) : base(logger, userManager, validators) + { + } + + public async Task> Handle(GetUserListRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var leagueUsers = await GetUserEntitiesWithLeagueRole(request.LeagueName, cancellationToken); + var getUsers = await MapToLeagueUserListAsync(leagueUsers, request.LeagueName, cancellationToken); + return getUsers; + } + + private async Task> GetUserEntitiesWithLeagueRole(string leagueName, CancellationToken cancellationToken) + { + var leagueRoles = LeagueRoles.RolesAvailable + .Select(x => LeagueRoles.GetLeagueRoleName(leagueName, x)); + var usersWithRole = new List(); + foreach (var leagueRole in leagueRoles) + { + usersWithRole.AddRange(await userManager.GetUsersInRoleAsync(leagueRole)); + } + return usersWithRole.DistinctBy(x => x.Id); + } + + private async Task> MapToLeagueUserListAsync(IEnumerable users, string leagueName, CancellationToken cancellationToken) + { + var userModels = new List(); + foreach (var user in users) + { + var model = await MapToLeagueUserModelAsync(user, leagueName, new()); + userModels.Add(model); + } + return userModels; + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/PutUserHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/PutUserHandler.cs new file mode 100644 index 00000000..3ceca783 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/PutUserHandler.cs @@ -0,0 +1,43 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record PutUserRequest(string UserId, PutUserModel Model) : IRequest; + +public sealed class PutUserHandler : UsersHandlerBase, IRequestHandler +{ + private readonly UserDbContext userDbContext; + + public PutUserHandler(ILogger logger, UserDbContext userDbContext, UserManager userManager, + IEnumerable> validators) : base(logger, userManager, validators) + { + this.userDbContext = userDbContext; + } + + public async Task Handle(PutUserRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await GetUserEntityAsync(request.UserId, cancellationToken) + ?? throw new ResourceNotFoundException(); + user = MapToUserEntity(request.Model, user); + await userDbContext.SaveChangesAsync(cancellationToken); + var getUser = MapToPrivateUserModel(user, new PrivateUserModel()); + return getUser; + } + + private ApplicationUser MapToUserEntity(PutUserModel model, ApplicationUser user) + { + user.FullName = GetUserFullName(model.Firstname, model.Lastname); + user.Email = model.Email; + user.HideFullName = model.HideFirstnameLastname; + return user; + } + + private async Task GetUserEntityAsync(string? userId, CancellationToken cancellationToken) + { + return await userDbContext.Users + .FirstOrDefaultAsync(x => x.Id == userId, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/RegisterUserHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/RegisterUserHandler.cs new file mode 100644 index 00000000..8ca8fdda --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/RegisterUserHandler.cs @@ -0,0 +1,66 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Services.EmailService; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.WebUtilities; +using Microsoft.EntityFrameworkCore.Query.SqlExpressions; +using System.Text; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record RegisterUserRequest(RegisterModel Model, string LinkTemplate) : IRequest<(UserModel? user, IdentityResult result)>; + +public enum UserRegistrationStatus +{ + Success, + UserExists, + CreateUserFailed, +} + +public class RegisterUserHandler : UsersHandlerBase, + IRequestHandler +{ + private readonly IEmailClient emailClient; + + public RegisterUserHandler(ILogger logger, UserDbContext userDbContext, UserManager userManager, + IEnumerable> validators, IEmailClient emailClient) : base(logger, userManager, validators) + { + this.emailClient = emailClient; + } + + public async Task<(UserModel? user, IdentityResult result)> Handle(RegisterUserRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var model = request.Model; + _logger.LogInformation("Registering new user {UserName}", model.Username); + var userExists = await userManager.FindByNameAsync(model.Username); + if (userExists != null) + { + _logger.LogInformation("User {UserName} already exists", model.Username); + return (null, IdentityResult.Failed(userManager.ErrorDescriber.DuplicateUserName(model.Username))); + } + + var user = CreateApplicationUser(model); + var result = await userManager.CreateAsync(user, model.Password); + if (!result.Succeeded) + { + _logger.LogError("Failed to add user {UserName} due to errors: {Errors}", model.Username, result.Errors + .Select(x => $"{x.Code}: {x.Description}")); + return (null, result); + } + _logger.LogInformation("User {UserName} created succesfully", model.Username); + + var emailConfirmationToken = await GetEmailConfirmationToken(user); + await SendConfirmationMail(user, emailConfirmationToken, request.LinkTemplate); + + var userModel = MapToUserModel(user, new()); + return (userModel, IdentityResult.Success); + } + + private async Task SendConfirmationMail(ApplicationUser user, string token, string linkTemplate) + { + var subject = "Confirm your Emailaddress for iRLeagueManager.net"; + var body = GenerateMailBody(user, token, linkTemplate); + await emailClient.SendNoReplyMailAsync(user.Email, subject, body); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/RemoveLeagueRoleHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/RemoveLeagueRoleHandler.cs new file mode 100644 index 00000000..624a96b4 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/RemoveLeagueRoleHandler.cs @@ -0,0 +1,32 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record RemoveLeagueRoleRequest(string LeagueName, string UserId, string RoleName) : IRequest; + +public sealed class RemoveLeagueRoleHandler : UsersHandlerBase, + IRequestHandler +{ + public RemoveLeagueRoleHandler(ILogger logger, UserManager userManager, + IEnumerable> validators) : base(logger, userManager, validators) + { + } + + public async Task Handle(RemoveLeagueRoleRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await GetUserAsync(request.UserId) + ?? throw new ResourceNotFoundException(); + await RemoveLeagueRoleFromUser(user, request.LeagueName, request.RoleName); + var getUser = await MapToLeagueUserModelAsync(user, request.LeagueName, new()); + return getUser; + } + + private async Task RemoveLeagueRoleFromUser(ApplicationUser user, string leagueName, string roleName) + { + var leagueRoleName = LeagueRoles.GetLeagueRoleName(leagueName, roleName); + await userManager.RemoveFromRoleAsync(user, leagueRoleName); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/SearchUsersByNameHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/SearchUsersByNameHandler.cs new file mode 100644 index 00000000..fb70ff49 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/SearchUsersByNameHandler.cs @@ -0,0 +1,35 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record SearchUsersByNameRequest(string[] SearchKeys) : IRequest>; + +public sealed class SearchUsersByNameHandler : UsersHandlerBase, + IRequestHandler> +{ + private readonly UserDbContext userDbContext; + + public SearchUsersByNameHandler(ILogger logger, UserDbContext userDbContext, UserManager userManager, + IEnumerable> validators) : base(logger, userManager, validators) + { + this.userDbContext = userDbContext; + } + + public async Task> Handle(SearchUsersByNameRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var users = await SearchUsers(request.SearchKeys); + var getUsers = users.Select(x => MapToUserModel(x, new())); + return getUsers; + } + + private async Task> SearchUsers(params string[] searchKeys) + { + var regexString = string.Join('|', searchKeys.Select(x => x.ToLower())); + return await userDbContext.Users + .FromSqlInterpolated($"SELECT * FROM AspNetUsers WHERE LOWER(UserName) REGEXP {regexString} OR LOWER(FullName) REGEXP {regexString}") + .ToListAsync(); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/SendConfirmationEmailHandler.cs b/src/iRLeagueApiCore.Server/Handlers/Users/SendConfirmationEmailHandler.cs new file mode 100644 index 00000000..6b758a30 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/SendConfirmationEmailHandler.cs @@ -0,0 +1,36 @@ +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Services.EmailService; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public record SendConfirmationEmailRequest(string Email, string LinkTemplate) : IRequest; + +public class SendConfirmationEmailHandler : UsersHandlerBase, + IRequestHandler +{ + private readonly IEmailClient emailClient; + + public SendConfirmationEmailHandler(ILogger logger, UserDbContext userDbContext, UserManager userManager, + IEnumerable> validators, IEmailClient emailClient) : base(logger, userManager, validators) + { + this.emailClient = emailClient; + } + + public async Task Handle(SendConfirmationEmailRequest request, CancellationToken cancellationToken) + { + await validators.ValidateAllAndThrowAsync(request, cancellationToken); + var user = await userManager.FindByEmailAsync(request.Email) + ?? throw new ResourceNotFoundException(); + var token = await GetEmailConfirmationToken(user); + await SendConfirmationMail(user, token, request.LinkTemplate); + return Unit.Value; + } + + private async Task SendConfirmationMail(ApplicationUser user, string token, string linkTemplate) + { + var subject = "Confirm your Emailaddress for iRLeagueManager.net"; + var body = GenerateMailBody(user, token, linkTemplate); + await emailClient.SendNoReplyMailAsync(user.Email, subject, body); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/Users/UsersHandlerBase.cs b/src/iRLeagueApiCore.Server/Handlers/Users/UsersHandlerBase.cs new file mode 100644 index 00000000..db5c8875 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/Users/UsersHandlerBase.cs @@ -0,0 +1,128 @@ +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.WebUtilities; +using System.Text; + +namespace iRLeagueApiCore.Server.Handlers.Users; + +public class UsersHandlerBase +{ + protected readonly ILogger _logger; + protected readonly UserManager userManager; + protected IEnumerable> validators; + + public UsersHandlerBase(ILogger logger, UserManager userManager, IEnumerable> validators) + { + _logger = logger; + this.userManager = userManager; + this.validators = validators; + } + + protected async Task GetUserAsync(string? userId) + { + return await userManager.FindByIdAsync(userId); + } + + protected ApplicationUser CreateApplicationUser(RegisterModel model) + { + var fullname = GetUserFullName(model.Firstname, model.Lastname); + var user = new ApplicationUser() + { + UserName = model.Username, + FullName = fullname, + Email = model.Email, + HideFullName = false, + SecurityStamp = Guid.NewGuid().ToString(), + }; + return user; + } + + protected UserModel MapToUserModel(ApplicationUser user, UserModel model) + { + (var firstname, var lastname) = GetUserFirstnameLastname(user.FullName); + model.UserId = user.Id; + model.UserName = user.UserName; + model.Firstname = user.HideFullName ? string.Empty : firstname; + model.Lastname = user.HideFullName ? string.Empty : lastname; + return model; + } + + protected PrivateUserModel MapToPrivateUserModel(ApplicationUser user, PrivateUserModel model) + { + MapToUserModel(user, model); + (var firstname, var lastname) = GetUserFirstnameLastname(user.FullName); + model.Firstname = firstname; + model.Lastname = lastname; + model.Email = user.Email; + model.HideFirstnameLastname = user.HideFullName; + return model; + } + + protected async Task MapToLeagueUserModelAsync(ApplicationUser user, string leagueName, LeagueUserModel model) + { + MapToUserModel(user, model); + model.LeagueRoles = GetLeagueRoles(leagueName, await userManager.GetRolesAsync(user)); + return model; + } + + protected async Task MapToAdminUserModelAsync(ApplicationUser user, AdminUserModel model) + { + MapToPrivateUserModel(user, model); + model.Roles = await userManager.GetRolesAsync(user); + return model; + } + + protected async Task GetEmailConfirmationToken(ApplicationUser user) + { + return await userManager.GenerateEmailConfirmationTokenAsync(user); + } + + protected string GenerateMailBody(ApplicationUser user, string emailConfirmationToken, string linkTemplate) + { + var confirmUrl = GenerateEmailConfirmationLink(user.Id, emailConfirmationToken, linkTemplate); + var body = $""" +

Hello {user.UserName},

+

Thank you for your registration with iRLeagueManager.net to bring your league results hosting to the next level!

+

+ To finish activation of your account we only need you to confirm your email adress by clicking the link below:
+ {confirmUrl} +

+

After you finished the confirmation you can log into your account with your username and the password that you set when you registered on the webpage.

+ + In case you got this mail even if you did not register with yourself on iRLeagueManager.net or any connected service, please just ignore it.
+ For further questions please contact simon@irleaguemanager.net
+ Please do not reply to this mail. +
+ """; + return body; + } + + protected string GenerateEmailConfirmationLink(string userId, string token, string template) + { + var encodedToken = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(token)); + var url = template + .Replace("{userId}", userId) + .Replace("{token}", encodedToken); + return url; + } + + protected (string firstname, string lastname) GetUserFirstnameLastname(string? Fullname) + { + var parts = Fullname?.Split(';') ?? Array.Empty(); + return (parts.ElementAtOrDefault(0) ?? string.Empty, parts.ElementAtOrDefault(1) ?? string.Empty); + } + + protected string GetUserFullName(string firstname, string lastname) + { + return $"{firstname};{lastname}"; + } + + protected IEnumerable GetLeagueRoles(string leagueName, IEnumerable userRoles) + { + return userRoles + .Where(x => LeagueRoles.IsLeagueRoleName(leagueName, x)) + .Select(x => LeagueRoles.GetRoleName(x)!) + .ToList(); + } +} diff --git a/src/iRLeagueApiCore.Server/Handlers/ValidationExtensions.cs b/src/iRLeagueApiCore.Server/Handlers/ValidationExtensions.cs new file mode 100644 index 00000000..3524bf90 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Handlers/ValidationExtensions.cs @@ -0,0 +1,30 @@ +using FluentValidation.Results; + +namespace iRLeagueApiCore.Server.Handlers; + +public static class ValidationExtensions +{ + /// + /// Run for all validators + /// and throw exception on validation errors + /// + /// + /// Multiple validators to validate the same instance + /// Instance to validate + /// + /// + public static async Task ValidateAllAndThrowAsync(this IEnumerable> validators, T instance, CancellationToken cancellationToken) + { + var results = new List(); + foreach (var validator in validators) + { + cancellationToken.ThrowIfCancellationRequested(); + results.Add(await validator.ValidateAsync(instance, cancellationToken)); + } + if (results.Any(x => x.IsValid == false)) + { + var errors = results.SelectMany(x => x.Errors); + throw new ValidationException(errors); + } + } +} diff --git a/src/iRLeagueApiCore.Server/Models/CacheKeys.cs b/src/iRLeagueApiCore.Server/Models/CacheKeys.cs new file mode 100644 index 00000000..4939eed6 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/CacheKeys.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Server.Models; + +internal static class CacheKeys +{ + public static string GetLeagueNameKey(string leagueName) => $"leagueName_{leagueName}"; +} diff --git a/src/iRLeagueApiCore.Server/Models/CredentialList.cs b/src/iRLeagueApiCore.Server/Models/CredentialList.cs new file mode 100644 index 00000000..89d74fb0 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/CredentialList.cs @@ -0,0 +1,46 @@ +using System.Collections; +using System.Net; + +namespace iRLeagueApiCore.Server.Models; + +// Modified from Microsoft documentation +// https://learn.microsoft.com/de-de/dotnet/api/system.net.icredentials.getcredential?view=net-7.0 +internal sealed class CredentialList : ICredentials +{ + private readonly Dictionary<(Uri uri, string authenticationType), NetworkCredential> storedCredentials; + + public CredentialList() + { + storedCredentials = new(); + } + + public CredentialList(IConfiguration configuration) : this() + { + foreach(var credentialConfig in configuration.GetChildren()) + { + var credential = new NetworkCredential(credentialConfig["Username"], credentialConfig["Password"]); + var uri = new Uri(credentialConfig["Uri"]); + var authenticationType = credentialConfig["AuthenticationType"]; + Add(uri, authenticationType, credential); + } + } + + public void Add(Uri uri, string authenticationType, NetworkCredential credential) + { + // Add a 'CredentialInfo' object into a list. + var key = (uri, authenticationType); + if (storedCredentials.TryAdd(key, credential) == false) + { + storedCredentials[key] = credential; + } + } + // Remove the 'CredentialInfo' object from the list that matches to the given 'Uri' and 'AuthenticationType' + public void Remove(Uri uri, string authenticationType) + { + storedCredentials.Remove((uri, authenticationType)); + } + public NetworkCredential? GetCredential(Uri uri, string authenticationType) + { + return storedCredentials.TryGetValue((uri, authenticationType), out var credential) ? credential : null; + } +}; diff --git a/src/iRLeagueApiCore.Server/Models/IracingAuthModel.cs b/src/iRLeagueApiCore.Server/Models/IracingAuthModel.cs new file mode 100644 index 00000000..3a7071e0 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/IracingAuthModel.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; + +namespace iRLeagueApiCore.Server.Models; + +[DataContract] +public sealed class IracingAuthModel +{ + /// + /// UserName (email) for use of authentication against iracing api + /// + [DataMember] + public string UserName { get; set; } = string.Empty; + /// + /// Passwor for use of authentication agains iracing api + /// + [DataMember] + public string Password { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Server/Models/LeagueDbContextFactory.cs b/src/iRLeagueApiCore.Server/Models/LeagueDbContextFactory.cs new file mode 100644 index 00000000..33592b84 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/LeagueDbContextFactory.cs @@ -0,0 +1,23 @@ +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Models; + +public sealed class LeagueDbContextFactory +{ + private readonly IConfiguration _configuration; + + public LeagueDbContextFactory(IConfiguration configuration) + { + _configuration = configuration; + } + + public LeagueDbContext CreateDbContext(ILeagueProvider leagueProvider) + { + var dbConnectionString = _configuration.GetConnectionString("ModelDb"); + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseMySQL(dbConnectionString); + + var dbContext = new LeagueDbContext(optionsBuilder.Options, leagueProvider); + return dbContext; + } +} diff --git a/src/iRLeagueApiCore.Server/Models/LeagueUser.cs b/src/iRLeagueApiCore.Server/Models/LeagueUser.cs new file mode 100644 index 00000000..08583767 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/LeagueUser.cs @@ -0,0 +1,48 @@ +using iRLeagueApiCore.Server.Extensions; +using iRLeagueApiCore.Services.ResultService.Extensions; +using System.Security.Claims; + +namespace iRLeagueApiCore.Server.Models; + +public sealed class LeagueUser +{ + public string Id { get; set; } + public string Name { get; set; } + public IReadOnlyCollection Roles { get; private set; } + + public LeagueUser(string leagueName, ClaimsPrincipal principal) + { + Id = principal.GetUserId() ?? string.Empty; + Name = principal.Identity?.Name ?? string.Empty; + if (string.IsNullOrEmpty(leagueName)) + { + Roles = principal.FindAll(ClaimTypes.Role) + .Select(x => x.Value) + .Where(role => role == "Admin") + .Select(LeagueRoles.GetRoleValue) + .ToList(); + } + else + { + Roles = principal.FindAll(ClaimTypes.Role) + .Select(x => x.Value) + .Where(role => LeagueRoles.IsLeagueRoleName(leagueName, role) || role == "Admin") + .Select(role => role == "Admin" ? role : LeagueRoles.GetRoleName(role)) + .NotNull() + .Select(LeagueRoles.GetRoleValue) + .ToList(); + } + } + + /// + /// Returns true when the user is in at least one of the provided roles + /// + /// + /// + public bool IsInRole(params string[] roles) + { + return Roles.Any(userRole => roles.Any(requiredRole => userRole.HasRole(requiredRole))); + } + + public static LeagueUser Empty => new LeagueUser("", new ClaimsPrincipal()); +} diff --git a/src/iRLeagueApiCore.Server/Models/PasswordResetModel.cs b/src/iRLeagueApiCore.Server/Models/PasswordResetModel.cs new file mode 100644 index 00000000..0f3b7fe3 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/PasswordResetModel.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Server.Models; + +public sealed class PasswordResetModel +{ + public string UserName { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public string LinkUriTemplate { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Server/Models/Payments/PaymentModel.cs b/src/iRLeagueApiCore.Server/Models/Payments/PaymentModel.cs new file mode 100644 index 00000000..e61e2446 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/Payments/PaymentModel.cs @@ -0,0 +1,14 @@ +namespace iRLeagueApiCore.Server.Models.Payments; + +public record PaymentModel( + Guid Id, + PaymentType PaymentType, + string PlanId, + string PlanName, + SubscriptionInterval Interval, + string SubscriptionId, + long LeagueId, + string UserId, + DateTime LastPayment, + DateTime? NextPayment, + PaymentStatus Status); diff --git a/src/iRLeagueApiCore.Server/Models/Payments/PostPaymentModel.cs b/src/iRLeagueApiCore.Server/Models/Payments/PostPaymentModel.cs new file mode 100644 index 00000000..6c000264 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/Payments/PostPaymentModel.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Server.Models.Payments; + +public record PostPaymentModel( + string PlanId, + string? SubscriptionId, + string UserId, + PaymentType PaymentType, + DateTime Received, + DateTime? NextDue +); diff --git a/src/iRLeagueApiCore.Server/Models/Payments/SetLeagueSubscriptionModel.cs b/src/iRLeagueApiCore.Server/Models/Payments/SetLeagueSubscriptionModel.cs new file mode 100644 index 00000000..8159a6c1 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/Payments/SetLeagueSubscriptionModel.cs @@ -0,0 +1,5 @@ +using iRLeagueApiCore.Common.Enums; + +namespace iRLeagueApiCore.Server.Models.Payments; + +public record SetLeagueSubscriptionModel(SubscriptionStatus Status, DateTime? Expires); diff --git a/src/iRLeagueApiCore.Server/Models/RequestLeagueProvider.cs b/src/iRLeagueApiCore.Server/Models/RequestLeagueProvider.cs new file mode 100644 index 00000000..32d50fa9 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/RequestLeagueProvider.cs @@ -0,0 +1,18 @@ +using iRLeagueDatabaseCore; + +namespace iRLeagueApiCore.Server.Models; + +public class RequestLeagueProvider : ILeagueProvider +{ + public long LeagueId { get; private set; } = 0; + + public bool HasLeagueName => string.IsNullOrEmpty(LeagueName) == false; + + public string LeagueName { get; private set; } = string.Empty; + + public void SetLeague(long leagueId, string? leagueName = null) + { + LeagueId = leagueId; + LeagueName = leagueName ?? string.Empty; + } +} diff --git a/src/iRLeagueApiCore.Server/Models/ResultResponse.cs b/src/iRLeagueApiCore.Server/Models/ResultResponse.cs new file mode 100644 index 00000000..bf86b4a4 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/ResultResponse.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Server.Models; + +public sealed class ResultResponse +{ + public string Status { get; set; } = string.Empty; + public string Result { get; set; } = string.Empty; + public string Message { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Server/Models/SetPasswordTokenModel.cs b/src/iRLeagueApiCore.Server/Models/SetPasswordTokenModel.cs new file mode 100644 index 00000000..e938d7e9 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Models/SetPasswordTokenModel.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.Server.Models; + +public sealed class SetPasswordTokenModel +{ + public string PasswordToken { get; set; } = string.Empty; + public string NewPassword { get; set; } = string.Empty; +} diff --git a/src/iRLeagueApiCore.Server/Program.cs b/src/iRLeagueApiCore.Server/Program.cs new file mode 100644 index 00000000..d6656aa4 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Program.cs @@ -0,0 +1,19 @@ +using Serilog; + +namespace iRLeagueApiCore.Server; + +public sealed class Program +{ + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseSerilog() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); +} diff --git a/src/iRLeagueApiCore.Server/Properties/launchSettings.json b/src/iRLeagueApiCore.Server/Properties/launchSettings.json new file mode 100644 index 00000000..8976aaf8 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:6164", + "sslPort": 44307 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "iRLeagueApiCore.Server": { + "commandName": "Project", + "dotnetRunMessages": "true", + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/iRLeagueApiCore.Server/Startup.cs b/src/iRLeagueApiCore.Server/Startup.cs new file mode 100644 index 00000000..7154dad1 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Startup.cs @@ -0,0 +1,262 @@ +using AspNetCoreRateLimit; +using Aydsko.iRacingData; +using iRLeagueApiCore.Common.Converters; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Extensions; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Tokens; +using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Models; +using Serilog; +using Serilog.Events; +using System.Net; +using System.Reflection; +using System.Text; +using System.Text.Json.Serialization; + +namespace iRLeagueApiCore.Server; + +public sealed class Startup +{ + public Startup(IConfiguration configuration) + { + Configuration = configuration; + + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(Configuration) + .CreateLogger(); + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.Configure(options => + options.AutomaticAuthentication = false); + + services.AddCors(options => + { + options.AddDefaultPolicy( + builder => + { + builder.WithOrigins("*") // this is only valid for dev environment + .AllowAnyHeader() + .AllowAnyMethod(); + }); + }); + + services.AddMvc() + .AddJsonOptions(options => + { + options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); + options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; + }); + + services.AddControllers().AddJsonOptions(option => + { + option.JsonSerializerOptions.Converters.Add(new JsonTimeSpanConverter()); + }); + services.AddSwaggerGen(c => + { + var readHostUrls = Configuration["ASPNETCORE_HOSTURLS"]; + if (readHostUrls != null) + { + var hostUrls = readHostUrls.Split(';'); + foreach (var hostUrl in hostUrls) + { + c.AddServer(new OpenApiServer() { Url = hostUrl }); + } + } + c.SwaggerDoc("v1", new OpenApiInfo { Title = "iRLeagueApiCore.Server", Version = "v1" }); + c.OperationFilter(); + c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme + { + Description = "JWT Authorization header using the Bearer scheme. \r\n\r\n" + + "Enter 'Bearer' [space] and then your token in the text input below." + + "\r\n\r\nExample: 'Bearer 12345abcdef'", + Name = "Authorization", + In = ParameterLocation.Header, + Type = SecuritySchemeType.ApiKey, + Scheme = "Bearer" + }); + + c.AddSecurityRequirement(new OpenApiSecurityRequirement() + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "Bearer" + }, + Scheme = "oauth2", + Name = "Bearer", + In = ParameterLocation.Header, + + }, + new List() + } + }); + var xmlPath = Path.Combine(AppContext.BaseDirectory, "iRLeagueApiCore.Server.xml"); + c.IncludeXmlComments(xmlPath); + xmlPath = Path.Combine(AppContext.BaseDirectory, "iRLeagueApiCore.Common.xml"); + c.IncludeXmlComments(xmlPath); + c.MapType(() => new OpenApiSchema() + { + Type = "string", + Format = "duration", + Pattern = "hh:mm:ss.fffff", + Example = new OpenApiString(new TimeSpan(0, 1, 2, 34, 567).ToString(@"hh\:mm\:ss\.fffff")) + }); + c.MapType(() => new OpenApiSchema() + { + Type = "string", + Format = "duration", + Nullable = true, + Pattern = "hh:mm:ss.fffff", + Example = new OpenApiString(new TimeSpan(0, 1, 2, 34, 567).ToString(@"hh\:mm\:ss\.fffff")) + }); + }); + + // try get connection string + services.AddDbContextFactory(); + services.AddScoped(x => + x.GetRequiredService>().CreateDbContext()); + services.AddSingleton(); + services.AddScoped(); + services.AddScoped(x => x.GetRequiredService()); + services.AddScoped(x => + x.GetRequiredService().CreateDbContext(x.GetRequiredService())); + + services.AddIdentity() + .AddEntityFrameworkStores() + .AddDefaultTokenProviders(); + + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + }) + + // Adding Jwt Bearer + .AddJwtBearer(options => + { + options.SaveToken = true; + options.RequireHttpsMetadata = false; + options.TokenValidationParameters = new TokenValidationParameters() + { + ValidateLifetime = true, + ValidateIssuer = true, + ValidateAudience = true, + ValidAudience = Configuration["JWT:ValidAudience"], + ValidIssuer = Configuration["JWT:ValidIssuer"], + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["JWT:Secret"])) + }; + }); + + services.Configure(options => + { + options.Password.RequireDigit = false; + options.Password.RequiredLength = 6; + options.Password.RequireNonAlphanumeric = true; + options.Password.RequiredUniqueChars = 1; + options.Password.RequireUppercase = true; + options.Password.RequireLowercase = true; + }); + + services.AddMemoryCache(); + services.Configure(Configuration.GetSection("IpRateLimiting")); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddInMemoryRateLimiting(); + + services.AddTrackImporter(); + + services.AddMediatR(Assembly.GetExecutingAssembly()); + services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly()); + + services.AddEmailService(); + services.AddResultService(); + services.AddBackgroundQueue(); + + services.AddSingleton(x => new(Configuration.GetSection("Credentials"))); + + services.AddIRacingDataApi(options => + { + options.UserAgentProductName = "iRLeagueApiCore"; + options.UserAgentProductVersion = Assembly.GetEntryAssembly()!.GetName().Version!; + }); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger) + { + + app.UseForwardedHeaders(new ForwardedHeadersOptions + { + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto + }); + + app.UseCors(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + app.UseSwagger(); + app.UseSwaggerUI(c => + { + //c.SwaggerEndpoint("./v1/swagger.json", "TestDeploy v1"); + //c.RoutePrefix = string.Empty; + string swaggerJsonBasePath = string.IsNullOrWhiteSpace(c.RoutePrefix) ? "./swagger/" : ""; + c.SwaggerEndpoint($"{swaggerJsonBasePath}v1/swagger.json", "iRLeagueApiCore.Server v1"); + }); + + //app.UseHttpsRedirection(); + + app.UseFileServer(); + + app.UseRouting(); + + app.UseIpRateLimiting(); + + app.UseSerilogRequestLogging(options => + { + // Customize the message template + options.MessageTemplate = "{RemoteIpAddress:l} {RequestScheme:l} {RequestMethod:l} {RequestPath:l} responded {StatusCode} in {Elapsed:0.0000} ms {RequestReferer} {RequestAgent} {UserName}"; + + // Emit debug-level events instead of the defaults + options.GetLevel = (httpContext, elapsed, ex) => LogEventLevel.Information; + + // Attach additional properties to the request completion event + options.EnrichDiagnosticContext = (diagnosticContext, httpContext) => + { + diagnosticContext.Set("RequestAgent", httpContext.Request.Headers["User-Agent"].ToString()); + diagnosticContext.Set("RequestReferer", httpContext.Request.GetTypedHeaders().Referer?.ToString() ?? string.Empty); + diagnosticContext.Set("RequestScheme", httpContext.Request.Scheme); + diagnosticContext.Set("RemoteIpAddress", httpContext.Connection.RemoteIpAddress); + diagnosticContext.Set("UserName", httpContext.User.Identity?.Name ?? string.Empty); + diagnosticContext.Set("UserId", httpContext.User.GetUserId()); + }; + }); + + app.UseAuthentication(); + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/AdminPanel/Payments/PostPaymentModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/AdminPanel/Payments/PostPaymentModelValidator.cs new file mode 100644 index 00000000..96df530e --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/AdminPanel/Payments/PostPaymentModelValidator.cs @@ -0,0 +1,33 @@ +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Models.Payments; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Validation.AdminPanel.Payments; + +public class PostPaymentModelValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + private readonly UserManager userManager; + + public PostPaymentModelValidator(LeagueDbContext dbContext, UserManager userManager) + { + this.dbContext = dbContext; + this.userManager = userManager; + RuleFor(x => x.PlanId) + .MustAsync(SubscriptionPlanExists) + .WithMessage("PlanId was not a valid subscription plan"); + RuleFor(x => x.UserId) + .MustAsync(UserExists) + .WithMessage("No user with UserId was found"); + } + + private async Task SubscriptionPlanExists(string planId, CancellationToken cancellationToken) + { + return await dbContext.Subscriptions.AnyAsync(x => x.PlanId == planId, cancellationToken); + } + + private async Task UserExists(string userId, CancellationToken cancellationToken) + { + return await userManager.FindByIdAsync(userId) is not null; + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/AdminPanel/Payments/PostPaymentRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/AdminPanel/Payments/PostPaymentRequestValidator.cs new file mode 100644 index 00000000..7a421644 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/AdminPanel/Payments/PostPaymentRequestValidator.cs @@ -0,0 +1,23 @@ +using iRLeagueApiCore.Server.Handlers.AdminPanel; + +namespace iRLeagueApiCore.Server.Validation.AdminPanel.Payments; + +public class PostPaymentRequestValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PostPaymentRequestValidator(PostPaymentModelValidator modelValidator, LeagueDbContext dbContext) + { + this.dbContext = dbContext; + RuleFor(x => x.Model) + .SetValidator(modelValidator); + RuleFor(x => x.LeagueId) + .MustAsync(LeagueExists) + .WithMessage("No league with given leagueId exists"); + } + + private async Task LeagueExists(long leagueId, CancellationToken cancellationToken) + { + return await dbContext.Leagues.AnyAsync(x => x.Id == leagueId, cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Authentication/SetPasswordWithTokenRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Authentication/SetPasswordWithTokenRequestValidator.cs new file mode 100644 index 00000000..91ff760f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Authentication/SetPasswordWithTokenRequestValidator.cs @@ -0,0 +1,35 @@ +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Authentication; +using Microsoft.AspNetCore.Identity; +using System.Text.RegularExpressions; + +namespace iRLeagueApiCore.Server.Validation.Authentication; + +public sealed class SetPasswordWithTokenRequestValidator : AbstractValidator +{ + private readonly UserManager userManager; + + public SetPasswordWithTokenRequestValidator(UserManager userManager) + { + this.userManager = userManager; + + RuleFor(x => x.Model.NewPassword) + .NotEmpty() + .WithMessage("Password cannot be empty") + .Must(PasswordIsValid) + .WithMessage("Invalid password. Password must have at least 6 characters, must contain one upper- and lowercase letter and one special character ($!%*?&)"); + RuleFor(x => x.UserId) + .MustAsync(UserExists) + .WithMessage("User with the given user id does not exist"); + } + + private bool PasswordIsValid(string password) + { + return Regex.IsMatch(password, @"^(?=.*[a-z])(?=.*[A-Z])(?=.*[@$!%*?&/\\])[A-Za-z\d@$!%*?&/\\]{6,}$"); + } + + private async Task UserExists(string userId, CancellationToken cancellationToken) + { + return await userManager.FindByIdAsync(userId) is not null; + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Events/CollectionAttribute.cs b/src/iRLeagueApiCore.Server/Validation/Events/CollectionAttribute.cs new file mode 100644 index 00000000..a48e8d2b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Events/CollectionAttribute.cs @@ -0,0 +1,5 @@ +namespace iRLeagueApiCore.Server.Validation.Events; + +internal class CollectionAttribute : Attribute +{ +} diff --git a/src/iRLeagueApiCore.Server/Validation/Events/PostEventModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Events/PostEventModelValidator.cs new file mode 100644 index 00000000..a3446a4b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Events/PostEventModelValidator.cs @@ -0,0 +1,59 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Validation.Events; + +public sealed class PostEventModelValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PostEventModelValidator(LeagueDbContext dbContext) + { + this.dbContext = dbContext; + + RuleFor(x => x.Sessions) + .NotNull() + .WithMessage("Sessions required"); + RuleForEach(x => x.Sessions) + .MustAsync(SessionIdValid) + .WithMessage("Session id must be either 0 or target a valid SessionEntity.SessionId"); + RuleFor(x => x.ResultConfigs) + .MustAsync(OnlyOneResultConfigPerChampSeason) + .WithMessage("Only one result config per championship can be selected") + .MustAsync(MustIncludeDependResultConfigs) + .WithMessage("At least one selected result configuration has \"From source\" set to another result configuration. Please make sure to include all depended on result configurations to prevent errors during calculation"); + } + + public async Task SessionIdValid(SessionModel session, CancellationToken cancellationToken) + { + var sessionId = session.SessionId; + var result = sessionId == 0 || + await dbContext.Sessions + .Where(x => x.SessionId == session.SessionId) + .AnyAsync(); + return result; + } + + private async Task OnlyOneResultConfigPerChampSeason(IEnumerable configs, CancellationToken cancellationToken) + { + var configIds = configs.Select(x => x.ResultConfigId).ToList(); + var configEntities = await dbContext.ResultConfigurations + .Where(x => configIds.Contains(x.ResultConfigId)) + .ToListAsync(cancellationToken); + // Return true if list has no duplicates + return configEntities + .Select(x => x.ChampSeasonId) + .Distinct() + .Count() == configs.Count(); + } + + private async Task MustIncludeDependResultConfigs(IEnumerable configs, CancellationToken cancellationToken) + { + var configIds = configs.Select(x => x.ResultConfigId).ToList(); + var configEntities = await dbContext.ResultConfigurations + .Where(x => configIds.Contains(x.ResultConfigId)) + .ToListAsync(cancellationToken); + // Return true if all dependant result config were found in event configs list (or source is null) + return configEntities + .All(x => x.SourceResultConfigId == null || configIds.Contains(x.SourceResultConfigId.Value)); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Events/PostEventToScheduleRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Events/PostEventToScheduleRequestValidator.cs new file mode 100644 index 00000000..82d6aaa6 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Events/PostEventToScheduleRequestValidator.cs @@ -0,0 +1,26 @@ +using iRLeagueApiCore.Server.Handlers.Events; + +namespace iRLeagueApiCore.Server.Validation.Events; + +public sealed class PostEventToScheduleRequestValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PostEventToScheduleRequestValidator(LeagueDbContext dbContext, PostEventModelValidator eventValidator) + { + this.dbContext = dbContext; + + RuleFor(x => x.ScheduleId) + .MustAsync(EventExists) + .WithMessage("No entry for schedule found with combination of LeagueId and ScheduleId"); + RuleFor(x => x.Event) + .SetValidator(eventValidator); + } + + public async Task EventExists(PostEventToScheduleRequest request, long scheduleId, CancellationToken cancellationToken) + { + return await dbContext.Schedules + .Where(x => x.ScheduleId == scheduleId) + .AnyAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Events/PutEventModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Events/PutEventModelValidator.cs new file mode 100644 index 00000000..c362ab41 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Events/PutEventModelValidator.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Validation.Events; + +public sealed class PutEventModelValidator : AbstractValidator +{ + public PutEventModelValidator(PostEventModelValidator postValidator) + { + Include(postValidator); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Events/PutEventRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Events/PutEventRequestValidator.cs new file mode 100644 index 00000000..a9649a4f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Events/PutEventRequestValidator.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Server.Handlers.Events; + +namespace iRLeagueApiCore.Server.Validation.Events; + +public sealed class PutEventRequestValidator : AbstractValidator +{ + public PutEventRequestValidator(PutEventModelValidator eventValidator) + { + RuleFor(x => x.Event) + .SetValidator(eventValidator); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/GiveRoleRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/GiveRoleRequestValidator.cs new file mode 100644 index 00000000..e500219d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/GiveRoleRequestValidator.cs @@ -0,0 +1,60 @@ +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Admin; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Validation; + +public sealed class GiveRoleRequestValidator : AbstractValidator +{ + private readonly LeagueDbContext _dbContext; + private readonly UserManager _userManager; + + public GiveRoleRequestValidator(LeagueDbContext dbContext, UserManager userManager) + { + _dbContext = dbContext; + _userManager = userManager; + + // league name must exist + RuleFor(x => x.LeagueName) + .MustAsync(LeagueNameExists) + .WithMessage(x => "League does not exist"); + RuleFor(x => x.UserName) + .Cascade(CascadeMode.Stop) + .NotNull() + .WithMessage(x => "UserName is required") + .MustAsync(UserExists) + .WithMessage(x => "User not found") + .MustAsync(UserNotInRole) + .WithMessage(x => "User is already in role"); + RuleFor(x => x.RoleName) + .Must(RoleIsValid) + .WithMessage(x => $"Invalid role. Use: either '{string.Join("', '", LeagueRoles.RolesAvailable.SkipLast(1))}' or '{LeagueRoles.RolesAvailable.Last()}'"); + } + + private async Task LeagueNameExists(string leagueName, CancellationToken cancellationToken) + { + return await _dbContext.Leagues + .AnyAsync(x => leagueName == x.Name, cancellationToken); + } + + private async Task UserExists(GiveRoleRequest request, string usernName, CancellationToken cancellationToken) + { + var user = await _userManager + .FindByNameAsync(usernName); + request.User = user; + return user != null; + } + + private bool RoleIsValid(string roleName) + { + return LeagueRoles.RolesAvailable + .Any(x => roleName == x); + } + + private async Task UserNotInRole(GiveRoleRequest request, string userName, CancellationToken cancellationToken) + { + var leagueRoleName = LeagueRoles.GetLeagueRoleName(request.LeagueName, request.RoleName); + bool notInRole = await _userManager.IsInRoleAsync(request.User, leagueRoleName) == false; + return notInRole; + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Leagues/PostLeagueModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Leagues/PostLeagueModelValidator.cs new file mode 100644 index 00000000..247e42ac --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Leagues/PostLeagueModelValidator.cs @@ -0,0 +1,34 @@ +using iRLeagueApiCore.Common.Models; +using System.Text.RegularExpressions; + +namespace iRLeagueApiCore.Server.Validation.Leagues; + +public sealed class PostLeagueModelValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PostLeagueModelValidator(LeagueDbContext dbContext) + { + this.dbContext = dbContext; + + RuleFor(x => x.Name) + .NotEmpty() + .WithMessage("Name required") + .Must(LeagueNameValid) + .WithMessage("Name invalid. Can only contain: 'a-zA-Z0-9_-' and must be between 3-85 characters long") + .MustAsync(LeagueNameNotTaken) + .WithMessage("Name already taken. Please use another name"); + } + + private static bool LeagueNameValid(string leagueName) + { + return Regex.IsMatch(leagueName, @"^[a-zA-Z0-9_-]{3,85}$") // only valid characters + && Regex.IsMatch(leagueName, @"[a-zA-Z]{1,}"); // at least one non-numeric character + } + + private async Task LeagueNameNotTaken(string leagueName, CancellationToken cancellationToken = default) + { + return await dbContext.Leagues + .AnyAsync(x => x.Name == leagueName) == false; + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Leagues/PostLeagueRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Leagues/PostLeagueRequestValidator.cs new file mode 100644 index 00000000..11ff8bf1 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Leagues/PostLeagueRequestValidator.cs @@ -0,0 +1,39 @@ +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.Server.Models; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Validation.Leagues; + +public sealed class PostLeagueRequestValidator : AbstractValidator +{ + private const int maxLeagues = 3; + private UserManager userManager; + + public PostLeagueRequestValidator(PostLeagueModelValidator modelValidator, UserManager userManager) + { + this.userManager = userManager; + + RuleFor(x => x.Model) + .SetValidator(modelValidator); + RuleFor(x => x.User) + .MustAsync(HaveLessThanMaximumAllowedLeagues) + .WithMessage("User is already the owner for the maximum allowed number of leagues"); + } + + private async Task HaveLessThanMaximumAllowedLeagues(LeagueUser user, CancellationToken cancellationToken) + { + var applicationUser = await userManager.FindByIdAsync(user.Id); + if (applicationUser is null) + { + // User does not exist but that will be handled at a different point + // For now no user means -> validation ok + return true; + } + var userLeagueCount = (await userManager + .GetRolesAsync(applicationUser)) + .Where(x => x.Contains(LeagueRoles.Owner)) + .Count(); + return userLeagueCount < maxLeagues; + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/ListUsersRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/ListUsersRequestValidator.cs new file mode 100644 index 00000000..c436dbfd --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/ListUsersRequestValidator.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Server.Handlers.Admin; + +namespace iRLeagueApiCore.Server.Validation; + +public sealed class ListUsersRequestValidator : AbstractValidator +{ + public ListUsersRequestValidator() + { + RuleFor(x => x.LeagueName).NotEmpty() + .WithMessage("'leagueName' may not be empty"); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Results/PostResultConfigModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Results/PostResultConfigModelValidator.cs new file mode 100644 index 00000000..609e7900 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Results/PostResultConfigModelValidator.cs @@ -0,0 +1,13 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Validation.Results; + +public sealed class PostResultConfigModelValidator : AbstractValidator +{ + public PostResultConfigModelValidator() + { + RuleFor(x => x.Name).NotEmpty() + .WithMessage("Name must not be empty"); + //RuleFor(x => x.DisplayName).NotEmpty(); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Results/PostResultConfigRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Results/PostResultConfigRequestValidator.cs new file mode 100644 index 00000000..8e5b8241 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Results/PostResultConfigRequestValidator.cs @@ -0,0 +1,23 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Results; + +namespace iRLeagueApiCore.Server.Validation.Results; + +public sealed class PostResultConfigRequestValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PostResultConfigRequestValidator(LeagueDbContext dbContext, PostResultConfigModelValidator modelValidator) + { + this.dbContext = dbContext; + RuleFor(x => x.Model) + .SetValidator(modelValidator); + RuleForEach(x => x.Model.Scorings) + .Must(ScoringIdZero); + } + + private bool ScoringIdZero(ScoringModel scoringModel) + { + return scoringModel.Id == 0; + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Results/PutResultConfigModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Results/PutResultConfigModelValidator.cs new file mode 100644 index 00000000..f5269106 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Results/PutResultConfigModelValidator.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Validation.Results; + +public sealed class PutResultConfigModelValidator : AbstractValidator +{ + public PutResultConfigModelValidator(PostResultConfigModelValidator includeValidator) + { + Include(includeValidator); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Results/PutResultConfigRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Results/PutResultConfigRequestValidator.cs new file mode 100644 index 00000000..489edfcc --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Results/PutResultConfigRequestValidator.cs @@ -0,0 +1,35 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Results; + +namespace iRLeagueApiCore.Server.Validation.Results; + +public sealed class PutResultConfigRequestValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PutResultConfigRequestValidator(LeagueDbContext dbContext, PutResultConfigModelValidator modelValidator) + { + this.dbContext = dbContext; + RuleFor(x => x.Model) + .SetValidator(modelValidator); + RuleForEach(x => x.Model.Scorings) + .MustAsync(ScoringIdValid); + } + + private async Task ScoringIdValid(PutResultConfigRequest request, ScoringModel scoringModel, CancellationToken cancellationToken) + { + if (scoringModel.Id == 0) + { + return true; + } + var exists = await dbContext.Scorings + .Where(x => x.ScoringId == scoringModel.Id) + .Select(x => new { x.ResultConfigId }) + .FirstOrDefaultAsync(cancellationToken); + if (exists != null && exists.ResultConfigId == request.ResultConfigId) + { + return true; + } + return false; + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Reviews/PostProtestModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Reviews/PostProtestModelValidator.cs new file mode 100644 index 00000000..8b8a387b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Reviews/PostProtestModelValidator.cs @@ -0,0 +1,60 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Validation.Reviews; + +public class PostProtestModelValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PostProtestModelValidator(LeagueDbContext dbContext) + { + this.dbContext = dbContext; + + RuleFor(x => x.AuthorMemberId) + .Cascade(CascadeMode.Stop) + .NotEmpty() + .WithMessage("Author is required") + .MustAsync(MemberExists) + .WithMessage("Member id does not exist"); + RuleFor(x => x.ConfirmIRacingId) + .Cascade(CascadeMode.Stop) + .NotEmpty() + .WithMessage("IRacing id is required to confirm identity") + .MustAsync(IRacingIdMatchAuthor) + .WithMessage("IRacing id does not match selected member"); + RuleFor(x => x.OnLap) + .NotEmpty() + .WithMessage("Lap is required"); + RuleFor(x => x.Corner) + .NotEmpty() + .WithMessage("Turn is required"); + RuleFor(x => x.FullDescription) + .NotEmpty() + .WithMessage("Description is required"); + RuleFor(x => x.InvolvedMembers) + .Cascade(CascadeMode.Stop) + .NotEmpty() + .WithMessage("At least one involved Driver is required") + .ForEach(x => x.MustAsync(MemberExists)) + .WithMessage("One or more members are invalid"); + } + + public async Task MemberExists(MemberInfoModel member, CancellationToken cancellationToken) + { + return await MemberExists(member.MemberId, cancellationToken); + } + + public async Task MemberExists(long memberId, CancellationToken cancellationToken) + { + return await dbContext.Members + .AnyAsync(x => x.Id == memberId, cancellationToken); + } + + public async Task IRacingIdMatchAuthor(PostProtestModel protest, string iRacingId, CancellationToken cancellationToken) + { + var member = await dbContext.Members + .Where(x => x.Id == protest.AuthorMemberId) + .FirstOrDefaultAsync(cancellationToken); + return member?.IRacingId == iRacingId; + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Reviews/PostProtestRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Reviews/PostProtestRequestValidator.cs new file mode 100644 index 00000000..88ac85c8 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Reviews/PostProtestRequestValidator.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Server.Handlers.Reviews; + +namespace iRLeagueApiCore.Server.Validation.Reviews; + +public class PostProtestRequestValidator : AbstractValidator +{ + public PostProtestRequestValidator(PostProtestModelValidator modelValidator) + { + RuleFor(x => x.Model) + .SetValidator(modelValidator); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Reviews/PostReviewModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Reviews/PostReviewModelValidator.cs new file mode 100644 index 00000000..4721905b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Reviews/PostReviewModelValidator.cs @@ -0,0 +1,38 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Services.ResultService.Extensions; + +namespace iRLeagueApiCore.Server.Validation.Reviews; + +public sealed class PostReviewModelValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PostReviewModelValidator(LeagueDbContext dbContext) + { + this.dbContext = dbContext; + + RuleFor(x => x.InvolvedMembers) + .Cascade(CascadeMode.Stop) + .NotEmpty() + .WithMessage("At least one driver or team required") + .When(x => x.InvolvedTeams.None()) + .MustAsync(EachMemberIsValid) + .WithMessage("Member does not exist") + .When(x => x.InvolvedMembers.Any()); + RuleFor(x => x.InvolvedTeams) + .NotEmpty() + .WithMessage("At least one driver or team required") + .When(x => x.InvolvedMembers.None()); + RuleFor(x => x.IncidentKind) + .NotEmpty() + .WithMessage("Incident Kind is required"); + } + + private async Task EachMemberIsValid(IEnumerable members, CancellationToken cancellationToken) + { + var memberIds = members.Select(x => x.MemberId).ToList(); + return await dbContext.Members + .AnyAsync(x => memberIds.Contains(x.Id), cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Reviews/PostReviewRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Reviews/PostReviewRequestValidator.cs new file mode 100644 index 00000000..6da523a3 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Reviews/PostReviewRequestValidator.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Server.Handlers.Reviews; + +namespace iRLeagueApiCore.Server.Validation.Reviews; + +public sealed class PostReviewRequestValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PostReviewRequestValidator(LeagueDbContext dbContext) + { + this.dbContext = dbContext; + + RuleFor(x => x.SessionId) + .Cascade(CascadeMode.Stop) + .NotEmpty() + .WithMessage("No session selected") + .MustAsync((request, sessionId, cancellationToken) => SessionisValid(sessionId, cancellationToken)) + .WithMessage("Selected session does not exist"); + RuleFor(x => x.Model) + .SetValidator(new PostReviewModelValidator(dbContext)); + } + + private async Task SessionisValid(long sessionId, CancellationToken cancellationToken) + { + return await dbContext.Sessions + .Where(x => x.SessionId == sessionId) + .AnyAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Reviews/PutReviewRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Reviews/PutReviewRequestValidator.cs new file mode 100644 index 00000000..75dfa6ee --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Reviews/PutReviewRequestValidator.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Server.Handlers.Reviews; + +namespace iRLeagueApiCore.Server.Validation.Reviews; + +public sealed class PutReviewRequestValidator : AbstractValidator +{ + public PutReviewRequestValidator(LeagueDbContext dbContext) + { + RuleFor(x => x.Model) + .SetValidator(new PostReviewModelValidator(dbContext)); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Scorings/PostPointRuleModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Scorings/PostPointRuleModelValidator.cs new file mode 100644 index 00000000..73ed4de6 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Scorings/PostPointRuleModelValidator.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Validation.Scorings; + +public sealed class PostPointRuleModelValidator : AbstractValidator +{ + public PostPointRuleModelValidator() + { + RuleFor(x => x.Name).NotEmpty(); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Scorings/PostPointRuleRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Scorings/PostPointRuleRequestValidator.cs new file mode 100644 index 00000000..fc1becb1 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Scorings/PostPointRuleRequestValidator.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.Server.Handlers.Scorings; + +namespace iRLeagueApiCore.Server.Validation.Scorings; + +public sealed class PostPointRuleRequestValidator : AbstractValidator +{ + public PostPointRuleRequestValidator(PostPointRuleModelValidator modelValidator) + { + RuleFor(x => x.Model) + .SetValidator(modelValidator); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Scorings/PutPointRuleModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Scorings/PutPointRuleModelValidator.cs new file mode 100644 index 00000000..c05d5a1f --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Scorings/PutPointRuleModelValidator.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Validation.Scorings; + +public sealed class PutPointRuleModelValidator : AbstractValidator +{ + public PutPointRuleModelValidator(PostPointRuleModelValidator parentValidator) + { + Include(parentValidator); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Scorings/PutPointRuleRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Scorings/PutPointRuleRequestValidator.cs new file mode 100644 index 00000000..387139fc --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Scorings/PutPointRuleRequestValidator.cs @@ -0,0 +1,13 @@ +using iRLeagueApiCore.Server.Handlers.Scorings; + +namespace iRLeagueApiCore.Server.Validation.Scorings; + +public sealed class PutPointRuleRequestValidator : AbstractValidator +{ + + public PutPointRuleRequestValidator(PutPointRuleModelValidator modelValidator) + { + RuleFor(x => x.Model) + .SetValidator(modelValidator); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Seasons/PostSeasonModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Seasons/PostSeasonModelValidator.cs new file mode 100644 index 00000000..988f2289 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Seasons/PostSeasonModelValidator.cs @@ -0,0 +1,13 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Validation.Seasons; + +public sealed class PostSeasonModelValidator : AbstractValidator +{ + public PostSeasonModelValidator() + { + RuleFor(x => x.SeasonName) + .NotEmpty() + .WithMessage("Season name required"); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Seasons/PostSeasonRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Seasons/PostSeasonRequestValidator.cs new file mode 100644 index 00000000..d70fec3b --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Seasons/PostSeasonRequestValidator.cs @@ -0,0 +1,26 @@ +using iRLeagueApiCore.Server.Handlers.Seasons; + +namespace iRLeagueApiCore.Server.Validation.Seasons; + +public sealed class PostSeasonRequestValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PostSeasonRequestValidator(LeagueDbContext dbContext, PostSeasonModelValidator modelValidator) + { + this.dbContext = dbContext; + + RuleFor(x => x.Model) + .SetValidator(modelValidator); + RuleFor(x => x.Model.MainScoringId) + .MustAsync(ScoringExists) + .When(x => x.Model.MainScoringId != null) + .WithMessage("Main scoring not found"); + } + + private async Task ScoringExists(PostSeasonRequest request, long? scoringId, CancellationToken cancellationToken) + { + return await dbContext.Scorings + .AnyAsync(x => x.ScoringId == scoringId); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Seasons/PutSeasonModelValidator.cs b/src/iRLeagueApiCore.Server/Validation/Seasons/PutSeasonModelValidator.cs new file mode 100644 index 00000000..a409091e --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Seasons/PutSeasonModelValidator.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Server.Validation.Seasons; + +public sealed class PutSeasonModelValidator : AbstractValidator +{ + public PutSeasonModelValidator(PostSeasonModelValidator putSeasonValidator) + { + Include(putSeasonValidator); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Seasons/PutSeasonRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Seasons/PutSeasonRequestValidator.cs new file mode 100644 index 00000000..5005a619 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Seasons/PutSeasonRequestValidator.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Server.Handlers.Seasons; + +namespace iRLeagueApiCore.Server.Validation.Seasons; + +public sealed class PutSeasonRequestValidator : AbstractValidator +{ + private readonly LeagueDbContext dbContext; + + public PutSeasonRequestValidator(LeagueDbContext dbContext, PutSeasonModelValidator modelValidator) + { + this.dbContext = dbContext; + + RuleFor(x => x.SeasonId) + .NotEmpty() + .WithMessage("Season id required"); + RuleFor(x => x.Model) + .SetValidator(modelValidator); + RuleFor(x => x.Model.MainScoringId) + .MustAsync(ScoringExists) + .When(x => x.Model.MainScoringId != null) + .WithMessage("Main scoring not found"); + } + + private async Task ScoringExists(PutSeasonRequest request, long? scoringId, CancellationToken cancellationToken) + { + return await dbContext.Scorings + .AnyAsync(x => x.ScoringId == scoringId); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Tracks/ImportTracksCommandValidator.cs b/src/iRLeagueApiCore.Server/Validation/Tracks/ImportTracksCommandValidator.cs new file mode 100644 index 00000000..db5b313d --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Tracks/ImportTracksCommandValidator.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Server.Handlers.Tracks; + +namespace iRLeagueApiCore.Server.Validation.Tracks; + +public sealed class ImportTracksCommandValidator : AbstractValidator +{ + public ImportTracksCommandValidator() + { + RuleFor(x => x.Model.UserName) + .NotEmpty(); + RuleFor(x => x.Model.Password) + .NotEmpty(); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Users/AddLeagueRoleRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Users/AddLeagueRoleRequestValidator.cs new file mode 100644 index 00000000..07a05237 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Users/AddLeagueRoleRequestValidator.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Server.Handlers.Users; + +namespace iRLeagueApiCore.Server.Validation.Users; + +public sealed class AddLeagueRoleRequestValidator : AbstractValidator +{ + public AddLeagueRoleRequestValidator() + { + RuleFor(x => x.RoleName) + .Must(LeagueRoles.IsValidRole) + .WithMessage(request => + $"Invalid value. Valid roles: [{string.Join(", ", LeagueRoles.RolesAvailable)}]"); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Users/PutUserValidator.cs b/src/iRLeagueApiCore.Server/Validation/Users/PutUserValidator.cs new file mode 100644 index 00000000..2d5c5dd7 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Users/PutUserValidator.cs @@ -0,0 +1,17 @@ +using iRLeagueApiCore.Server.Handlers.Users; + +namespace iRLeagueApiCore.Server.Validation.Users; + +public sealed class PutUserValidator : AbstractValidator +{ + public PutUserValidator() + { + RuleFor(x => x.Model.Firstname) + .NotEmpty() + .WithMessage("Firstname is required"); + + RuleFor(x => x.Model.Lastname) + .NotEmpty() + .WithMessage("Lastname is required"); + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Users/RegisterUserValidator.cs b/src/iRLeagueApiCore.Server/Validation/Users/RegisterUserValidator.cs new file mode 100644 index 00000000..32da0bcf --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Users/RegisterUserValidator.cs @@ -0,0 +1,56 @@ +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Users; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.Server.Validation.Users; + +public class RegisterUserValidator : AbstractValidator +{ + private readonly UserManager userManager; + + public RegisterUserValidator(UserManager userManager) + { + this.userManager = userManager; + + RuleFor(x => x.Model.Username) + .NotEmpty() + .MinimumLength(4) + .Matches("^[a-zA-Z0-9_-]{4,}$") + .WithMessage("Username can only contain following characters: \"a-zA-Z0-9_-\"") + .MustAsync(UsernameUnique) + .WithMessage("Username already exists"); + + RuleFor(x => x.Model.Firstname) + .NotEmpty() + .WithMessage("Firstname may not be empty") + .Must(x => x.IndexOfAny(new[] { ';', '!', ',', '$', '&', '§', '"', '/', '{', '}', '[', ']', '\\' }) == -1) + .WithMessage("Firstname may not contain special characters"); + + RuleFor(x => x.Model.Lastname) + .NotEmpty() + .WithMessage("Lastname may not be empty") + .Must(x => x.IndexOfAny(new[] { ';', '!', ',', '$', '&', '§', '"', '/', '{', '}', '[', ']', '\\' }) == -1) + .WithMessage("Lastname may not contain special characters"); + + RuleFor(x => x.Model.Email) + .EmailAddress() + .MustAsync(EmailAddressUnique) + .WithMessage("This email address is already in use by another user"); + + RuleFor(x => x.Model.Password) + .NotEmpty() + .MinimumLength(6) + .Matches("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])?(?=.*[#$^+=!*()@%&]).{8,255}$") + .WithMessage("Password must contain upercase, lowercase and at least one non-alphanumeric letter: \"#$^+=!*()@%&\""); + } + + private async Task UsernameUnique(string username, CancellationToken cancellationToken) + { + return await userManager.FindByNameAsync(username) is null; + } + + private async Task EmailAddressUnique(string email, CancellationToken cancellationToken) + { + return await userManager.FindByEmailAsync(email) is null; + } +} diff --git a/src/iRLeagueApiCore.Server/Validation/Users/RemoveLeagueRoleRequestValidator.cs b/src/iRLeagueApiCore.Server/Validation/Users/RemoveLeagueRoleRequestValidator.cs new file mode 100644 index 00000000..7c131390 --- /dev/null +++ b/src/iRLeagueApiCore.Server/Validation/Users/RemoveLeagueRoleRequestValidator.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Server.Handlers.Users; + +namespace iRLeagueApiCore.Server.Validation.Users; + +public sealed class RemoveLeagueRoleRequestValidator : AbstractValidator +{ + public RemoveLeagueRoleRequestValidator() + { + RuleFor(x => x.RoleName) + .Must(LeagueRoles.IsValidRole) + .WithMessage(request => + $"Invalid value. Valid roles: [{string.Join(", ", LeagueRoles.RolesAvailable)}]"); + } +} diff --git a/src/iRLeagueApiCore.Server/_GlobalUsing.cs b/src/iRLeagueApiCore.Server/_GlobalUsing.cs new file mode 100644 index 00000000..c5227fc5 --- /dev/null +++ b/src/iRLeagueApiCore.Server/_GlobalUsing.cs @@ -0,0 +1,6 @@ +global using FluentValidation; +global using iRLeagueApiCore.Common; +global using iRLeagueApiCore.Server.Exceptions; +global using iRLeagueDatabaseCore.Models; +global using MediatR; +global using Microsoft.EntityFrameworkCore; diff --git a/src/iRLeagueApiCore.Server/appsettings.json b/src/iRLeagueApiCore.Server/appsettings.json new file mode 100644 index 00000000..a09abcc3 --- /dev/null +++ b/src/iRLeagueApiCore.Server/appsettings.json @@ -0,0 +1,75 @@ +{ + "Serilog": { + "MinimumLevel": { + "Default": "Verbose", + "Override": { + "Microsoft": "Information", + "Microsoft.AspNetCore": "Warning", + "System": "Error" + } + }, + "Enrich": [ + "FromLogContext", + "WithMachineName" + ], + "WriteTo": [ + { + "Name": "Console" + }, + { + "Name": "File", + "Args": { + "path": "Logs/log.txt", + "rollingInterval": "Day", + "retainedFileCountLimit": null, + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {Message}{NewLine:1}{Exception:1}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/structuredlog.json", + "rollingInterval": "Day", + "retainedFileCountLimit": null, + "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog" + } + } + ] + }, + "AllowedHosts": "*", + "JWT": { + "ValidAudience": "http://localhost:4200", + "ValidIssuer": "http://localhost:61955", + "Secret": "ByYM000OLlMQG6VVVp1OH7Xzyr7gHuw1qvUC5dcGt3SNM" + }, + "Mail": { + "Host": "localhost", + "NoReplySender": "noreply@irleaguemanager.net" + //"Port": "25", + //"UserName": "username", + //"Password": "password + }, + "IpRateLimiting": { + "EnableEndpointRateLimiting": true, + "StackBlockedRequests": false, + "RealIPHeader": "X-Real-IP", + "ClientIdHeader": "X-ClientId", + "HttpStatusCode": 429, + "IpWhitelist": [ "127.0.0.1", "::1/10" ], + "GeneralRules": [ + { + "Endpoint": "*", + "Period": "5s", + "Limit": 200 + } + ] + }, + "Credentials": [ + { + "Uri": "https://example.com", + "AuthenticationType": "BasicAuth", + "Username": "Username", + "Password": "Password" + } + ] +} diff --git a/src/iRLeagueApiCore.Server/iRLeagueApiCore.Server.csproj b/src/iRLeagueApiCore.Server/iRLeagueApiCore.Server.csproj new file mode 100644 index 00000000..de0c0855 --- /dev/null +++ b/src/iRLeagueApiCore.Server/iRLeagueApiCore.Server.csproj @@ -0,0 +1,92 @@ + + + + net6.0 + f8b50589-89e6-49b7-9dca-793830174a9e + enable + 11 + + + + InProcess + + + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + 0.11.4 + enable + + + + 1701;1702;1591 + + + + 1701;1702;1591 + + + + + <_Parameter1>iRLeagueApiCore.UnitTests + + + + diff --git a/src/iRLeagueApiCore.Services/EmailService/ConfigEmailClientFactory.cs b/src/iRLeagueApiCore.Services/EmailService/ConfigEmailClientFactory.cs new file mode 100644 index 00000000..76ac8566 --- /dev/null +++ b/src/iRLeagueApiCore.Services/EmailService/ConfigEmailClientFactory.cs @@ -0,0 +1,61 @@ +using Microsoft.Extensions.Configuration; +using System.Net; + +namespace iRLeagueApiCore.Services.EmailService; + +public sealed class ConfigEmailClientFactory : IEmailClientFactory +{ + private readonly EmailClientConfiguration clientConfiguration; + private readonly ILoggerFactory loggerFactory; + + public ConfigEmailClientFactory(IConfiguration configuration, ILoggerFactory loggerFactory) + { + clientConfiguration = ReadEmailConfig(configuration); + this.loggerFactory = loggerFactory; + } + + public IEmailClient CreateEmailClient() + { + // first detect if client config is default + if (clientConfiguration.Equals(EmailClientConfiguration.Default)) + { + // return mock client + return new MockEmailClient(); + } + + return new EmailClient(clientConfiguration, loggerFactory.CreateLogger()); + } + + private static EmailClientConfiguration ReadEmailConfig(IConfiguration configuration) + { + var mailConfig = configuration.GetSection("Mail"); + if (mailConfig.Exists() == false) + { + return EmailClientConfiguration.Default; + } + + string host = mailConfig["Host"] + ?? throw new InvalidOperationException("No value provided for \"Mail:Host\" in appsettings"); + if (int.TryParse(mailConfig["Port"], out int port) == false) + { + throw new InvalidOperationException("No value provided for \"Mail:Port\" in appsettings"); + } + string? authUserName = mailConfig["UserName"]; + string? password = mailConfig["Password"]; + string sender = mailConfig["Sender"] + ?? throw new InvalidOperationException("No value provided for \"Mail:Sender\" in appsettings"); + bool.TryParse(mailConfig["EnableSsl"], out bool enableSsl); + + NetworkCredential credentials; + if (authUserName != null && password != null) + { + credentials = new NetworkCredential(authUserName, password); + } + else + { + credentials = new NetworkCredential(); + } + + return new EmailClientConfiguration(host, port, credentials, sender, enableSsl); + } +} diff --git a/src/iRLeagueApiCore.Services/EmailService/EmailClient.cs b/src/iRLeagueApiCore.Services/EmailService/EmailClient.cs new file mode 100644 index 00000000..7e640228 --- /dev/null +++ b/src/iRLeagueApiCore.Services/EmailService/EmailClient.cs @@ -0,0 +1,50 @@ +using System.Net.Mail; + +namespace iRLeagueApiCore.Services.EmailService; + +public sealed class EmailClient : IEmailClient +{ + private readonly ILogger logger; + private readonly EmailClientConfiguration clientConfiguration; + + public EmailClient(EmailClientConfiguration clientConfiguration, ILogger logger) + { + this.clientConfiguration = clientConfiguration; + this.logger = logger; + } + + public async Task SendNoReplyMailAsync(string email, string subject, string body) + { + using var smtpClient = CreateSmtpClient(clientConfiguration); + if (smtpClient == null) + { + logger.LogInformation("No Email SMTP host configured - Emails will not be send. To configure a client specify \"Host\", \"Port\" and \"Sender\" in appsettings \"Mail\" section"); + return; + } + + using var message = new MailMessage(new MailAddress(clientConfiguration.Sender), new MailAddress(email)) + { + Subject = subject, + Body = body, + IsBodyHtml = true, + }; + + logger.LogInformation("Sending Email To:\"{Recipient}\" through Host: \"{Host}\"", email, smtpClient.Host); + await smtpClient.SendMailAsync(message); + } + + private static SmtpClient? CreateSmtpClient(EmailClientConfiguration configuration) + { + if (configuration.Equals(EmailClientConfiguration.Default)) + { + return null; + } + return new() + { + Host = configuration.Host, + Port = configuration.Port, + Credentials = configuration.Credentials, + EnableSsl = configuration.EnableSsl, + }; + } +} diff --git a/src/iRLeagueApiCore.Services/EmailService/EmailClientConfiguration.cs b/src/iRLeagueApiCore.Services/EmailService/EmailClientConfiguration.cs new file mode 100644 index 00000000..93a5ed0c --- /dev/null +++ b/src/iRLeagueApiCore.Services/EmailService/EmailClientConfiguration.cs @@ -0,0 +1,23 @@ +using System.Net; + +namespace iRLeagueApiCore.Services.EmailService; + +public sealed class EmailClientConfiguration +{ + public EmailClientConfiguration(string host, int port, NetworkCredential credentials, string sender, bool enableSsl = true) + { + Host = host; + Port = port; + Credentials = credentials; + Sender = sender; + EnableSsl = enableSsl; + } + + public string Host { get; } + public int Port { get; } + public NetworkCredential Credentials { get; } + public string Sender { get; } + public bool EnableSsl { get; } + + public static EmailClientConfiguration Default { get; } = new(string.Empty, 0, new(), string.Empty, false); +} diff --git a/src/iRLeagueApiCore.Services/EmailService/EmailServiceCollectionExtensions.cs b/src/iRLeagueApiCore.Services/EmailService/EmailServiceCollectionExtensions.cs new file mode 100644 index 00000000..5a834e7c --- /dev/null +++ b/src/iRLeagueApiCore.Services/EmailService/EmailServiceCollectionExtensions.cs @@ -0,0 +1,17 @@ +using iRLeagueApiCore.Services.EmailService; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace Microsoft.Extensions.DependencyInjection; + +public static class EmailServiceCollectionExtensions +{ + public static IServiceCollection AddEmailService(this IServiceCollection services) + { + _ = services ?? throw new ArgumentNullException(nameof(services)); + + services.TryAddScoped(); + services.TryAddTransient(sp => sp.GetRequiredService().CreateEmailClient()); + + return services; + } +} diff --git a/src/iRLeagueApiCore.Services/EmailService/IEmailClient.cs b/src/iRLeagueApiCore.Services/EmailService/IEmailClient.cs new file mode 100644 index 00000000..108d979e --- /dev/null +++ b/src/iRLeagueApiCore.Services/EmailService/IEmailClient.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Services.EmailService; + +public interface IEmailClient +{ + public Task SendNoReplyMailAsync(string email, string subject, string body); +} diff --git a/src/iRLeagueApiCore.Services/EmailService/IEmailClientFactory.cs b/src/iRLeagueApiCore.Services/EmailService/IEmailClientFactory.cs new file mode 100644 index 00000000..78309d61 --- /dev/null +++ b/src/iRLeagueApiCore.Services/EmailService/IEmailClientFactory.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Services.EmailService; + +public interface IEmailClientFactory +{ + public IEmailClient CreateEmailClient(); +} diff --git a/src/iRLeagueApiCore.Services/EmailService/MockEmailClient.cs b/src/iRLeagueApiCore.Services/EmailService/MockEmailClient.cs new file mode 100644 index 00000000..81cf597f --- /dev/null +++ b/src/iRLeagueApiCore.Services/EmailService/MockEmailClient.cs @@ -0,0 +1,9 @@ +namespace iRLeagueApiCore.Services.EmailService; + +public sealed class MockEmailClient : IEmailClient +{ + public Task SendNoReplyMailAsync(string email, string subject, string body) + { + return Task.CompletedTask; + } +} diff --git a/src/iRLeagueApiCore.Services/GlobalUsing.cs b/src/iRLeagueApiCore.Services/GlobalUsing.cs new file mode 100644 index 00000000..8cabe8ed --- /dev/null +++ b/src/iRLeagueApiCore.Services/GlobalUsing.cs @@ -0,0 +1,2 @@ +global using Microsoft.Extensions.Logging; +global using System.Linq.Expressions; diff --git a/src/iRLeagueApiCore.Services/QueueService/BackGroundTaskQueue.cs b/src/iRLeagueApiCore.Services/QueueService/BackGroundTaskQueue.cs new file mode 100644 index 00000000..5b85d5bc --- /dev/null +++ b/src/iRLeagueApiCore.Services/QueueService/BackGroundTaskQueue.cs @@ -0,0 +1,50 @@ +// from ASP.NET Core documentation: +// https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-6.0&tabs=visual-studio + +using System.Threading.Channels; + +public interface IBackgroundTaskQueue +{ + ValueTask QueueBackgroundWorkItemAsync(Func workItem); + + ValueTask> DequeueAsync( + CancellationToken cancellationToken); +} + +public sealed class BackgroundTaskQueue : IBackgroundTaskQueue +{ + private readonly Channel> _queue; + + public BackgroundTaskQueue(int capacity) + { + // Capacity should be set based on the expected application load and + // number of concurrent threads accessing the queue. + // BoundedChannelFullMode.Wait will cause calls to WriteAsync() to return a task, + // which completes only when space became available. This leads to backpressure, + // in case too many publishers/calls start accumulating. + var options = new BoundedChannelOptions(capacity) + { + FullMode = BoundedChannelFullMode.Wait + }; + _queue = Channel.CreateBounded>(options); + } + + public async ValueTask QueueBackgroundWorkItemAsync( + Func workItem) + { + if (workItem == null) + { + throw new ArgumentNullException(nameof(workItem)); + } + + await _queue.Writer.WriteAsync(workItem); + } + + public async ValueTask> DequeueAsync( + CancellationToken cancellationToken) + { + var workItem = await _queue.Reader.ReadAsync(cancellationToken); + + return workItem; + } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Services/QueueService/QueueServiceCollectionExtensions.cs b/src/iRLeagueApiCore.Services/QueueService/QueueServiceCollectionExtensions.cs new file mode 100644 index 00000000..eb6266cc --- /dev/null +++ b/src/iRLeagueApiCore.Services/QueueService/QueueServiceCollectionExtensions.cs @@ -0,0 +1,14 @@ +namespace Microsoft.Extensions.DependencyInjection; + +public static class QueueServiceCollectionExtensions +{ + public static IServiceCollection AddBackgroundQueue(this IServiceCollection services, int queueCapacity = 100) + { + services.AddSingleton(ctx => + { + return new BackgroundTaskQueue(queueCapacity); + }); + services.AddHostedService(); + return services; + } +} diff --git a/src/iRLeagueApiCore.Services/QueueService/QueuedHostedService.cs b/src/iRLeagueApiCore.Services/QueueService/QueuedHostedService.cs new file mode 100644 index 00000000..b2d1cf53 --- /dev/null +++ b/src/iRLeagueApiCore.Services/QueueService/QueuedHostedService.cs @@ -0,0 +1,51 @@ +// from ASP.NET Core documentation: +// https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-6.0&tabs=visual-studio + +using Microsoft.Extensions.Hosting; + +public sealed class QueuedHostedService : BackgroundService +{ + private readonly ILogger _logger; + + public QueuedHostedService(IBackgroundTaskQueue taskQueue, + ILogger logger) + { + TaskQueue = taskQueue; + _logger = logger; + } + + public IBackgroundTaskQueue TaskQueue { get; } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + _logger.LogInformation("Queued Hosted Service is running"); + + await BackgroundProcessing(stoppingToken); + } + + private async Task BackgroundProcessing(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + var workItem = + await TaskQueue.DequeueAsync(stoppingToken); + + try + { + await workItem(stoppingToken); + } + catch (Exception ex) + { + _logger.LogError(ex, + "Error occurred executing {WorkItem}.", nameof(workItem)); + } + } + } + + public override async Task StopAsync(CancellationToken stoppingToken) + { + _logger.LogInformation("Queued Hosted Service is stopping."); + + await base.StopAsync(stoppingToken); + } +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/CalculationPointRuleBase.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/CalculationPointRuleBase.cs new file mode 100644 index 00000000..3940ea2b --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/CalculationPointRuleBase.cs @@ -0,0 +1,41 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal abstract class CalculationPointRuleBase : PointRule +{ + public FilterGroupRowFilter PointFilters { get; set; } = new(); + public FilterGroupRowFilter ChampSeasonFilters { get; set; } = new(); + public FilterGroupRowFilter ResultFilters { get; set; } = new(); + public IEnumerable PointSortOptions { get; set; } = Array.Empty(); + public IEnumerable FinalSortOptions { get; set; } = Array.Empty(); + public IEnumerable BonusPoints { get; set; } = Array.Empty(); + public IEnumerable AutoPenalties { get; set; } = Array.Empty(); + + public override FilterGroupRowFilter GetResultFilters() => ResultFilters; + public override FilterGroupRowFilter GetPointFilters() => PointFilters; + public override FilterGroupRowFilter GetChampSeasonFilters() => ChampSeasonFilters; + public override IEnumerable GetAutoPenalties() => AutoPenalties; + public override IEnumerable GetBonusPoints() => BonusPoints; + + public override IReadOnlyList SortFinal(IEnumerable rows) + { + foreach (var sortOption in FinalSortOptions.Reverse()) + { + rows = rows.OrderBy(sortOption.GetSortingValue()); + } + return rows.ToList(); + } + + public override IReadOnlyList SortForPoints(IEnumerable rows) + { + foreach (var sortOptions in PointSortOptions.Reverse()) + { + rows = rows.OrderBy(sortOptions.GetSortingValue()); + } + return rows.ToList(); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/CalculationServiceBase.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/CalculationServiceBase.cs new file mode 100644 index 00000000..62944316 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/CalculationServiceBase.cs @@ -0,0 +1,476 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using System.ComponentModel; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +abstract internal class CalculationServiceBase : ICalculationService +{ + public abstract Task Calculate(SessionCalculationData data); + + protected static IEnumerable ApplyPoints(IEnumerable rows, PointRule pointRule, + SessionCalculationData data) + { + rows = pointRule.GetChampSeasonFilters().FilterRows(rows); + rows = pointRule.GetResultFilters().FilterRows(rows); + rows = CalculateCompletedPct(rows); + rows = CalculateIntervals(rows); + rows = CalculateAutoPenalties(rows, pointRule.GetAutoPenalties()); + ApplyAddPenaltyDsq(rows); + ApplyAddPenaltyTimes(rows); + rows = pointRule.SortForPoints(rows); + rows = ApplyAddPenaltyPositions(rows); + + IEnumerable pointRows = rows.ToList(); + // Filter for points only + pointRows = pointRule.GetPointFilters().FilterRows(pointRows); + + // Calculation + pointRule.ApplyPoints(data, pointRows.ToList()); + // remove points from filtered rows and set points eligible + pointRows.ForEach(x => x.PointsEligible = true); + rows.Except(pointRows) + .ForEach(x => { + x.RacePoints = 0; + x.PointsEligible = false; + }); + + IEnumerable finalRows = rows; + ApplyAddPenaltyPoints(finalRows); + ApplyReviewPenalties(finalRows, data.AcceptedReviewVotes); + ApplyBonusPoints(pointRows, pointRule.GetBonusPoints()); + ApplyTotalPoints(finalRows); + finalRows = pointRule.SortFinal(finalRows); + // Set final position + foreach ((var row, var position) in finalRows.Select((x, i) => (x, i + 1))) + { + row.FinalPosition = position; + row.FinalPositionChange = row.StartPosition - row.FinalPosition; + } + + return finalRows; + } + + protected static (TId? id, TimeSpan lap) GetBestLapValue(IEnumerable rows, Func idSelector, Func valueSelector) + { + return rows + .Select(row => ((TId? id, TimeSpan lap))(idSelector.Invoke(row), valueSelector.Invoke(row))) + .Where(row => LapIsValid(row.lap)) + .DefaultIfEmpty() + .MinBy(row => row.lap); + } + + protected static IEnumerable<(TId? id, TValue value)> GetBestValues(IEnumerable rows, Func valueSelector, Func idSelector, + Func, TValue> bestValueFunc, EqualityComparer? comparer = default) + { + comparer ??= EqualityComparer.Default; + try + { + var valueRows = rows.Select(row => ((TId? id, TValue value))(idSelector.Invoke(row), valueSelector.Invoke(row))); + var bestValue = bestValueFunc.Invoke(valueRows.Select(x => x.value)); + return valueRows.Where(row => comparer.Equals(row.value, bestValue)); + } + catch (Exception ex) when (ex is InvalidOperationException) + { + return Array.Empty<(TId? id, TValue value)>(); + } + } + + protected static TimeSpan GetAverageLapValue(IEnumerable rows, Func valueSelector, Func weightSelector) + { + double total = 0; + TimeSpan lap = TimeSpan.Zero; + foreach (var row in rows) + { + var w = weightSelector(row); + total += w; + lap += valueSelector(row) * w; + } + + return lap / (total > 0 ? total : 1); + } + + protected static bool LapIsValid(TimeSpan lap) + { + return lap > TimeSpan.Zero; + } + + protected static bool HardChargerEligible(ResultRowCalculationResult row) + { + return row.QualifyingTime > TimeSpan.Zero; + } + + /// + /// Group and combine result rows using the given groupBy key selector + /// + /// + /// rows to combine + /// selector for the key by which to group the rows + /// + protected static IEnumerable CombineResults(IEnumerable rows, Func groupBy) + { + var groupedRows = rows.GroupBy(groupBy); + var combined = new List(); + + foreach (var group in groupedRows.Where(x => x.Any())) + { + var row = new ResultRowCalculationResult(group.First()); + foreach (var groupRow in group.Skip(1)) + { + row.BonusPoints += groupRow.BonusPoints; + row.CompletedLaps += groupRow.CompletedLaps; + row.Incidents += groupRow.Incidents; + row.LeadLaps += groupRow.LeadLaps; + row.PenaltyPoints += groupRow.PenaltyPoints; + row.RacePoints += groupRow.RacePoints; + row.PointsEligible |= groupRow.PointsEligible; + row.Status = Math.Min(row.Status, groupRow.Status); + } + row.StartPosition = group.Last().StartPosition; + row.AvgLapTime = GetAverageLapValue(group, x => x.AvgLapTime, x => x.CompletedLaps); + (_, row.FastestLapTime) = GetBestLapValue(group, x => x.MemberId, x => x.FastestLapTime); + (_, row.QualifyingTime) = GetBestLapValue(group, x => x.MemberId, x => x.QualifyingTime); + row.FastLapNr = 0; + var last = group.Last(); + row.NewCpi = last.NewCpi; + row.NewIrating = last.NewIrating; + row.NewLicenseLevel = last.NewLicenseLevel; + row.NewSafetyRating = last.NewSafetyRating; + combined.Add(row); + } + + return combined.ToList(); + } + + private static AddPenaltyCalculationData CreateAddPenaltyFromAutoPenalty(ResultRowCalculationResult row, AutoPenaltyConfigurationData autoPenalty, + int penaltyMultiplikator) + { + var penalty = new AddPenaltyCalculationData() + { + MemberId = row.MemberId, + Points = autoPenalty.Type == PenaltyType.Points ? autoPenalty.Points * penaltyMultiplikator : 0, + Positions = autoPenalty.Type == PenaltyType.Position ? autoPenalty.Positions * penaltyMultiplikator : 0, + Time = autoPenalty.Type == PenaltyType.Time ? autoPenalty.Time * penaltyMultiplikator : TimeSpan.Zero, + Type = autoPenalty.Type, + }; + return penalty; + } + + private static IEnumerable CalculateAutoPenalties(IEnumerable rows, + IEnumerable autoPenalties) + { + foreach(var autoPenalty in autoPenalties) + { + var penaltyRows = autoPenalty.Conditions + .FilterRows(rows); + var grouped = penaltyRows.GroupBy(x => x); + foreach(var row in grouped.Where(x => x.Any())) + { + row.Key.AddPenalties = row.Key.AddPenalties.Concat(new[] { CreateAddPenaltyFromAutoPenalty(row.Key, autoPenalty, row.Count()) }); + } + } + return rows; + } + + private static IEnumerable ApplyAddPenaltyDsq(IEnumerable rows) + { + foreach (var row in rows.Where(x => x.AddPenalties.Any(x => x.Type == PenaltyType.Disqualification))) + { + foreach (var penalty in row.AddPenalties.Where(x => x.Type == PenaltyType.Disqualification)) + { + row.Status = (int)RaceStatus.Disqualified; + } + } + return rows; + } + + private static IEnumerable ApplyAddPenaltyTimes(IEnumerable rows) + { + foreach (var row in rows.Where(x => x.AddPenalties.Any(x => x.Type == PenaltyType.Time))) + { + foreach (var penalty in row.AddPenalties.Where(x => x.Type == PenaltyType.Time)) + { + row.Interval += penalty.Time; + } + } + return rows; + } + + private static IEnumerable ApplyAddPenaltyPoints(IEnumerable rows) + { + foreach (var row in rows.Where(x => x.AddPenalties.Any(x => x.Type == PenaltyType.Points))) + { + foreach (var penalty in row.AddPenalties.Where(x => x.Type == PenaltyType.Points)) + { + if (penalty.Points < 0) + { + row.BonusPoints -= penalty.Points; + } + else + { + row.PenaltyPoints += penalty.Points; + } + } + } + return rows; + } + + private static IReadOnlyList ApplyAddPenaltyPositions(IEnumerable rows) + { + var modRows = rows.ToList(); + foreach (var row in rows.Where(x => x.AddPenalties.Any(x => x.Type == PenaltyType.Position)).Reverse()) // Start from the back to keep order between mutliple drivers with penalties + { + var movePositions = row.AddPenalties.Where(x => x.Type == PenaltyType.Position).Sum(x => x.Positions); + if (movePositions == 0) + { + continue; + } + var rowIndex = modRows.IndexOf(row); + modRows.Move(rowIndex, movePositions); + } + return modRows; + } + + private static IEnumerable ApplyReviewPenalties(IEnumerable rows, IEnumerable reviewVotes) + { + Func compareIds; + if (rows.Any(x => x.MemberId != null)) + { + compareIds = (row, vote) => vote.MemberAtFaultId == row.MemberId; + } + else + { + compareIds = (row, vote) => vote.TeamAtFaultId == row.TeamId; + } + + foreach (var row in rows) + { + var rowVotes = reviewVotes.Where(vote => compareIds(row, vote)); + foreach (var vote in rowVotes) + { + var penalty = new ReviewPenaltyCalculationResult() + { + ReviewId = vote.ReviewId, + ReviewVoteId = vote.ReviewVoteId, + PenaltyPoints = vote.DefaultPenalty, + }; + row.ReviewPenalties.Add(penalty); + if (penalty.PenaltyPoints < 0) + { + row.BonusPoints -= penalty.PenaltyPoints; + } + else + { + row.PenaltyPoints += penalty.PenaltyPoints; + } + } + } + return rows; + } + + private static IEnumerable ApplyTotalPoints(IEnumerable rows) + { + foreach (var row in rows) + { + row.TotalPoints = row.RacePoints + row.BonusPoints - row.PenaltyPoints; + } + return rows; + } + + private static IEnumerable ApplyBonusPoints(IEnumerable rows, IEnumerable BonusPoints) + { + if (rows.None()) + { + return rows; + } + + var minIncs = rows.Any(x => x.PenaltyPoints == 0) ? rows.Where(x => x.PenaltyPoints == 0).Min(x => x.Incidents) : -1; + var fastestLapRow = GetBestLapValue(rows, x => x, x => x.FastestLapTime); + + foreach (var bonus in BonusPoints) + { + var bonusType = bonus.Type; + var bonusKeyValue = (int)bonus.Value; + var bonusPoints = (int)bonus.Points; + rows = bonusType switch + { + BonusPointType.Position => ApplyPositionBonusPoints(rows, bonusKeyValue, bonusPoints), + BonusPointType.CleanestDriver => ApplyCleanestDriverBonusPoints(rows, bonusPoints), + BonusPointType.FastestLap => ApplyFastestLapBonusPoints(rows, bonusPoints), + BonusPointType.QualyPosition => ApplyStartPositionBonusPoints(rows, bonusKeyValue, bonusPoints), + BonusPointType.MostPositionsGained => ApplyMostPositionsGainedBonusPoints(rows, bonusPoints), + BonusPointType.MostPositionsLost => ApplyMostPositionsLostBonusPoints(rows, bonusPoints), + BonusPointType.LeadOneLap => ApplyLeadOneLapBonusPoints(rows, bonusPoints), + BonusPointType.LeadMostLaps => ApplyLeadMostLapsBonusPoints(rows, bonusPoints), + BonusPointType.NoIncidents => ApplyNoIncidentsBonusPoints(rows, bonusPoints), + BonusPointType.FastestAverageLap => ApplyFastestAverageLapBonusPoints(rows, bonusPoints), + BonusPointType.Custom => ApplyCustomBonusPoints(rows, bonus.Conditions, bonusPoints), + _ => rows, + }; + } + + return rows; + } + + private static IEnumerable ApplyCustomBonusPoints(IEnumerable rows, FilterGroupRowFilter conditions, + int bonusPoints) + { + var bonusRows = conditions.FilterRows(rows); + foreach (var row in bonusRows) + { + row.BonusPoints += bonusPoints; + } + return rows; + } + + private static IEnumerable ApplyFastestAverageLapBonusPoints(IEnumerable rows, int points) + { + var (row, lapTime) = GetBestLapValue(rows, x => x, x => x.AvgLapTime); + if (row is not null) + { + row.BonusPoints += points; + } + return rows; + } + + private static IEnumerable ApplyNoIncidentsBonusPoints(IEnumerable rows, int points) + { + foreach(var row in rows) + { + if (row.Incidents == 0) + { + row.BonusPoints += points; + } + } + return rows; + } + + private static IEnumerable ApplyLeadMostLapsBonusPoints(IEnumerable rows, int points) + { + var mostLapsLead = rows.Max(x => x.LeadLaps); + foreach(var row in rows) + { + if (row.LeadLaps == mostLapsLead) + { + row.BonusPoints += points; + } + } + return rows; + } + + private static IEnumerable ApplyLeadOneLapBonusPoints(IEnumerable rows, int points) + { + foreach(var row in rows) + { + if (row.LeadLaps > 0) + { + row.BonusPoints += points; + } + } + return rows; + } + + private static IEnumerable ApplyMostPositionsLostBonusPoints(IEnumerable rows, int points) + { + var mostPositionsLost = rows.Max(x => x.PositionChange); + foreach (var row in rows) + { + if (row.PositionChange == mostPositionsLost) + { + row.BonusPoints += points; + } + } + return rows; + } + + private static IEnumerable ApplyMostPositionsGainedBonusPoints(IEnumerable rows, int points) + { + var mostPositionsGained = rows.Min(x => x.PositionChange); + foreach(var row in rows) + { + if (row.PositionChange == mostPositionsGained) + { + row.BonusPoints += points; + } + } + return rows; + } + + private static IEnumerable ApplyPositionBonusPoints(IEnumerable rows, int position, int points) + { + foreach (var row in rows) + { + if (row.FinalPosition == position) + { + row.BonusPoints += points; + } + } + return rows; + } + + private static IEnumerable ApplyCleanestDriverBonusPoints(IEnumerable rows, int points) + { + static bool condition(ResultRowCalculationResult x) => x.PenaltyPoints == 0; + var minIncRows = GetBestValues(rows.Where(condition), x => x.Incidents, x => x, x => x.Min()) + .Select(x => x.id) + .NotNull(); + foreach (var row in minIncRows) + { + row.BonusPoints += points; + } + return rows; + } + + private static IEnumerable ApplyFastestLapBonusPoints(IEnumerable rows, int points) + { + var (row, lapTime) = GetBestLapValue(rows, x => x, x => x.FastestLapTime); + if (row is not null) + { + row.BonusPoints += points; + } + return rows; + } + + private static IEnumerable ApplyStartPositionBonusPoints(IEnumerable rows, int position, int points) + { + foreach (var row in rows) + { + if (row.StartPosition == position) + { + row.BonusPoints += points; + } + } + return rows; + } + + protected static IEnumerable CalculateCompletedPct(IEnumerable rows) + { + var laps = rows.MaxOrDefault(x => x.CompletedLaps); + if (laps == 0) + { + return rows; + } + + foreach (var row in rows) + { + row.CompletedPct = row.CompletedLaps / laps; + } + + return rows; + } + + private static IEnumerable CalculateIntervals(IEnumerable rows) + { + int totalLaps = (int)rows.MaxOrDefault(x => x.CompletedLaps); + foreach (var row in rows) + { + if (row.Interval.Days > 0) + { + row.Interval = TimeSpan.FromDays(totalLaps - row.CompletedLaps); + } + } + return rows; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/ColumnValueRowFilter.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/ColumnValueRowFilter.cs new file mode 100644 index 00000000..9e3c89df --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/ColumnValueRowFilter.cs @@ -0,0 +1,132 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Models; +using System.Globalization; +using System.Reflection; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class ColumnValueRowFilter : RowFilter +{ + public bool AllowForEach { get; private set; } + + /// + /// Create an instance of a + /// + /// Name of the property matching the desired column + /// Type of comparison to execute + /// Values corresponding to comparator + /// Action to perform: Keep / Remove + /// Enable multiplication of rows using "ForEach" comparator + /// + public ColumnValueRowFilter(string propertyName, ComparatorType comparator, IEnumerable values, MatchedValueAction action, bool allowForEach = false) + { + Action = action; + AllowForEach = allowForEach; + try + { + ColumnProperty = GetColumnPropertyInfo(propertyName); + } + catch (InvalidOperationException ex) + { + throw new ArgumentException($"Parameter value {propertyName} did not target a valid column property on type {typeof(ResultRowCalculationResult)}", + nameof(propertyName), ex); + } + Comparator = comparator; + CompareFunc = GetCompareFunction(comparator); + try + { + FilterValues = GetFilterValuesOfType(ColumnProperty.PropertyType, values).ToList(); + } + catch (Exception ex) when (ex is InvalidCastException || + ex is FormatException || + ex is OverflowException || + ex is ArgumentNullException) + { + throw new ArgumentException($"Parameter was not of type {ColumnProperty.PropertyType} of column property {ColumnProperty.Name}", nameof(values), ex); + } + } + + public PropertyInfo ColumnProperty { get; } + public ComparatorType Comparator { get; } + private Func, bool> CompareFunc { get; } + public IEnumerable FilterValues { get; } + public MatchedValueAction Action { get; } + + public override IEnumerable FilterRows(IEnumerable rows) + { + var match = rows.Where(x => MatchFilterValues(x, ColumnProperty, FilterValues, CompareFunc)); + if (Comparator == ComparatorType.ForEach && AllowForEach) + { + // special handling for ForEach --> duplicate rows by multiple of values + match = MultiplyRows(match, ColumnProperty, FilterValues); + } + return Action switch + { + MatchedValueAction.Keep => match, + MatchedValueAction.Remove => rows.Except(match), + _ => rows, + }; + } + + private static bool MatchFilterValues(ResultRowCalculationResult row, PropertyInfo property, IEnumerable filterValues, Func, bool> compare) + { + var value = (IComparable?)property.GetValue(row); + return compare(value, filterValues); + } + + private static PropertyInfo GetColumnPropertyInfo(string propertyName) + { + var sourceType = typeof(ResultRowCalculationResult); + var propertyInfo = sourceType.GetProperty(propertyName) + ?? throw new InvalidOperationException($"{typeof(ResultRowCalculationResult)} does not have a property with name {propertyName}"); + if (typeof(IComparable).IsAssignableFrom(propertyInfo.PropertyType) == false) + { + throw new InvalidOperationException($"Column {propertyName} of type {typeof(ResultRowCalculationResult)} does not implement IComparable"); + } + return propertyInfo; + } + + private static IEnumerable GetFilterValuesOfType(Type type, IEnumerable values) + { + if (type.Equals(typeof(TimeSpan))) + { + return values.Select(x => TimeSpan.Parse(x)).Cast(); + } + return values.Select(x => Convert.ChangeType(x, type, CultureInfo.InvariantCulture)).Cast(); + } + + private static IEnumerable MultiplyRows(IEnumerable rows, PropertyInfo property, + IEnumerable filterValues) + { + if (filterValues.Any() == false) + { + return rows; + } + var compareValue = Convert.ToDouble(filterValues.First()); + List multipliedRows = new(); + foreach (var row in rows) + { + var value = Convert.ToDouble(property.GetValue(row)); + var count = (int)(value / compareValue); + for (int i=0; i, bool> GetCompareFunction(ComparatorType comparatorType) + => comparatorType switch + { + ComparatorType.IsBigger => (x, y) => { var c = x?.CompareTo(y.FirstOrDefault()); return c == 1; }, + ComparatorType.IsBiggerOrEqual => (x, y) => { var c = x?.CompareTo(y.FirstOrDefault()); return c == 1 || c == 0; }, + ComparatorType.IsEqual => (x, y) => { var c = x?.CompareTo(y.FirstOrDefault()); return c == 0; }, + ComparatorType.IsSmallerOrEqual => (x, y) => { var c = x?.CompareTo(y.FirstOrDefault()); return c == -1 || c == 0; }, + ComparatorType.IsSmaller => (x, y) => { var c = x?.CompareTo(y.FirstOrDefault()); return c == -1; }, + ComparatorType.NotEqual => (x, y) => { var c = x?.CompareTo(y.FirstOrDefault()); return c == 1 || c == -1; }, + ComparatorType.InList => (x, y) => { var c = y.Any(z => x?.CompareTo(z) == 0); return c; }, + ComparatorType.ForEach => (x, y) => { var c = x?.CompareTo(y.FirstOrDefault()); return c == 1 || c == 0; }, + _ => (x, y) => true, + }; +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/DefaultPointRule.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/DefaultPointRule.cs new file mode 100644 index 00000000..786807de --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/DefaultPointRule.cs @@ -0,0 +1,40 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal class DefaultPointRule : PointRule where TRow : IPointRow, IPenaltyRow +{ + private readonly FilterGroupRowFilter filters = new(Array.Empty<(FilterCombination, RowFilter)>()); + + public override FilterGroupRowFilter GetPointFilters() => filters; + public override FilterGroupRowFilter GetResultFilters() => filters; + public override FilterGroupRowFilter GetChampSeasonFilters() => filters; + + public override IEnumerable GetAutoPenalties() => Array.Empty(); + + public override IReadOnlyList ApplyPoints(SessionCalculationData _, IReadOnlyList rows) + { + foreach (var row in rows) + { + row.TotalPoints = row.RacePoints + row.BonusPoints - row.PenaltyPoints; + } + return rows; + } + + public override IReadOnlyList SortFinal(IEnumerable rows) => DefaultPointRule.DefaultSort(rows); + + public override IReadOnlyList SortForPoints(IEnumerable rows) => DefaultPointRule.DefaultSort(rows); + + public override IEnumerable GetBonusPoints() => Array.Empty(); + + private static IReadOnlyList DefaultSort(IEnumerable rows) where T : TRow + { + if (rows is IReadOnlyList list) + { + return list; + } + return rows.ToList(); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/DefaultRowFilter.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/DefaultRowFilter.cs new file mode 100644 index 00000000..d1efc03f --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/DefaultRowFilter.cs @@ -0,0 +1,9 @@ +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class DefaultRowFilter : RowFilter +{ + public override IEnumerable FilterRows(IEnumerable rows) + { + return rows; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/EventCalculationService.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/EventCalculationService.cs new file mode 100644 index 00000000..3510faa5 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/EventCalculationService.cs @@ -0,0 +1,95 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class EventCalculationService : ICalculationService +{ + private readonly EventCalculationConfiguration config; + private readonly ICalculationServiceProvider + sessionCalculationServiceProvider; + + public EventCalculationService(EventCalculationConfiguration config, + ICalculationServiceProvider sessionCalculationServiceProvider) + { + this.config = config; + this.sessionCalculationServiceProvider = sessionCalculationServiceProvider; + } + + public async Task Calculate(EventCalculationData data) + { + if (config.EventId != data.EventId) + { + throw new InvalidOperationException($"EventId in configuration and provided data set does not match -> config:{config.EventId} | data:{data.EventId}"); + } + + EventCalculationResult result = new(data); + result.ResultId = config.ResultId; + result.ResultConfigId = config.ResultConfigId; + result.ChampSeasonId = config.ChampSeasonId; + result.Name = config.DisplayName; + List sessionResults = new(); + foreach (var sessionConfig in config.SessionResultConfigurations.Where(x => x.IsCombinedResult == false).OrderBy(x => x.SessionNr)) + { + var sessionData = data.SessionResults + .FirstOrDefault(x => x.SessionNr == sessionConfig.SessionNr); + if (sessionData == null) + { + continue; + } + sessionData = AssignAddPenalties(sessionData, data.AddPenalties); + + var sessionCalculationService = sessionCalculationServiceProvider.GetCalculationService(sessionConfig); + sessionResults.Add(await sessionCalculationService.Calculate(sessionData)); + } + if (config.SessionResultConfigurations.Any(x => x.IsCombinedResult)) + { + var combinedConfig = config.SessionResultConfigurations.First(x => x.IsCombinedResult); + IEnumerable combinedRows; + if (data.SessionResults.Any(x => x.SessionNr == 999) && combinedConfig.UseExternalSourcePoints) + { + combinedRows = data.SessionResults.First(x => x.SessionNr == 999).ResultRows; + } + else + { + var combinedSessionNrs = config.SessionResultConfigurations + .Where(x => x.IsCombinedResult == false) + .Where(x => x.SessionType == SessionType.Race) + .Select(x => x.SessionNr); + combinedRows = sessionResults + .Where(x => combinedSessionNrs.Contains(x.SessionNr)) + .OrderByDescending(x => x.SessionNr) + .SelectMany(x => x.ResultRows); + } + if (combinedRows.Any()) + { + var combinedData = new SessionCalculationData() + { + LeagueId = combinedConfig.LeagueId, + SessionId = null, + SessionNr = 999, + ResultRows = combinedRows, + }; + combinedData = AssignAddPenalties(combinedData, data.AddPenalties); + var combinedCalculationService = sessionCalculationServiceProvider.GetCalculationService(combinedConfig); + sessionResults.Add(await combinedCalculationService.Calculate(combinedData)); + } + } + result.SessionResults = sessionResults; + + return result; + } + + private static SessionCalculationData AssignAddPenalties(SessionCalculationData data, IEnumerable addPenalties) + { + var sessionPenalties = addPenalties.Where(x => x.SessionNr == data.SessionNr); + data.ResultRows.ForEach(row => + row.AddPenalties = sessionPenalties + .Where(x => + (x.MemberId != null && x.MemberId == row.MemberId) || + (x.MemberId == null && x.TeamId != null && x.TeamId == row.TeamId)) + .ToList()); + return data; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/EventCalculationServiceProvider.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/EventCalculationServiceProvider.cs new file mode 100644 index 00000000..689fedd1 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/EventCalculationServiceProvider.cs @@ -0,0 +1,21 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class EventCalculationServiceProvider : + ICalculationServiceProvider +{ + private readonly ICalculationServiceProvider + sessionCalculationServiceProvider; + + public EventCalculationServiceProvider( + ICalculationServiceProvider sessionCalculationServiceProvider) + { + this.sessionCalculationServiceProvider = sessionCalculationServiceProvider; + } + + public ICalculationService GetCalculationService(EventCalculationConfiguration config) + { + return new EventCalculationService(config, sessionCalculationServiceProvider); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/FilterGroupRowFilter.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/FilterGroupRowFilter.cs new file mode 100644 index 00000000..83a24f16 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/FilterGroupRowFilter.cs @@ -0,0 +1,38 @@ +namespace iRLeagueApiCore.Services.ResultService.Calculation; +internal sealed class FilterGroupRowFilter : RowFilter +{ + private readonly IList<(FilterCombination combination, RowFilter rowFilter)> filters; + + public IEnumerable<(FilterCombination combination, RowFilter rowFilter)> GetFilters() => filters; + + public FilterGroupRowFilter() + { + filters = new List<(FilterCombination, RowFilter)>(); + } + + public FilterGroupRowFilter(IEnumerable<(FilterCombination, RowFilter)> filters) + { + this.filters = filters.ToList(); + } + + public override IEnumerable FilterRows(IEnumerable rows) + { + var originalRows = rows.ToList(); + foreach(var (combination, filter) in filters) + { + rows = combination switch + { + FilterCombination.And => filter.FilterRows(rows), + FilterCombination.Or => rows.Union(filter.FilterRows(originalRows)), + _ => rows, + }; + } + return rows.OrderBy(x => originalRows.IndexOf(x)); + } +} + +public enum FilterCombination +{ + And, + Or, +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/FormulaParameters.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/FormulaParameters.cs new file mode 100644 index 00000000..81d670fa --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/FormulaParameters.cs @@ -0,0 +1,28 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; +internal record FormulaParameter(string[] Aliases, string Description, Func valueFunc); + +public static class FormulaParameters +{ + internal static IEnumerable Parameters { get; } = new List() + { + new(["pos", "position"], "Finish position", (_, row) => row.FinishPosition), + new(["start", "start_position"], "Starting position", (_, row) => row.StartPosition), + new(["irating"], "Irating at the start of the session", (_, row) => row.OldIrating), + new(["sof", "strength_of_field"], "SOF - Strength of field (Irating)", (session, _) => session.Sof), + new(["count", "driver_count"], "Number of drivers/teams in the result", (session, _) => session.ResultRows.Count()), + new(["flap", "fastest_lap"], "Personal fastest lap", (_, row) => row.FastestLapTime.TotalSeconds), + new(["qlap", "qualy_lap"], "Personal qualy lap", (_, row) => row.QualifyingTime.TotalSeconds), + new(["avglap", "avg_lap"], "Personal avg. lap", (_, row) => row.AvgLapTime.TotalSeconds), + new(["flapsession", "session_fastest_lap"], "Fastest lap in the session", (session, _) => session.FastestLap.TotalSeconds), + new(["qlapsession", "session_fastest_qualy_lap"], "Fastest qualy lap in the session", (session, _) => session.FastestQualyLap.TotalSeconds), + new(["avglapsession", "session_fastest_avg_lap"], "Fastest avg. lap in the session", (session, _) => session.FastestAvgLap.TotalSeconds), + }; + + internal static IDictionary ParameterDict => Parameters + .SelectMany(x => x.Aliases.Select(y => (name: y, parameter: x))) + .ToDictionary(k => k.name, v => v.parameter); + + public static IEnumerable<(string[] aliases, string description)> ParameterInfo => Parameters.Select(x => (x.Aliases, x.Description)); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/FormulaPointRule.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/FormulaPointRule.cs new file mode 100644 index 00000000..a72c9eb0 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/FormulaPointRule.cs @@ -0,0 +1,42 @@ + +using iRLeagueApiCore.Services.ResultService.Models; +using NCalc; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; +internal class FormulaPointRule : CalculationPointRuleBase +{ + public string Formula { get; } + public bool AllowNegativePoints { get; } + private static IDictionary _parameters = FormulaParameters.ParameterDict; + + public FormulaPointRule(string formula, bool allowNegativePoints) + { + Formula = formula; + AllowNegativePoints = allowNegativePoints; + } + + public override IReadOnlyList ApplyPoints(SessionCalculationData session, IReadOnlyList rows) + { + // prepare parameters + var e = new NCalc.Expression(Formula, EvaluateOptions.IterateParameters); + foreach (var (key, parameter) in _parameters) + { + e.Parameters[key] = rows.Select(row => parameter.valueFunc.Invoke(session, row)).ToArray(); + } + // calculate + if (e.Evaluate() is not IList points) + { + return rows; + } + // assign points to rows + foreach (var (row, rowPoints) in rows.Zip(points)) + { + row.RacePoints = Convert.ToDouble(rowPoints); + if (!AllowNegativePoints) + { + row.RacePoints = Math.Max(row.RacePoints, 0); + } + } + return rows; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/ICalculationService.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/ICalculationService.cs new file mode 100644 index 00000000..97ed5a84 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/ICalculationService.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +public interface ICalculationService +{ + public Task Calculate(TIn data); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/ICalculationServiceProvider.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/ICalculationServiceProvider.cs new file mode 100644 index 00000000..d6a265a1 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/ICalculationServiceProvider.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +public interface ICalculationServiceProvider +{ + public ICalculationService GetCalculationService(TConfig config); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/IdRowFilter.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/IdRowFilter.cs new file mode 100644 index 00000000..72316bed --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/IdRowFilter.cs @@ -0,0 +1,48 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Models; +using System.Diagnostics.Eventing.Reader; +using System.Globalization; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; +internal sealed class IdRowFilter : RowFilter +{ + public IReadOnlyCollection MatchIds; + public Func GetIdFunc; + public MatchedValueAction Action; + + /// + /// Create new instance of member or team row filter + /// + /// + /// + /// If id cannot be parsed as long + public IdRowFilter(IEnumerable idValues, Func getIdFunc, MatchedValueAction action) + { + MatchIds = idValues.Select(GetIdValue).ToList(); + GetIdFunc = getIdFunc; + Action = action; + } + + public override IEnumerable FilterRows(IEnumerable rows) + { + var match = rows.Where(x => MatchIds.Contains(GetIdFunc(x))); + return Action switch + { + MatchedValueAction.Keep => match, + MatchedValueAction.Remove => rows.Except(match), + _ => rows, + }; + } + + private TId? GetIdValue(string idString) + { + try + { + return (TId?)Convert.ChangeType(idString, typeof(TId?), CultureInfo.InvariantCulture); + } + catch (Exception ex) when (ex is InvalidCastException || ex is FormatException || ex is ArgumentException) + { + throw new ArgumentException($"Argument \"{idString}\" is not a valid id"); + } + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/MaxPointRule.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/MaxPointRule.cs new file mode 100644 index 00000000..cfc5a668 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/MaxPointRule.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class MaxPointRule : CalculationPointRuleBase +{ + public int MaxPoints { get; private set; } + public int DropOff { get; private set; } + + public MaxPointRule(int maxPoints, int dropOff) + { + MaxPoints = maxPoints; + DropOff = dropOff; + } + + public override IReadOnlyList ApplyPoints(SessionCalculationData _, IReadOnlyList rows) + { + foreach ((var row, var pos) in rows.Select((x, i) => (x, i + 1))) + { + row.RacePoints = GetPointsForPosition(pos); + } + return rows; + } + + private int GetPointsForPosition(int pos) + { + return Math.Max(MaxPoints - (pos - 1) * DropOff, 0); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/MemberSessionCalculationService.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/MemberSessionCalculationService.cs new file mode 100644 index 00000000..68815eda --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/MemberSessionCalculationService.cs @@ -0,0 +1,49 @@ +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class MemberSessionCalculationService : CalculationServiceBase +{ + private readonly SessionCalculationConfiguration config; + + public MemberSessionCalculationService(SessionCalculationConfiguration config) + { + this.config = config; + } + + public override Task Calculate(SessionCalculationData data) + { + var rows = data.ResultRows + .Select(row => new ResultRowCalculationResult(row)) + .Where(row => row.MemberId != null) + .ToList(); + if (config.IsCombinedResult) + { + rows = CombineResults(rows, x => x.MemberId).ToList(); + } + var pointRule = config.PointRule; + var finalRows = ApplyPoints(rows, pointRule, data); + + var result = new SessionCalculationResult(data) + { + Name = config.Name, + SessionResultId = config.SessionResultId, + ResultRows = finalRows, + SessionNr = data.SessionNr + }; + (result.FastestAvgLapDriverMemberId, result.FastestAvgLap) = GetBestLapValue(finalRows, x => x.MemberId, x => x.AvgLapTime); + (result.FastestLapDriverMemberId, result.FastestLap) = GetBestLapValue(finalRows, x => x.MemberId, x => x.FastestLapTime); + (result.FastestQualyLapDriverMemberId, result.FastestQualyLap) = GetBestLapValue(finalRows, x => x.MemberId, x => x.QualifyingTime); + result.CleanestDrivers = GetBestValues(rows, x => x.Incidents, x => x.MemberId, x => x.Min()) + .Select(x => x.id) + .NotNull() + .ToList(); + result.HardChargers = GetBestValues(rows.Where(HardChargerEligible), x => x.FinalPositionChange, x => x.MemberId, x => x.Max()) + .Select(x => x.id) + .NotNull() + .ToList(); + + return Task.FromResult(result); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/MemberStandingCalculationService.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/MemberStandingCalculationService.cs new file mode 100644 index 00000000..fd1917c1 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/MemberStandingCalculationService.cs @@ -0,0 +1,114 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class MemberStandingCalculationService : StandingCalculationServiceBase, ICalculationService +{ + public MemberStandingCalculationService(StandingCalculationConfiguration config) : base(config) + { + } + + public override Task Calculate(StandingCalculationData data) + { + var (previousSessionResults, currentSessionResults) = GetPreviousAndCurrentSessionResults(data, config.UseCombinedResult); + + static long? keySelector(ResultRowCalculationResult x) => x.MemberId; + var previousMemberEventResults = GetGroupedEventResults(previousSessionResults, keySelector); + var currentMemberEventResult = GetGroupedEventResult(currentSessionResults, keySelector); + + var memberStandingRows = CalculateMemberStandingRows(previousMemberEventResults, currentMemberEventResult); + + // Sort and apply positions standings previous + memberStandingRows = SortStandingRows(memberStandingRows, x => x.previous, config.SortOptions) + .ToList(); + foreach (var (memberStandingRow, position) in memberStandingRows.Select((x, i) => (x, i + 1))) + { + memberStandingRow.previous.Position = position; + } + + // Sort and apply positions standings current + memberStandingRows = SortStandingRows(memberStandingRows, x => x.current, config.SortOptions) + .ToList(); + + var finalStandingRows = new List(); + foreach (var (memberStandingRow, position) in memberStandingRows.Select((x, i) => (x, i + 1))) + { + memberStandingRow.current.Position = position; + var final = DiffStandingRows(memberStandingRow.previous, memberStandingRow.current); + finalStandingRows.Add(final); + } + + var standingResult = new StandingCalculationResult() + { + LeagueId = config.LeagueId, + EventId = config.EventId, + Name = config.DisplayName, + SeasonId = config.SeasonId, + ChampSeasonId = config.ChampSeasonId, + StandingConfigId = config.StandingConfigId, + StandingRows = finalStandingRows + }; + return Task.FromResult(standingResult); + } + + private IEnumerable<(long memberId, StandingRowCalculationResult previous, StandingRowCalculationResult current)> CalculateMemberStandingRows( + Dictionary>> previousMemberResults, + Dictionary> currentMemberResult) + { + var memberIds = previousMemberResults.Keys.Concat(currentMemberResult.Keys).Distinct(); + List<(long memberId, StandingRowCalculationResult previous, StandingRowCalculationResult current)> memberStandingRows = new(); + foreach (var memberId in memberIds) + { + // sort by best race points each event + var previousEventResults = (previousMemberResults.GetValueOrDefault(memberId) ?? Array.Empty>()) + .OrderByDescending(GetEventOrderValue); + var currentResult = currentMemberResult.GetValueOrDefault(memberId); + var standingRow = new StandingRowCalculationResult(); + var lastResult = currentResult ?? previousEventResults.FirstOrDefault(); + var lastRow = lastResult?.SessionResults.LastOrDefault()?.ResultRow; + if (lastRow is null) + { + continue; + } + // static data + standingRow.MemberId = lastRow.MemberId; + standingRow.CarClass = lastRow.CarClass; + standingRow.ClassId = lastRow.ClassId; + standingRow.TeamId = lastRow.TeamId; + standingRow.StartIrating = lastRow.SeasonStartIrating; + standingRow.LastIrating = lastRow.NewIrating; + + // accumulated data + var previousStandingRow = new StandingRowCalculationResult(standingRow); + + var previousSessionResults = previousEventResults.SelectMany(x => x.SessionResults); + var countedEventResults = previousEventResults.Take(config.WeeksCounted); + var countedSessionResults = countedEventResults.SelectMany(x => x.SessionResults); + previousStandingRow = AccumulateOverallSessionResults(previousStandingRow, previousSessionResults); + previousStandingRow = AccumulateCountedSessionResults(previousStandingRow, countedSessionResults); + previousStandingRow = AccumulateTotalPoints(previousStandingRow); + previousStandingRow = SetScoredResultRows(previousStandingRow, previousSessionResults, countedSessionResults); + + if (currentResult is not null) + { + var currentSessionResults = previousEventResults.Concat(new[] { currentResult }) + .OrderByDescending(GetEventOrderValue); + var currentMemberSessionResults = currentSessionResults.SelectMany(x => x.SessionResults); + var currentCountedResults = currentSessionResults.Take(config.WeeksCounted); + var currentCountedSessionResults = currentCountedResults.SelectMany(x => x.SessionResults); + standingRow = AccumulateOverallSessionResults(standingRow, currentMemberSessionResults); + standingRow = AccumulateCountedSessionResults(standingRow, currentCountedSessionResults); + standingRow = AccumulateTotalPoints(standingRow); + standingRow = SetScoredResultRows(standingRow, currentMemberSessionResults, currentCountedSessionResults); + } + else + { + standingRow = previousStandingRow; + } + + memberStandingRows.Add((memberId, previousStandingRow, standingRow)); + } + + return memberStandingRows; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/PerPlacePointRule.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/PerPlacePointRule.cs new file mode 100644 index 00000000..097c1ee6 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/PerPlacePointRule.cs @@ -0,0 +1,22 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class PerPlacePointRule : CalculationPointRuleBase +{ + public IReadOnlyDictionary PointsPerPlace { get; private set; } + + public PerPlacePointRule(IReadOnlyDictionary pointPerPlace) + { + PointsPerPlace = pointPerPlace; + } + + public override IReadOnlyList ApplyPoints(SessionCalculationData _, IReadOnlyList rows) + { + foreach ((var row, var pos) in rows.Select((x, i) => (x, i + 1))) + { + row.RacePoints = PointsPerPlace.TryGetValue(pos, out double points) ? points : 0d; + } + return rows; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/PointRule.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/PointRule.cs new file mode 100644 index 00000000..881c8ba8 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/PointRule.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal abstract class PointRule where TRow : IPointRow, IPenaltyRow +{ + public abstract FilterGroupRowFilter GetPointFilters(); + public abstract FilterGroupRowFilter GetResultFilters(); + public abstract FilterGroupRowFilter GetChampSeasonFilters(); + public abstract IEnumerable GetAutoPenalties(); + public abstract IEnumerable GetBonusPoints(); + public abstract IReadOnlyList SortForPoints(IEnumerable rows) where T : TRow; + public abstract IReadOnlyList ApplyPoints(SessionCalculationData session, IReadOnlyList rows) where T : TRow; + public abstract IReadOnlyList SortFinal(IEnumerable rows) where T : TRow; + + private readonly static DefaultPointRule defaultPointRule = new(); + public static PointRule Default() => defaultPointRule; +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/RowFilter.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/RowFilter.cs new file mode 100644 index 00000000..d39f1257 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/RowFilter.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal abstract class RowFilter +{ + public abstract IEnumerable FilterRows(IEnumerable rows) where T : TRow; + + public static RowFilter Default() => new DefaultRowFilter(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/SessionCalculationServiceProvider.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/SessionCalculationServiceProvider.cs new file mode 100644 index 00000000..5c4eddbe --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/SessionCalculationServiceProvider.cs @@ -0,0 +1,18 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class SessionCalculationServiceProvider : + ICalculationServiceProvider +{ + public ICalculationService GetCalculationService(SessionCalculationConfiguration config) + { + return config.ResultKind switch + { + ResultKind.Member => new MemberSessionCalculationService(config), + ResultKind.Team => new TeamSessionCalculationService(config), + _ => throw new InvalidOperationException($"Unknown Scoring Kind: {config.ResultKind}"), + }; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/StandingCalculationServiceBase.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/StandingCalculationServiceBase.cs new file mode 100644 index 00000000..a2d2d480 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/StandingCalculationServiceBase.cs @@ -0,0 +1,172 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal abstract class StandingCalculationServiceBase : ICalculationService +{ + protected readonly StandingCalculationConfiguration config; + + public StandingCalculationServiceBase(StandingCalculationConfiguration config) + { + this.config = config; + } + + protected (IEnumerable PreviousResults, EventSessionResults CurrentResult) GetPreviousAndCurrentSessionResults( + StandingCalculationData data, bool useCombinedResult) + { + IEnumerable previousResults; + EventSessionResults currentResult; + if (config.UseCombinedResult) + { + previousResults = data.PreviousEventResults + .Select(eventResult => new EventSessionResults(eventResult, eventResult.SessionResults.OrderBy(x => x.SessionNr).TakeLast(1))); + currentResult = new EventSessionResults(data.CurrentEventResult, data.CurrentEventResult.SessionResults.OrderBy(x => x.SessionNr).TakeLast(1)); + } + else + { + previousResults = data.PreviousEventResults + .Select(eventResult => new EventSessionResults(eventResult, eventResult.SessionResults.Where(x => x.Name != "Practice" && x.Name != "Qualifying"))); + currentResult = new EventSessionResults(data.CurrentEventResult, + data.CurrentEventResult.SessionResults.Where(x => x.Name != "Practice" && x.Name != "Qualifying")); + } + return (previousResults, currentResult); + } + + protected Dictionary> GetGroupedEventResult(EventSessionResults sessionResults, + Func groupBy) where T : struct + { + return GetGroupedEventResults(new[] { sessionResults }, groupBy) + .ToDictionary(k => k.Key, v => v.Value.First()); + } + + protected Dictionary>> GetGroupedEventResults(IEnumerable sessionResults, + Func groupBy) where T : struct + { + var resultRows = sessionResults + .SelectMany(result => result.SessionResults + .SelectMany(sessionResult => sessionResult.ResultRows + .Select(resultRow => (result.EventResult, sessionResult, resultRow)))); + + // get the previous result rows for each individual driver + var groupedResultRows = resultRows + .Where(x => groupBy(x.resultRow) is not null) + .GroupBy(x => groupBy(x.resultRow)!.Value); + + // get the previous result rows per event + var groupedEventResults = groupedResultRows + .Select(x => (key: x.Key, results: x + .GroupBy(result => result.EventResult, result => new GroupedSessionResultRow(x.Key, result.sessionResult, result.resultRow)) + .Select(result => new GroupedEventResult(x.Key, result.Key, result)))) + .ToDictionary(k => k.key, v => v.results); + + return groupedEventResults; + } + + public abstract Task Calculate(StandingCalculationData data); + + protected static IComparable GetEventOrderValue(GroupedEventResult eventResult) where T : notnull + => eventResult.SessionResults.Sum(result => result.ResultRow.RacePoints + result.ResultRow.BonusPoints); + + protected StandingRowCalculationResult AccumulateTotalPoints(StandingRowCalculationResult row) + { + row.TotalPoints = row.RacePoints - row.PenaltyPoints; + return row; + } + + protected static StandingRowCalculationResult AccumulateCountedSessionResults(StandingRowCalculationResult standingRow, + IEnumerable> results) + { + if (results.None()) + { + return standingRow; + } + + standingRow.RacePoints += (int)results.Sum(x => x.ResultRow.RacePoints + x.ResultRow.BonusPoints); + standingRow.RacesCounted += results.Count(); + + return standingRow; + } + + protected static StandingRowCalculationResult AccumulateOverallSessionResults(StandingRowCalculationResult standingRow, + IEnumerable> results) + { + if (results.None()) + { + return standingRow; + } + + // accumulate rows + foreach (var resultRow in results) + { + var sessionResult = resultRow.SessionResult; + var row = resultRow.ResultRow; + standingRow.CompletedLaps += (int)row.CompletedLaps; + standingRow.FastestLaps += sessionResult.FastestLapDriverMemberId == standingRow.MemberId ? 1 : 0; + standingRow.Incidents += (int)row.Incidents; + standingRow.LeadLaps += (int)row.LeadLaps; + standingRow.PenaltyPoints += (int)row.PenaltyPoints; + standingRow.PolePositions += (int)row.StartPosition == 1 ? 1 : 0; + standingRow.Top10 += row.FinalPosition <= 10 ? 1 : 0; + standingRow.Top5 += row.FinalPosition <= 5 ? 1 : 0; + standingRow.Top3 += row.FinalPosition <= 3 ? 1 : 0; + standingRow.Wins += row.FinalPosition == 1 ? 1 : 0; + standingRow.Races += 1; + standingRow.RacesScored += row.PointsEligible ? 1 : 0; + standingRow.RacesInPoints += row.RacePoints > 0 ? 1 : 0; + } + + return standingRow; + } + + protected static StandingRowCalculationResult SetScoredResultRows(StandingRowCalculationResult standingRow, IEnumerable> allResults, + IEnumerable> countedResults) + { + standingRow.ResultRows.Clear(); + foreach (var resultRow in allResults) + { + var standingResultRow = resultRow.ResultRow; + standingResultRow.IsScored = countedResults.Contains(resultRow); + standingRow.ResultRows.Add(standingResultRow); + } + return standingRow; + } + + protected static IEnumerable SortStandingRows(IEnumerable rows, Func standingRowSelector, IEnumerable sortOptions) + { + foreach(var sortOption in sortOptions.Reverse()) + { + rows = rows.OrderBy(x => sortOption.GetStandingSortingValue()(standingRowSelector(x))); + } + return rows; + } + + protected static StandingRowCalculationResult DiffStandingRows(StandingRowCalculationResult previous, StandingRowCalculationResult current) + { + if (previous == current) + { + return current; + } + var diff = current; + + diff.CompletedLapsChange = current.CompletedLaps - previous.CompletedLaps; + diff.FastestLapsChange = current.FastestLaps - previous.FastestLaps; + diff.IncidentsChange = current.Incidents - previous.Incidents; + diff.LeadLapsChange = current.LeadLaps - previous.LeadLaps; + diff.PenaltyPointsChange = current.PenaltyPoints - previous.PenaltyPoints; + diff.PolePositionsChange = current.PolePositions - previous.PolePositions; + diff.PositionChange = -(current.Position - previous.Position); + diff.RacePointsChange = current.RacePoints - previous.RacePoints; + diff.TotalPointsChange = current.TotalPoints - previous.TotalPoints; + diff.WinsChange = current.Wins - previous.Wins; + + return diff; + } + + protected record GroupedSessionResultRow(T TeamId, SessionCalculationResult SessionResult, ResultRowCalculationResult ResultRow); + + protected record GroupedEventResult(T TeamId, EventCalculationResult EventResult, IEnumerable> SessionResults); + + protected record EventSessionResults(EventCalculationResult EventResult, IEnumerable SessionResults); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/StandingCalculationServiceProvider.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/StandingCalculationServiceProvider.cs new file mode 100644 index 00000000..c9bfd97b --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/StandingCalculationServiceProvider.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class StandingCalculationServiceProvider : + ICalculationServiceProvider +{ + public ICalculationService GetCalculationService(StandingCalculationConfiguration config) + { + switch (config.ResultKind) + { + case Common.Enums.ResultKind.Member: + return new MemberStandingCalculationService(config); + case Common.Enums.ResultKind.Team: + return new TeamStandingCalculationService(config); + } + return new MemberStandingCalculationService(config); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/TeamSessionCalculationService.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/TeamSessionCalculationService.cs new file mode 100644 index 00000000..8db3f5a8 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/TeamSessionCalculationService.cs @@ -0,0 +1,103 @@ +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class TeamSessionCalculationService : CalculationServiceBase +{ + private readonly SessionCalculationConfiguration config; + + public TeamSessionCalculationService(SessionCalculationConfiguration config) + { + this.config = config; + } + + public override Task Calculate(SessionCalculationData data) + { + var memberRows = data.ResultRows.Select(x => new ResultRowCalculationResult(x)) + .OrderBy(x => x.FinalPosition); + var teamRowGroups = memberRows + .GroupBy(x => x.TeamId) + .Where(x => x.Key != null); + // do not aggregate driver points if all members of all teams have the same race points, usually indicating a team based points value + bool aggregateDriverPoints = teamRowGroups + .Select(x => x.DistinctBy(y => y.RacePoints).Count()) + .Any(x => x > 1); + var teamRows = teamRowGroups + .Select(x => GetTeamResultRow(x, aggregateDriverPoints)) + .NotNull() + .ToList(); + var pointRule = config.PointRule; + var finalRows = ApplyPoints(teamRows, pointRule, data); + + var result = new SessionCalculationResult(data) + { + Name = config.Name, + SessionResultId = config.SessionResultId, + ResultRows = finalRows, + SessionNr = data.SessionNr + }; + + return Task.FromResult(result); + } + + private ResultRowCalculationResult? GetTeamResultRow(IEnumerable teamMemberRows, bool aggregateDriverRows) + { + // 2. Keep two best driver results + teamMemberRows = teamMemberRows.Take(config.MaxResultsPerGroup); + if (teamMemberRows.Any() == false) + { + return null; + } + // 3. Accumulate results + var dataRow = teamMemberRows.First(); + var teamRow = new ResultRowCalculationResult() + { + TeamId = dataRow.TeamId, + TeamColor = dataRow.TeamColor, + TeamName = dataRow.TeamName, + ScoredResultRowId = null, + MemberId = null, + Firstname = string.Empty, + Lastname = string.Empty, + Car = dataRow.Car, + CarClass = dataRow.CarClass, + CarId = dataRow.CarId, + CarNumber = dataRow.CarNumber, + ClassId = dataRow.ClassId, + Status = dataRow.Status, + StartPosition = dataRow.StartPosition, + FinishPosition = dataRow.FinishPosition, + FinalPosition = dataRow.FinalPosition, + AddPenalties = dataRow.AddPenalties, + }; + foreach (var memberRow in teamMemberRows) + { + teamRow.CompletedLaps += memberRow.CompletedLaps; + teamRow.LeadLaps += memberRow.LeadLaps; + teamRow.Incidents += memberRow.Incidents; + teamRow.Interval += memberRow.Interval; + if (aggregateDriverRows) + { + teamRow.RacePoints += memberRow.RacePoints + memberRow.BonusPoints; + } + else + { + teamRow.RacePoints = dataRow.RacePoints + dataRow.BonusPoints; + } + teamRow.PenaltyPoints += memberRow.PenaltyPoints; + teamRow.PointsEligible |= memberRow.PointsEligible; + teamRow.AddPenalties = teamRow.AddPenalties.Concat(memberRow.AddPenalties.Where(x => x.MemberId != null)); + } + teamRow.StartPosition = teamMemberRows.Min(x => x.StartPosition); + (_, teamRow.QualifyingTime) = GetBestLapValue(teamMemberRows, x => x.MemberId, x => x.QualifyingTime); + (_, teamRow.FastestLapTime) = GetBestLapValue(teamMemberRows, x => x.MemberId, x => x.FastestLapTime); + teamRow.AvgLapTime = GetAverageLapValue(teamMemberRows, x => x.AvgLapTime, x => x.CompletedLaps); + teamRow.ScoredMemberResultRowIds = teamMemberRows + .Select(x => x.ScoredResultRowId) + .NotNull() + .ToList(); + + return teamRow; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/TeamStandingCalculationService.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/TeamStandingCalculationService.cs new file mode 100644 index 00000000..d84ca871 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/TeamStandingCalculationService.cs @@ -0,0 +1,109 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class TeamStandingCalculationService : StandingCalculationServiceBase, ICalculationService +{ + public TeamStandingCalculationService(StandingCalculationConfiguration config) : base(config) + { + } + + public override Task Calculate(StandingCalculationData data) + { + var (previousSessionResults, currentSessionResults) = GetPreviousAndCurrentSessionResults(data, config.UseCombinedResult); + + Func keySelector = x => x.TeamId; + var previousTeamEventResults = GetGroupedEventResults(previousSessionResults, keySelector); + var currentTeamEventResult = GetGroupedEventResult(currentSessionResults, keySelector); + + var teamStandingRows = CalculateTeamStandingRows(previousTeamEventResults, currentTeamEventResult); + + // Sort and apply positions standings previous + teamStandingRows = SortStandingRows(teamStandingRows, x => x.Previous, config.SortOptions) + .ToList(); + foreach (var (teamStandingRow, position) in teamStandingRows.Select((x, i) => (x, i + 1))) + { + teamStandingRow.Previous.Position = position; + } + + // Sort and apply positions standings current + teamStandingRows = SortStandingRows(teamStandingRows, x => x.Current, config.SortOptions) + .ToList(); + var finalStandingRows = new List(); + foreach (var (teamStandingRow, position) in teamStandingRows.Select((x, i) => (x, i + 1))) + { + teamStandingRow.Current.Position = position; + var final = DiffStandingRows(teamStandingRow.Previous, teamStandingRow.Current); + finalStandingRows.Add(final); + } + + var standingResult = new StandingCalculationResult() + { + LeagueId = config.LeagueId, + EventId = config.EventId, + Name = config.DisplayName, + SeasonId = config.SeasonId, + StandingConfigId = config.StandingConfigId, + StandingRows = finalStandingRows, + IsTeamStanding = true + }; + return Task.FromResult(standingResult); + } + + private List<(long TeamId, StandingRowCalculationResult Previous, StandingRowCalculationResult Current)> CalculateTeamStandingRows(Dictionary>> previousTeamEventResults, Dictionary> currentTeamEventResult) + { + var teamIds = previousTeamEventResults.Keys.Concat(currentTeamEventResult.Keys).Distinct(); + List<(long TeamId, StandingRowCalculationResult Previous, StandingRowCalculationResult Current)> teamStandingRows = new(); + foreach (var memberId in teamIds) + { + // sort by best race points each event + var previousEventResults = (previousTeamEventResults.GetValueOrDefault(memberId) ?? Array.Empty>()) + .OrderByDescending(GetEventOrderValue); + var currentResult = currentTeamEventResult.GetValueOrDefault(memberId); + var standingRow = new StandingRowCalculationResult(); + var lastResult = currentResult ?? previousEventResults.FirstOrDefault(); + var lastRow = lastResult?.SessionResults.LastOrDefault()?.ResultRow; + if (lastRow is null) + { + continue; + } + // static data + standingRow.MemberId = null; + standingRow.CarClass = lastRow.CarClass; + standingRow.ClassId = lastRow.ClassId; + standingRow.TeamId = lastRow.TeamId; + + // accumulated data + var previousStandingRow = new StandingRowCalculationResult(standingRow); + + var previousResults = previousEventResults.SelectMany(x => x.SessionResults); + var countedEventResults = previousEventResults.Take(config.WeeksCounted); + var countedSessionResults = countedEventResults.SelectMany(x => x.SessionResults); + previousStandingRow = AccumulateOverallSessionResults(previousStandingRow, previousResults); + previousStandingRow = AccumulateCountedSessionResults(previousStandingRow, countedSessionResults); + previousStandingRow = AccumulateTotalPoints(previousStandingRow); + previousStandingRow = SetScoredResultRows(previousStandingRow, previousResults, countedSessionResults); + + if (currentResult is not null) + { + var currentResults = previousEventResults.Concat(new[] { currentResult }) + .OrderByDescending(GetEventOrderValue); + var currentMemberSessionResults = currentResults.SelectMany(x => x.SessionResults); + var currentCountedResults = currentResults.Take(config.WeeksCounted); + var currentCountedSessionResults = currentCountedResults.SelectMany(x => x.SessionResults); + standingRow = AccumulateOverallSessionResults(standingRow, currentMemberSessionResults); + standingRow = AccumulateCountedSessionResults(standingRow, currentCountedSessionResults); + standingRow = AccumulateTotalPoints(standingRow); + standingRow = SetScoredResultRows(standingRow, currentMemberSessionResults, currentCountedSessionResults); + } + else + { + standingRow = previousStandingRow; + } + + teamStandingRows.Add((memberId, previousStandingRow, standingRow)); + } + + return teamStandingRows; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Calculation/UseResultPointsPointRule.cs b/src/iRLeagueApiCore.Services/ResultService/Calculation/UseResultPointsPointRule.cs new file mode 100644 index 00000000..29a6df92 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Calculation/UseResultPointsPointRule.cs @@ -0,0 +1,11 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Calculation; + +internal sealed class UseResultPointsPointRule : CalculationPointRuleBase +{ + public override IReadOnlyList ApplyPoints(SessionCalculationData _, IReadOnlyList rows) + { + return rows; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/DatabaseAccessBase.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/DatabaseAccessBase.cs new file mode 100644 index 00000000..b373f2e9 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/DatabaseAccessBase.cs @@ -0,0 +1,26 @@ +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal abstract class DatabaseAccessBase +{ + protected readonly LeagueDbContext dbContext; + + public DatabaseAccessBase(LeagueDbContext dbContext) + { + this.dbContext = dbContext; + } + + public async Task SetLeague(long eventId, CancellationToken cancellationToken) + { + var @event = await dbContext.Events + .IgnoreQueryFilters() + .FirstOrDefaultAsync(x => x.EventId == eventId, cancellationToken); + if (@event == null) + { + return; + } + dbContext.LeagueProvider.SetLeague(@event.LeagueId); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/EventCalculationConfigurationProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/EventCalculationConfigurationProvider.cs new file mode 100644 index 00000000..eb193b6f --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/EventCalculationConfigurationProvider.cs @@ -0,0 +1,151 @@ +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal sealed class EventCalculationConfigurationProvider : DatabaseAccessBase, IEventCalculationConfigurationProvider +{ + private readonly ISessionCalculationConfigurationProvider sessionConfigurationProvider; + public EventCalculationConfigurationProvider(LeagueDbContext dbContext, + ISessionCalculationConfigurationProvider sessionConfigurationProvider) : + base(dbContext) + { + this.sessionConfigurationProvider = sessionConfigurationProvider; + } + + public async Task> GetResultConfigIds(long eventId, CancellationToken cancellationToken = default) + { + var configs = await dbContext.Events + .Where(x => x.EventId == eventId) + .SelectMany(x => x.ResultConfigs.Select(y => new { y.ResultConfigId, y.SourceResultConfigId })) + .ToListAsync(cancellationToken); + return SortInOrderOfDependency(configs.Select(x => (x.ResultConfigId, x.SourceResultConfigId))); + } + + public async Task GetConfiguration(long eventId, long? resultConfigId, CancellationToken cancellationToken = default) + { + var configEntity = await GetResultConfigurationEntity(resultConfigId, cancellationToken); + var eventEntity = await GetEventEntity(eventId, resultConfigId, cancellationToken); + var champSeasonEntity = await GetChampSeasonEntity(eventEntity, configEntity, cancellationToken); + if (configEntity is not null) + { + configEntity.ChampSeason = champSeasonEntity; + } + var resultConfiguration = await GetEventResultCalculationConfiguration(eventEntity, champSeasonEntity, configEntity, cancellationToken); + return resultConfiguration; + } + + private async Task GetChampSeasonEntity(EventEntity eventEntity, ResultConfigurationEntity? configEntity, CancellationToken cancellationToken) + { + if (configEntity is null) + { + return null; + } + + return await dbContext.ChampSeasons + .Include(x => x.Championship) + .Include(x => x.Filters) + .Where(x => x.SeasonId == eventEntity.Schedule.SeasonId) + .Where(x => x.ResultConfigurations.Contains(configEntity)) + .FirstOrDefaultAsync(cancellationToken); + } + + private async Task GetResultConfigurationEntity(long? resultConfigId, CancellationToken cancellationToken) + { + if (resultConfigId == null) + { + return null; + } + + return await dbContext.ResultConfigurations + .Include(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .ThenInclude(x => x.AutoPenalties) + .Include(x => x.Scorings) + .ThenInclude(x => x.ExtScoringSource) + .Include(x => x.PointFilters) + .Include(x => x.ResultFilters) + .FirstOrDefaultAsync(x => x.ResultConfigId == resultConfigId, cancellationToken) + ?? throw new InvalidOperationException($"No result configuration with id:{resultConfigId} found"); + } + + private async Task GetEventEntity(long eventId, long? resultConfigId, CancellationToken cancellationToken) + { + var events = dbContext.Events + .Include(x => x.Schedule) + .Include(x => x.Sessions); + + if (resultConfigId == null) + { + return await events + .Where(x => x.EventId == eventId) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new InvalidOperationException($"No event id:{eventId} found in database"); + } + + return await events + .Where(x => x.EventId == eventId) + .Where(x => x.ResultConfigs.Any(y => y.ResultConfigId == resultConfigId)) + .FirstOrDefaultAsync(cancellationToken) + ?? throw new InvalidOperationException($"No event id:{eventId} registered with result configuration id:{resultConfigId}"); + } + + private async Task GetEventResultCalculationConfiguration(EventEntity eventEntity, ChampSeasonEntity? champSeason, ResultConfigurationEntity? configEntity, + CancellationToken cancellationToken) + { + EventCalculationConfiguration configuration = new(); + var configId = configEntity?.ResultConfigId; + var championship = champSeason?.Championship; + configuration.EventId = eventEntity.EventId; + configuration.LeagueId = eventEntity.LeagueId; + configuration.ResultId = await dbContext.ScoredEventResults + .Where(x => x.ResultConfigId == configId) + .Where(x => x.EventId == eventEntity.EventId) + .Select(x => x.ResultId) + .FirstOrDefaultAsync(cancellationToken); + configuration.ChampSeasonId = champSeason?.ChampSeasonId; + configuration.ResultConfigId = configId; + configuration.SourceResultConfigId = configEntity?.SourceResultConfigId; + configuration.DisplayName = (string.IsNullOrWhiteSpace(championship?.DisplayName) ? championship?.Name : championship.DisplayName) ?? "Default"; + configuration.SessionResultConfigurations = await sessionConfigurationProvider.GetConfigurations(eventEntity, configEntity, cancellationToken); + return configuration; + } + + private static IReadOnlyList SortInOrderOfDependency(IEnumerable<(long id, long? sourceId)> configs) + { + // Implementation of Kahn's algorithm --> see https://en.wikipedia.org/wiki/Topological_sorting + var sortList = new List(); + if (configs.Any() == false) + { + return sortList; + } + + var source = configs.ToDictionary(k => k.id, v => v.sourceId); + var startNodes = configs.Where(x => x.sourceId is null).ToList(); + if (startNodes.Any() == false || startNodes.Any(x => x.id == x.sourceId)) + { + throw new InvalidOperationException("ResultConfiguration list contains cyclic dependencies"); + } + + while (startNodes.Any()) + { + var node = startNodes.First(); + startNodes.Remove(node); + + sortList.Add(node.id); + foreach (var (id, sourceId) in source.Where(x => x.Value == node.id)) + { + source[id] = null; + startNodes.Add((id, null)); + } + } + + if (source.Values.Any(x => x is not null)) + { + throw new InvalidOperationException("ResultConfiguration list contains cyclic dependencies, or dependencies outside of this event scope"); + } + + return sortList; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/EventCalculationDataProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/EventCalculationDataProvider.cs new file mode 100644 index 00000000..ff572f6c --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/EventCalculationDataProvider.cs @@ -0,0 +1,262 @@ +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using MySqlX.XDevAPI.Relational; +using System.Diagnostics.Eventing.Reader; +using System.Threading; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal sealed class EventCalculationDataProvider : DatabaseAccessBase, IEventCalculationDataProvider +{ + public EventCalculationDataProvider(LeagueDbContext dbContext) : + base(dbContext) + { + } + + public async Task GetData(EventCalculationConfiguration config, CancellationToken cancellationToken = default) + { + var data = await GetDataFromConfiguration(config, cancellationToken); + if (data is null) + { + return data; + } + + data = await AssociatePenalties(config, data, cancellationToken); + // Fill Qualy lap + data = FillQualyLap(config, data); + data = FillFastestLapTimes(data); + return data; + } + + public async Task GetDataFromConfiguration(EventCalculationConfiguration config, CancellationToken cancellationToken = default) + { + if (config.SourceResultConfigId is not null) + { + return await dbContext.ScoredEventResults + .Where(x => x.ResultConfigId == config.SourceResultConfigId) + .Select(ScoredMapToEventResultCalculationDataExpression) + .FirstOrDefaultAsync(x => x.EventId == config.EventId, cancellationToken); + } + + return await dbContext.EventResults + .Select(MapToEventResultCalculationDataExpression) + .FirstOrDefaultAsync(x => x.EventId == config.EventId, cancellationToken); + } + + /// + /// Fill qualy lap time for first race session after qualifying + /// + /// + /// + /// + private static EventCalculationData FillQualyLap(EventCalculationConfiguration config, EventCalculationData data) + { + // find driver qualy laps + var qualySessionNr = config.SessionResultConfigurations.FirstOrDefault(x => x.SessionType == Common.Enums.SessionType.Qualifying)?.SessionNr; + var qualySessionData = data.SessionResults.FirstOrDefault(x => x.SessionNr == qualySessionNr); + if (qualySessionData is null) + { + return data; + } + + // find driver qualy laps + var driverQualyLaps = qualySessionData.ResultRows.Select(x => new { x.MemberId, x.QualifyingTime }); + + // fill qualifying time for all sessions + var firstRaceSessionNr = config.SessionResultConfigurations + .Where(x => x.SessionNr > qualySessionNr) + .Where(x => x.SessionType == Common.Enums.SessionType.Race) + .FirstOrDefault()?.SessionNr; + var firstRaceSession = data.SessionResults.FirstOrDefault(x => x.SessionNr == firstRaceSessionNr); + if (firstRaceSession is null) + { + return data; + } + + foreach(var row in firstRaceSession.ResultRows) + { + row.QualifyingTime = driverQualyLaps.FirstOrDefault(x => x.MemberId == row.MemberId)?.QualifyingTime ?? TimeSpan.Zero; + } + + return data; + } + + private EventCalculationData FillFastestLapTimes(EventCalculationData data) + { + foreach (var sessionResult in data.SessionResults) + { + sessionResult.FastestLap = sessionResult.ResultRows + .Select(x => x.FastestLapTime) + .Where(LapIsValid) + .OrderBy(x => x) + .FirstOrDefault(); + sessionResult.FastestQualyLap = sessionResult.ResultRows + .Select(x => x.QualifyingTime) + .Where(LapIsValid) + .OrderBy(x => x) + .FirstOrDefault(); + sessionResult.FastestAvgLap = sessionResult.ResultRows + .Select(x => x.AvgLapTime) + .Where(LapIsValid) + .OrderBy(x => x) + .FirstOrDefault(); + } + return data; + } + + private async Task AssociatePenalties(EventCalculationConfiguration config, EventCalculationData data, CancellationToken cancellationToken) + { + // get existing scoredresultrows + var scoredResultRows = await dbContext.ScoredResultRows + .Include(x => x.ScoredSessionResult) + .Include(x => x.AddPenalties) + .Where(x => x.ScoredSessionResult.ResultId == config.ResultId) + .ToListAsync(cancellationToken); + if (scoredResultRows.None()) + { + return data; + } + + data.AddPenalties = scoredResultRows + .SelectMany(row => row.AddPenalties + .Select(x => new AddPenaltyCalculationData() + { + SessionNr = row.ScoredSessionResult.SessionNr, + MemberId = row.MemberId, + TeamId = row.TeamId, + Type = x.Value.Type, + Points = x.Value.Points, + Positions = x.Value.Positions, + Time = x.Value.Time, + })); + return data; + } + + private static bool LapIsValid(TimeSpan lap) + { + return lap > TimeSpan.Zero; + } + + private static Expression> MapToEventResultCalculationDataExpression => eventResult => new EventCalculationData() + { + LeagueId = eventResult.LeagueId, + EventId = eventResult.EventId, + SessionResults = eventResult.SessionResults + .Select(sessionResult => new SessionCalculationData() + { + LeagueId = sessionResult.LeagueId, + SessionId = sessionResult.SessionId, + SessionNr = sessionResult.Session.SessionNr, + AcceptedReviewVotes = sessionResult.Session.IncidentReviews + .SelectMany(review => review.AcceptedReviewVotes) + .Select(vote => new AcceptedReviewVoteCalculationData() + { + DefaultPenalty = vote.VoteCategory == null ? 0 : vote.VoteCategory.DefaultPenalty, + MemberAtFaultId = vote.MemberAtFaultId, + TeamAtFaultId = vote.TeamAtFaultId, + ReviewId = vote.ReviewId, + VoteCategoryId = vote.VoteCategoryId, + ReviewVoteId = vote.ReviewVoteId, + }), + Sof = sessionResult.IRSimSessionDetails == null ? 0 : sessionResult.IRSimSessionDetails.EventStrengthOfField, + ResultRows = sessionResult.ResultRows.Select(row => new ResultRowCalculationData() + { + ScoredResultRowId = null, + MemberId = row.MemberId, + Firstname = row.Member == null ? string.Empty : row.Member.Firstname, + Lastname = row.Member == null ? string.Empty : row.Member.Lastname, + TeamId = row.TeamId, + TeamName = row.Team == null ? string.Empty : row.Team.Name, + AvgLapTime = row.AvgLapTime, + Car = row.Car, + CarClass = row.CarClass, + CarId = row.CarId, + CarNumber = row.CarNumber, + ClassId = row.ClassId, + ClubId = row.ClubId, + ClubName = row.ClubName, + CompletedLaps = row.CompletedLaps, + CompletedPct = row.CompletedPct, + FastestLapTime = row.FastestLapTime, + FastLapNr = row.FastLapNr, + FinishPosition = row.FinishPosition, + Division = row.Division, + Incidents = row.Incidents, + Interval = row.Interval, + LeadLaps = row.LeadLaps, + License = row.License, + NewIrating = row.NewIRating, + NewCpi = row.NewCpi, + NewLicenseLevel = row.NewLicenseLevel, + NewSafetyRating = row.NewSafetyRating, + OldIrating = row.OldIRating, + OldCpi = row.OldCpi, + OldLicenseLevel = row.OldLicenseLevel, + OldSafetyRating = row.OldSafetyRating, + QualifyingTime = row.QualifyingTime, + PositionChange = row.PositionChange, + RacePoints = row.RacePoints, + SeasonStartIrating = row.SeasonStartIRating, + StartPosition = row.StartPosition, + Status = row.Status, + TotalPoints = row.RacePoints, + PointsEligible = row.PointsEligible, + }) + }) + }; + + private static Expression> ScoredMapToEventResultCalculationDataExpression => eventResult => new EventCalculationData() + { + LeagueId = eventResult.LeagueId, + EventId = eventResult.EventId, + SessionResults = eventResult.ScoredSessionResults.Select(sessionResult => new SessionCalculationData() + { + LeagueId = sessionResult.LeagueId, + SessionNr = sessionResult.SessionNr, + ResultRows = sessionResult.ScoredResultRows.Select(row => new ResultRowCalculationData() + { + ScoredResultRowId = row.ScoredResultRowId, + MemberId = row.MemberId, + Firstname = row.Member == null ? string.Empty : row.Member.Firstname, + Lastname = row.Member == null ? string.Empty : row.Member.Lastname, + TeamId = row.TeamId, + TeamName = row.Team == null ? string.Empty : row.Team.Name, + AvgLapTime = row.AvgLapTime, + Car = row.Car, + CarClass = row.CarClass, + CarId = row.CarId, + CarNumber = row.CarNumber, + ClassId = row.ClassId, + CompletedLaps = row.CompletedLaps, + CompletedPct = row.CompletedPct, + FastestLapTime = row.FastestLapTime, + FastLapNr = row.FastLapNr, + FinishPosition = row.FinishPosition, + Division = row.Division, + Incidents = row.Incidents, + Interval = row.Interval, + LeadLaps = row.LeadLaps, + License = row.License, + NewIrating = row.NewIRating, + NewLicenseLevel = row.NewLicenseLevel, + NewSafetyRating = row.NewSafetyRating, + OldIrating = row.OldIRating, + OldLicenseLevel = row.OldLicenseLevel, + OldSafetyRating = row.OldSafetyRating, + QualifyingTime = row.QualifyingTime, + PositionChange = row.PositionChange, + RacePoints = row.RacePoints, + BonusPoints = row.BonusPoints, + PenaltyPoints = row.PenaltyPoints, + SeasonStartIrating = row.SeasonStartIRating, + StartPosition = row.StartPosition, + Status = row.Status, + TotalPoints = row.RacePoints, + PointsEligible = row.PointsEligible, + }) + }) + }; +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/EventCalculationResultStore.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/EventCalculationResultStore.cs new file mode 100644 index 00000000..b2e548a0 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/EventCalculationResultStore.cs @@ -0,0 +1,303 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal sealed class EventCalculationResultStore : DatabaseAccessBase, IEventCalculationResultStore +{ + public EventCalculationResultStore(LeagueDbContext dbContext) : + base(dbContext) + { + } + + public async Task StoreCalculationResult(EventCalculationResult result, CancellationToken cancellationToken = default) + { + var eventResultEntity = await GetScoredEventResultEntity(result.EventId, result.ResultConfigId, cancellationToken); + if (eventResultEntity == null) + { + eventResultEntity = await CreateScoredResultEntity(result.EventId, result.ResultConfigId, cancellationToken); + dbContext.ScoredEventResults.Add(eventResultEntity); + } + var requiredEntities = await GetRequiredEntities(result, cancellationToken); + await MapToEventResultEntity(result, eventResultEntity, requiredEntities, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + return; + } + + private async Task MapToEventResultEntity(EventCalculationResult result, ScoredEventResultEntity entity, + RequiredEntities requiredEntities, CancellationToken cancellationToken) + { + var members = await GetMemberEntities(result.SessionResults + .SelectMany(x => x.ResultRows) + .Select(x => x.MemberId) + .OfType(), cancellationToken); + var teams = await GetTeamEntities(result.SessionResults + .SelectMany(x => x.ResultRows) + .Select(x => x.TeamId) + .OfType(), cancellationToken); + entity.Name = result.Name; + entity.ChampSeason = await dbContext.ChampSeasons + .FirstOrDefaultAsync(x => x.ChampSeasonId == result.ChampSeasonId); + entity.ScoredSessionResults = await MapToScoredSessionResults(result.SessionResults, entity.ScoredSessionResults, + requiredEntities, cancellationToken); + + return entity; + } + + private async Task> MapToScoredSessionResults(IEnumerable sessionResults, + ICollection sessionResultEntities, RequiredEntities requiredEntities, CancellationToken cancellationToken) + { + var keepResults = new List(); + foreach (var sessionResult in sessionResults) + { + var sessionResultEntity = sessionResultEntities + .Where(x => x.SessionResultId != 0) + .FirstOrDefault(x => x.SessionNr == sessionResult.SessionNr); + if (sessionResultEntity == null) + { + sessionResultEntity = await CreateScoredSessionResultEntity(sessionResult.ScoringId, cancellationToken); + sessionResultEntities.Add(sessionResultEntity); + } + sessionResultEntity = MapToScoredSessionResultEntity(sessionResult, sessionResultEntity, requiredEntities); + keepResults.Add(sessionResultEntity); + } + foreach (var removeResult in sessionResultEntities.Except(keepResults).ToList()) + { + sessionResultEntities.Remove(removeResult); + } + return sessionResultEntities; + } + + private ScoredSessionResultEntity MapToScoredSessionResultEntity(SessionCalculationResult result, ScoredSessionResultEntity entity, + RequiredEntities requiredEntities) + { + entity.Name = result.Name; + entity.SessionNr = result.SessionNr ?? 0; + entity.CleanestDrivers = requiredEntities.Members.Where(x => result.CleanestDrivers.Contains(x.Id)).ToList(); + entity.FastestAvgLap = result.FastestAvgLap; + entity.FastestAvgLapDriver = requiredEntities.Members.FirstOrDefault(x => x.Id == result.FastestQualyLapDriverMemberId); + entity.FastestLap = result.FastestLap; + entity.FastestLapDriver = requiredEntities.Members.FirstOrDefault(x => x.Id == result.FastestLapDriverMemberId); + entity.FastestQualyLap = result.FastestQualyLap; + entity.FastestQualyLapDriver = requiredEntities.Members.FirstOrDefault(x => x.Id == result.FastestQualyLapDriverMemberId); + entity.HardChargers = requiredEntities.Members.Where(x => result.HardChargers.Contains(x.Id)).ToList(); + entity.ScoredResultRows = MapToScoredResultRows(result.ResultRows, entity.ScoredResultRows, requiredEntities); + + return entity; + } + + private ICollection MapToScoredResultRows(IEnumerable resultRows, + ICollection rowEntities, RequiredEntities requiredEntities) + { + var keepRows = new List(); + foreach (var row in resultRows) + { + ScoredResultRowEntity? rowEntity = default; + if (row.MemberId != null) + { + rowEntity = rowEntities + .FirstOrDefault(x => x.MemberId == row.MemberId); + } + else if (row.TeamId != null) + { + rowEntity = rowEntities + .FirstOrDefault(x => x.TeamId == row.TeamId); + } + if (rowEntity == null) + { + rowEntity = new ScoredResultRowEntity(); + rowEntities.Add(rowEntity); + } + rowEntity = MaptoScoredResultRow(row, rowEntity, requiredEntities); + keepRows.Add(rowEntity); + } + foreach (var removeRows in rowEntities.Except(keepRows).ToList()) + { + rowEntities.Remove(removeRows); + } + return rowEntities; + } + + private ScoredResultRowEntity MaptoScoredResultRow(ResultRowCalculationResult row, ScoredResultRowEntity rowEntity, + RequiredEntities requiredEntities) + { + rowEntity.Member = requiredEntities.Members.FirstOrDefault(x => x.Id == row.MemberId); + rowEntity.Team = requiredEntities.Teams.FirstOrDefault(x => x.TeamId == row.TeamId); + rowEntity.AvgLapTime = row.AvgLapTime; + rowEntity.BonusPoints = row.BonusPoints; + rowEntity.Car = row.Car; + rowEntity.CarClass = row.CarClass; + rowEntity.CarId = row.CarId; + rowEntity.CarNumber = row.CarNumber; + rowEntity.ClassId = row.ClassId; + rowEntity.ClubId = row.ClubId; + rowEntity.ClubName = row.ClubName; + rowEntity.CompletedLaps = row.CompletedLaps; + rowEntity.CompletedPct = row.CompletedPct; + rowEntity.Division = row.Division; + rowEntity.FastestLapTime = row.FastestLapTime; + rowEntity.FastLapNr = row.FastLapNr; + rowEntity.FinalPosition = row.FinalPosition; + rowEntity.FinalPositionChange = row.FinalPositionChange; + rowEntity.FinishPosition = row.FinishPosition; + rowEntity.Incidents = row.Incidents; + rowEntity.Interval = row.Interval; + rowEntity.LeadLaps = row.LeadLaps; + rowEntity.License = row.License; + rowEntity.NewCpi = row.NewCpi; + rowEntity.NewIRating = row.NewIrating; + rowEntity.NewLicenseLevel = row.NewLicenseLevel; + rowEntity.NewSafetyRating = row.NewSafetyRating; + rowEntity.OldCpi = row.OldCpi; + rowEntity.OldIRating = row.OldIrating; + rowEntity.OldLicenseLevel = row.OldLicenseLevel; + rowEntity.OldSafetyRating = row.OldSafetyRating; + rowEntity.PenaltyPoints = row.PenaltyPoints; + rowEntity.PointsEligible = row.PointsEligible; + rowEntity.PositionChange = row.PositionChange; + rowEntity.QualifyingTime = row.QualifyingTime; + rowEntity.RacePoints = row.RacePoints; + rowEntity.ReviewPenalties = MapToReviewPenaltyList(row, rowEntity.ReviewPenalties, requiredEntities); + rowEntity.SeasonStartIRating = row.SeasonStartIrating; + rowEntity.StartPosition = row.StartPosition; + rowEntity.Status = row.Status; + rowEntity.TotalPoints = row.TotalPoints; + rowEntity.TeamResultRows = requiredEntities.ScoredResultRows + .Where(x => row.ScoredMemberResultRowIds.Contains(x.ScoredResultRowId)).ToList(); + return rowEntity; + } + + private ICollection MapToReviewPenaltyList(ResultRowCalculationResult row, ICollection penaltyEntities, + RequiredEntities requiredEntities) + { + foreach (var penalty in row.ReviewPenalties) + { + var penaltyEntity = penaltyEntities + .Where(x => x.ReviewVoteId == penalty.ReviewVoteId) + .FirstOrDefault(); + if (penaltyEntity is null) + { + var review = requiredEntities.Reviews + .FirstOrDefault(x => x.ReviewId == penalty.ReviewId); + var vote = review?.AcceptedReviewVotes + .FirstOrDefault(x => x.ReviewVoteId == penalty.ReviewVoteId); + if (review is null || vote is null) + { + continue; + } + penaltyEntity = new ReviewPenaltyEntity() + { + LeagueId = review.LeagueId, + Review = review, + ReviewVote = vote, + Value = new(), + }; + penaltyEntities.Add(penaltyEntity); + } + penaltyEntity.Value.Type = PenaltyType.Points; + penaltyEntity.Value.Points = penalty.PenaltyPoints; + } + return penaltyEntities; + } + + private async Task CreateScoredSessionResultEntity(long? scoringId, CancellationToken cancellationToken) + { + var scoring = await dbContext.Scorings + .FirstOrDefaultAsync(x => x.ScoringId == scoringId, cancellationToken); + var sessionResult = new ScoredSessionResultEntity() + { + Scoring = scoring, + }; + return sessionResult; + } + + private async Task CreateScoredResultEntity(long eventId, long? resultConfigId, CancellationToken cancellationToken) + { + var @event = await dbContext.Events + .FirstOrDefaultAsync(x => x.EventId == eventId, cancellationToken) + ?? throw new InvalidOperationException($"No event with id:{eventId} exists"); + var resultConfig = await dbContext.ResultConfigurations + .FirstOrDefaultAsync(x => x.ResultConfigId == resultConfigId, cancellationToken); + var eventResult = new ScoredEventResultEntity() + { + Event = @event, + ResultConfig = resultConfig, + }; + return eventResult; + } + + private async Task GetScoredEventResultEntity(long eventId, long? resultConfigId, CancellationToken cancellationToken) + { + return await dbContext.ScoredEventResults + .Include(x => x.ScoredSessionResults) + .ThenInclude(x => x.ScoredResultRows) + .ThenInclude(x => x.Member) + .Include(x => x.ScoredSessionResults) + .ThenInclude(x => x.ScoredResultRows) + .ThenInclude(x => x.TeamResultRows) + .Include(x => x.ScoredSessionResults) + .ThenInclude(x => x.ScoredResultRows) + .ThenInclude(x => x.ReviewPenalties) + .Include(x => x.ScoredSessionResults) + .ThenInclude(x => x.HardChargers) + .Include(x => x.ScoredSessionResults) + .ThenInclude(x => x.CleanestDrivers) + .Where(x => x.EventId == eventId) + .Where(x => x.ResultConfigId == resultConfigId) + .FirstOrDefaultAsync(cancellationToken); + } + + private async Task GetRequiredEntities(EventCalculationResult result, CancellationToken cancellationToken) + { + RequiredEntities requiredEntities = new(); + requiredEntities.Members = await GetMemberEntities(result.SessionResults + .SelectMany(x => x.ResultRows) + .Select(x => x.MemberId) + .NotNull(), cancellationToken); + requiredEntities.Teams = await GetTeamEntities(result.SessionResults + .SelectMany(x => x.ResultRows) + .Select(x => x.TeamId) + .NotNull(), cancellationToken); + requiredEntities.ScoredResultRows = await GetScoredResultRowEntities(result.SessionResults + .SelectMany(x => x.ResultRows) + .SelectMany(x => x.ScoredMemberResultRowIds), cancellationToken); + requiredEntities.Reviews = await GetReviewEntities(result.SessionResults + .SelectMany(x => x.ResultRows) + .SelectMany(x => x.ReviewPenalties) + .Select(x => (x.ReviewId)) + .NotNull(), cancellationToken); + return requiredEntities; + } + + private async Task> GetReviewEntities(IEnumerable reviewIds, CancellationToken cancellationToken) + { + return await dbContext.IncidentReviews + .Include(x => x.AcceptedReviewVotes) + .Where(x => reviewIds.Contains(x.ReviewId)) + .ToListAsync(cancellationToken); + } + + private async Task> GetMemberEntities(IEnumerable memberIds, CancellationToken cancellationToken) + { + return await dbContext.Members + .Where(x => memberIds.Contains(x.Id)) + .ToListAsync(cancellationToken); + } + + private async Task> GetTeamEntities(IEnumerable teamIds, CancellationToken cancellationToken) + { + return await dbContext.Teams + .Where(x => teamIds.Contains(x.TeamId)) + .ToListAsync(cancellationToken); + } + + private async Task> GetScoredResultRowEntities(IEnumerable ids, CancellationToken cancellationToken) + { + return await dbContext.ScoredResultRows + .Where(x => ids.Contains(x.ScoredResultRowId)) + .ToListAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/IEventCalculationConfigurationProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IEventCalculationConfigurationProvider.cs new file mode 100644 index 00000000..0aa53189 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IEventCalculationConfigurationProvider.cs @@ -0,0 +1,9 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal interface IEventCalculationConfigurationProvider +{ + public Task> GetResultConfigIds(long eventId, CancellationToken cancellationToken = default); + public Task GetConfiguration(long eventId, long? resultConfigId, CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/IEventCalculationDataProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IEventCalculationDataProvider.cs new file mode 100644 index 00000000..68405746 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IEventCalculationDataProvider.cs @@ -0,0 +1,9 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal interface IEventCalculationDataProvider +{ + public Task SetLeague(long eventId, CancellationToken cancellationToken); + public Task GetData(EventCalculationConfiguration config, CancellationToken cancellationToken); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/IEventCalculationResultStore.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IEventCalculationResultStore.cs new file mode 100644 index 00000000..6858d3b5 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IEventCalculationResultStore.cs @@ -0,0 +1,8 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal interface IEventCalculationResultStore +{ + public Task StoreCalculationResult(EventCalculationResult result, CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/ISessionCalculationConfigurationProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/ISessionCalculationConfigurationProvider.cs new file mode 100644 index 00000000..a8ccbc96 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/ISessionCalculationConfigurationProvider.cs @@ -0,0 +1,10 @@ +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal interface ISessionCalculationConfigurationProvider +{ + public Task> GetConfigurations(EventEntity eventEntity, + ResultConfigurationEntity? configurationEntity, CancellationToken cancellationToken); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/IStandingCalculationConfigurationProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IStandingCalculationConfigurationProvider.cs new file mode 100644 index 00000000..29777ecf --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IStandingCalculationConfigurationProvider.cs @@ -0,0 +1,10 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal interface IStandingCalculationConfigurationProvider +{ + public Task GetSeasonId(long eventId, CancellationToken cancellationToken); + public Task> GetStandingConfigIds(long seasonId, CancellationToken cancellationToken = default); + public Task GetConfiguration(long seasonId, long? eventId, long? resultConfigId, CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/IStandingCalculationDataProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IStandingCalculationDataProvider.cs new file mode 100644 index 00000000..3d02698e --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IStandingCalculationDataProvider.cs @@ -0,0 +1,9 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal interface IStandingCalculationDataProvider +{ + public Task SetLeague(long eventId, CancellationToken cancellationToken); + public Task GetData(StandingCalculationConfiguration config, CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/IStandingCalculationResultStore.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IStandingCalculationResultStore.cs new file mode 100644 index 00000000..24422027 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/IStandingCalculationResultStore.cs @@ -0,0 +1,9 @@ +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal interface IStandingCalculationResultStore +{ + public Task StoreCalculationResult(StandingCalculationResult result, CancellationToken cancellationToken = default); + public Task ClearStaleStandings(IEnumerable StandingConfigIds, long eventId, CancellationToken cancellationToken = default); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/RequiredEntities.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/RequiredEntities.cs new file mode 100644 index 00000000..e8fe6c57 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/RequiredEntities.cs @@ -0,0 +1,13 @@ +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +// TODO: find better name for this class +internal sealed class RequiredEntities +{ + public ICollection Members { get; set; } = Array.Empty(); + public ICollection Teams { get; set; } = Array.Empty(); + public ICollection ScoredResultRows { get; set; } = Array.Empty(); + public ICollection AddPenalties { get; set; } = Array.Empty(); + public ICollection Reviews { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/SessionCalculationConfigurationProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/SessionCalculationConfigurationProvider.cs new file mode 100644 index 00000000..8b10797b --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/SessionCalculationConfigurationProvider.cs @@ -0,0 +1,253 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal sealed class SessionCalculationConfigurationProvider : DatabaseAccessBase, ISessionCalculationConfigurationProvider +{ + public SessionCalculationConfigurationProvider(LeagueDbContext dbContext) : base(dbContext) + { + } + + public async Task> GetConfigurations(EventEntity eventEntity, + ResultConfigurationEntity? configurationEntity, CancellationToken cancellationToken = default) + { + if (configurationEntity == null) + { + return await DefaultSessionResultCalculationConfigurations(eventEntity, configurationEntity, cancellationToken); + } + + return await GetSessionConfigurationsFromEntity(eventEntity, configurationEntity, cancellationToken); + } + + private async Task> DefaultSessionResultCalculationConfigurations(EventEntity eventEntity, + ResultConfigurationEntity? configurationEntity, CancellationToken cancellationToken) + { + var configId = configurationEntity?.ResultConfigId; + var sessionResultIds = await dbContext.ScoredSessionResults + .Where(x => x.ScoredEventResult.EventId == eventEntity.EventId) + .Where(x => x.ScoredEventResult.ResultConfigId == configId) + .OrderBy(x => x.SessionNr) + .Select(x => x.SessionResultId) + .ToListAsync(cancellationToken); + + var configurations = eventEntity.Sessions + .OrderBy(x => x.SessionNr) + .Select((x, i) => new SessionCalculationConfiguration() + { + LeagueId = x.LeagueId, + ScoringId = null, + SessionResultId = sessionResultIds.ElementAtOrDefault(i), + SessionId = x.SessionId, + SessionNr = x.SessionNr, + UseResultSetTeam = false, + MaxResultsPerGroup = (configurationEntity?.ResultsPerTeam is null or <= 0) ? int.MaxValue : configurationEntity.ResultsPerTeam, + Name = x.Name, + UpdateTeamOnRecalculation = false, + ResultKind = configurationEntity?.ChampSeason.ResultKind ?? ResultKind.Member, + }); + return configurations; + } + + private async Task> GetSessionConfigurationsFromEntity(EventEntity eventEntity, + ResultConfigurationEntity configurationEntity, CancellationToken cancellationToken) + { + var sessionResultIds = await dbContext.ScoredSessionResults + .Where(x => x.ScoredEventResult.EventId == eventEntity.EventId) + .Where(x => x.ScoredEventResult.ResultConfigId == configurationEntity.ResultConfigId) + .OrderBy(x => x.SessionNr) + .Select(x => x.SessionResultId) + .ToListAsync(cancellationToken); + + var scorings = configurationEntity.Scorings + .Where(x => x.IsCombinedResult == false) + .OrderBy(x => x.Index); + var raceIndex = scorings.Count() - eventEntity.Sessions.Count(x => x.SessionType == SessionType.Race); + var sessionConfigurations = new List(); + foreach ((var session, var index) in eventEntity.Sessions + .OrderBy(x => x.SessionNr) + .Select((x, i) => (x, i))) + { + var scoring = session.SessionType != SessionType.Race ? null : scorings.ElementAtOrDefault(raceIndex++); + var sessionConfiguration = new SessionCalculationConfiguration + { + LeagueId = session.LeagueId, + Name = session.Name, + SessionId = session.SessionId, + SessionNr = session.SessionNr, + ResultKind = configurationEntity.ChampSeason?.ResultKind ?? ResultKind.Member, + SessionType = session.SessionType, + SessionResultId = sessionResultIds.ElementAtOrDefault(index) + }; + sessionConfiguration = MapFromScoringEntity(scoring, configurationEntity, sessionConfiguration); + sessionConfigurations.Add(sessionConfiguration); + } + var combinedScoring = configurationEntity.Scorings.FirstOrDefault(x => x.IsCombinedResult); + if (combinedScoring != null) + { + var sessionConfiguration = new SessionCalculationConfiguration + { + LeagueId = configurationEntity.LeagueId, + Name = combinedScoring.Name, + SessionId = null, + SessionNr = 999, + ResultKind = configurationEntity.ChampSeason?.ResultKind ?? ResultKind.Member, + IsCombinedResult = true, + UseExternalSourcePoints = combinedScoring.UseExternalSourcePoints, + SessionType = SessionType.Race, + SessionResultId = null, + }; + sessionConfiguration = MapFromScoringEntity(combinedScoring, configurationEntity, sessionConfiguration, includePointFilters: false); + sessionConfigurations.Add(sessionConfiguration); + } + return sessionConfigurations; + } + + private static SessionCalculationConfiguration MapFromScoringEntity(ScoringEntity? scoring, ResultConfigurationEntity configurationEntity, + SessionCalculationConfiguration sessionConfiguration, bool includePointFilters = true) + { + sessionConfiguration.PointRule = GetPointRuleFromEntity(scoring?.PointsRule, configurationEntity, includePointFilters: includePointFilters); + sessionConfiguration.MaxResultsPerGroup = (configurationEntity.ResultsPerTeam <= 0) ? int.MaxValue : configurationEntity.ResultsPerTeam; + sessionConfiguration.UseResultSetTeam = scoring?.UseResultSetTeam ?? false; + sessionConfiguration.UpdateTeamOnRecalculation = scoring?.UpdateTeamOnRecalculation ?? false; + sessionConfiguration.ScoringId = scoring?.ScoringId; + + return sessionConfiguration; + } + + private static PointRule GetPointRuleFromEntity(PointRuleEntity? pointsRuleEntity, ResultConfigurationEntity configurationEntity, + bool includePointFilters = true) + { + CalculationPointRuleBase pointRule; + + pointRule = pointsRuleEntity switch + { + var rule when rule?.RuleType == PointRuleType.PointList && rule.PointsPerPlace.Any() => new PerPlacePointRule(PointsPerPlaceToDictionary(rule.PointsPerPlace.Select(x => (double)x))), + var rule when rule?.RuleType == PointRuleType.MaxPointsDropOff && rule.MaxPoints > 0 => new MaxPointRule(rule.MaxPoints, rule.PointDropOff), + var rule when rule?.RuleType == PointRuleType.Formula && string.IsNullOrEmpty(rule.Formula) == false => new FormulaPointRule(rule.Formula, false), + _ => new UseResultPointsPointRule() + }; + + pointRule.PointSortOptions = pointsRuleEntity?.PointsSortOptions ?? Array.Empty(); + pointRule.FinalSortOptions = pointsRuleEntity?.FinalSortOptions ?? Array.Empty(); + pointRule.BonusPoints = (pointsRuleEntity?.BonusPoints.Select(MapFromBonusPointModel) ?? Array.Empty()).ToList(); + pointRule.ResultFilters = MapFromFilterEntities(configurationEntity.ResultFilters); + pointRule.ChampSeasonFilters = configurationEntity.ChampSeason != null ? MapFromFilterEntities(configurationEntity.ChampSeason.Filters) : new(); + pointRule.AutoPenalties = (pointsRuleEntity?.AutoPenalties.Select(MapFromAutoPenaltyConfig) ?? Array.Empty()).ToList(); + if (includePointFilters) + { + pointRule.PointFilters = MapFromFilterEntities(configurationEntity.PointFilters); + } + else + { + pointRule.PointFilters = CreatePointsEligibleFilter(); + } + + // Add normal status filter for Disqualified drivers, when status is not explicitly filtered already. + var hasStatusPointFilter = configurationEntity.PointFilters.Any(x => x.Conditions.Any(y => y.ColumnPropertyName == nameof(ResultRowCalculationResult.Status))); + if (hasStatusPointFilter == false) + { + var statusFilter = (FilterCombination.And, new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.Status), + ComparatorType.IsEqual, + new[] { ((int)RaceStatus.Disqualified).ToString() }, + MatchedValueAction.Remove) as RowFilter); + pointRule.PointFilters = new FilterGroupRowFilter( + pointRule.PointFilters.GetFilters().Concat(new[] { statusFilter })); + } + + return pointRule; + } + + private static BonusPointConfiguration MapFromBonusPointModel(BonusPointModel bonusPoint) + { + var bonusPointConfig = new BonusPointConfiguration() + { + Type = bonusPoint.Type, + Value = (int)bonusPoint.Value, + Points = (int)bonusPoint.Points, + Conditions = MapFromFilterEntities(bonusPoint.Conditions, allowForEach: true, overrideFilterCombination: FilterCombination.And), + }; + return bonusPointConfig; + } + + private static AutoPenaltyConfigurationData MapFromAutoPenaltyConfig(AutoPenaltyConfigEntity penaltyEntity) + { + var penaltyData = new AutoPenaltyConfigurationData + { + Conditions = MapFromFilterEntities(penaltyEntity.Conditions, allowForEach: true, overrideFilterCombination: FilterCombination.And), + Description = penaltyEntity.Description, + Points = penaltyEntity.Points, + Positions = penaltyEntity.Positions, + Time = penaltyEntity.Time, + Type = penaltyEntity.Type + }; + return penaltyData; + } + + private static FilterGroupRowFilter CreatePointsEligibleFilter() => new( + new (FilterCombination, RowFilter)[] { + (FilterCombination.And, new ColumnValueRowFilter(nameof(ResultRowCalculationResult.PointsEligible), ComparatorType.IsEqual, + new[] { true.ToString() }, MatchedValueAction.Keep)) + } + ); + + private static FilterGroupRowFilter MapFromFilterEntities(ICollection pointFilters, + bool allowForEach = false, FilterCombination? overrideFilterCombination = null) + { + return MapToFilterGroup(pointFilters, allowForEach: allowForEach, overrideFilterCombination: overrideFilterCombination); + } + + private static FilterGroupRowFilter MapFromFilterEntities(ICollection pointFilters) + { + return MapToFilterGroup(pointFilters.Select(x => x.Conditions.FirstOrDefault())); + } + + private static IReadOnlyDictionary PointsPerPlaceToDictionary(IEnumerable points) + { + return points + .Select((x, i) => new { pos = i + 1, value = x }) + .ToDictionary(k => k.pos, v => v.value); + } + + private static FilterCombination GetFilterCombination(FilterConditionModel? condition, int index) + { + if (index == 0 || condition is null) + { + return FilterCombination.And; + } + return condition.Action switch + { + MatchedValueAction.Remove => FilterCombination.And, + MatchedValueAction.Keep => FilterCombination.Or, + _ => FilterCombination.And, + }; + } + + private static FilterGroupRowFilter MapToFilterGroup(IEnumerable filters, + bool allowForEach = false, FilterCombination? overrideFilterCombination = null) + { + var filterCombination = filters + .Select((x, i) => (overrideFilterCombination ?? GetFilterCombination(x, i), GetRowFilterFromCondition(x, allowForEach: allowForEach))) + .Where(x => x.Item2 is not null); + return new(filterCombination!); + } + + private static RowFilter? GetRowFilterFromCondition(FilterConditionModel? condition, + bool allowForEach = false) + { + return condition?.FilterType switch + { + FilterType.ColumnProperty => new ColumnValueRowFilter(condition.ColumnPropertyName, condition.Comparator, + condition.FilterValues, condition.Action, allowForEach: allowForEach), + FilterType.Member => new IdRowFilter(condition.FilterValues, x => x.MemberId.GetValueOrDefault(), condition.Action), + FilterType.Team => new IdRowFilter(condition.FilterValues, x => x.TeamId.GetValueOrDefault(), condition.Action), + _ => null, + }; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/StandingCalculationConfigurationProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/StandingCalculationConfigurationProvider.cs new file mode 100644 index 00000000..4a1e08c6 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/StandingCalculationConfigurationProvider.cs @@ -0,0 +1,120 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal sealed class StandingCalculationConfigurationProvider : DatabaseAccessBase, IStandingCalculationConfigurationProvider +{ + public StandingCalculationConfigurationProvider(LeagueDbContext dbContext) : base(dbContext) + { + } + + public async Task GetSeasonId(long eventId, CancellationToken cancellationToken) + { + return await dbContext.Events + .Where(x => x.EventId == eventId) + .Select(x => x.Schedule.SeasonId) + .FirstOrDefaultAsync(cancellationToken); + } + + public async Task> GetStandingConfigIds(long seasonId, CancellationToken cancellationToken = default) + { + var configIds = await dbContext.ChampSeasons + .Where(x => x.SeasonId == seasonId) + .Where(x => x.StandingConfigId != null) + .Where(x => x.IsActive) + .Select(x => x.StandingConfigId.GetValueOrDefault()) + .Distinct() + .ToListAsync(cancellationToken); + return configIds; + } + + public async Task GetConfiguration(long seasonId, long? eventId, long? standingConfigId, CancellationToken cancellationToken = default) + { + var season = await GetSeasonEntityAsync(seasonId, cancellationToken) + ?? throw new ArgumentException($"No season with id {seasonId} found", nameof(seasonId)); + var @event = await GetEventEntityAsync(seasonId, eventId, cancellationToken) + ?? await GetLatestEventEntityAsync(seasonId, cancellationToken); + if (@event is null) + { + return EmptyStandingConfiguration(); + } + var config = DefaultStandingConfiguration(season, @event.EventId); + var standingConfig = await GetConfigurationEntityAsync(standingConfigId, cancellationToken); + var champSeason = standingConfig?.ChampSeasons.FirstOrDefault(x => x.SeasonId == seasonId); + if (standingConfig is not null && champSeason is not null) + { + var championship = champSeason.Championship; + config.ChampSeasonId = standingConfig.ChampSeasons.FirstOrDefault(x => x.SeasonId == seasonId)?.ChampSeasonId; + config.StandingConfigId = standingConfig.StandingConfigId; + config.ResultConfigs = champSeason.ResultConfigurations.Select(x => x.ResultConfigId); + config.Name = champSeason.Championship.Name; + config.DisplayName = string.IsNullOrWhiteSpace(championship.DisplayName) ? championship.Name : championship.DisplayName; + config.UseCombinedResult = standingConfig.UseCombinedResult; + config.ResultKind = champSeason.ResultKind; + config.WeeksCounted = standingConfig.WeeksCounted > 0 ? standingConfig.WeeksCounted : 999; + config.SortOptions = standingConfig.SortOptions; + } + // Add default sorting options if none are configured + if (config.SortOptions.None()) + { + config.SortOptions.Add(SortOptions.TotalPtsDesc); + config.SortOptions.Add(SortOptions.PenPtsAsc); + config.SortOptions.Add(SortOptions.WinsDesc); + config.SortOptions.Add(SortOptions.IncsAsc); + } + return config; + } + + private async Task GetSeasonEntityAsync(long seasonId, CancellationToken cancellationToken) + { + return await dbContext.Seasons + .FirstOrDefaultAsync(x => x.SeasonId == seasonId, cancellationToken); + } + + private async Task GetConfigurationEntityAsync(long? standingConfigId, CancellationToken cancellationToken) + { + return await dbContext.StandingConfigurations + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.ResultConfigurations) + .Include(x => x.ChampSeasons) + .ThenInclude(x => x.Championship) + .FirstOrDefaultAsync(x => x.StandingConfigId == standingConfigId, cancellationToken: cancellationToken); + } + + private async Task GetEventEntityAsync(long seasonId, long? eventId, CancellationToken cancellationToken) + { + return await dbContext.Events + .Where(x => x.Schedule.SeasonId == seasonId) + .FirstOrDefaultAsync(x => x.EventId == eventId, cancellationToken); + } + + private async Task GetLatestEventEntityAsync(long seasonId, CancellationToken cancellationToken) + { + return await dbContext.Events + .Where(x => x.Schedule.SeasonId == seasonId) + .Where(x => x.ScoredEventResults.Any()) + .OrderBy(x => x.Date) + .LastOrDefaultAsync(cancellationToken); + } + + private static StandingCalculationConfiguration DefaultStandingConfiguration(SeasonEntity season, long eventId) + { + return new StandingCalculationConfiguration() + { + Name = "Default", + DisplayName = "Default", + LeagueId = season.LeagueId, + SeasonId = season.SeasonId, + EventId = eventId, + }; + } + + private static StandingCalculationConfiguration EmptyStandingConfiguration() + { + return new StandingCalculationConfiguration(); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/StandingCalculationDataProvider.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/StandingCalculationDataProvider.cs new file mode 100644 index 00000000..6bf05c53 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/StandingCalculationDataProvider.cs @@ -0,0 +1,153 @@ +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal sealed class StandingCalculationDataProvider : DatabaseAccessBase, IStandingCalculationDataProvider +{ + public StandingCalculationDataProvider(LeagueDbContext dbContext) : base(dbContext) + { + } + + public async Task GetData(StandingCalculationConfiguration config, CancellationToken cancellationToken = default) + { + // 1. Get season and event entity from config + var season = await GetSeasonEntityAsync(config.SeasonId, cancellationToken) + ?? throw new InvalidOperationException($"No season with id {config.SeasonId} found"); + var currentEvent = await GetCurrentEventEntityAsync(config.EventId, cancellationToken) + ?? throw new InvalidOperationException($"No event with id {config.EventId} found"); + // 2. Load all results from events prior to configured event + var resultConfigIds = config.ResultConfigs.Count() == 0 ? new[] { default(long?) } : config.ResultConfigs.Cast(); + var previousResults = await GetPreviousResultsAsync(season.SeasonId, resultConfigIds, currentEvent.Date, cancellationToken); + // 3. Load results from latest event + var currentResults = await GetCurrentEventResultAsync(currentEvent.EventId, resultConfigIds, cancellationToken); + if (currentResults is null && previousResults.None()) + { + return null; + } + + // 4. return data + var data = new StandingCalculationData() + { + LeagueId = config.LeagueId, + EventId = config.EventId, + SeasonId = config.SeasonId, + PreviousEventResults = previousResults.ToList(), + CurrentEventResult = currentResults ?? new() { LeagueId = config.LeagueId, EventId = currentEvent.EventId }, + }; + + return data; + } + + private async Task GetSeasonEntityAsync(long seasonId, CancellationToken cancellationToken) + { + return await dbContext.Seasons + .FirstOrDefaultAsync(x => x.SeasonId == seasonId, cancellationToken); + } + + private async Task GetCurrentEventEntityAsync(long eventId, CancellationToken cancellationToken) + { + return await dbContext.Events + .FirstOrDefaultAsync(x => x.EventId == eventId, cancellationToken); + } + + private async Task> GetPreviousResultsAsync(long seasonId, IEnumerable resultConfigIds, DateTime? date, CancellationToken cancellationToken) + { + if (date is null) + { + return Array.Empty(); + } + + return await dbContext.ScoredEventResults + .Where(x => x.Event.Schedule.SeasonId == seasonId) + .Where(x => resultConfigIds.Contains(x.ResultConfigId)) + .OrderBy(x => x.Event.Date) + .Where(x => x.Event.Date < date.Value) + .Select(MapToEventResultCalculationResultExpression) + .ToListAsync(cancellationToken); + } + + private async Task GetCurrentEventResultAsync(long eventId, IEnumerable resultConfigIds, CancellationToken cancellationToken) + { + return await dbContext.ScoredEventResults + .Where(x => x.Event.EventId == eventId) + .Where(x => resultConfigIds.Contains(x.ResultConfigId)) + .Select(MapToEventResultCalculationResultExpression) + .FirstOrDefaultAsync(cancellationToken); + } + + private static Expression> MapToEventResultCalculationResultExpression => eventResult => new EventCalculationResult() + { + LeagueId = eventResult.LeagueId, + EventId = eventResult.EventId, + Name = eventResult.Name, + ResultConfigId = eventResult.ResultConfigId, + ResultId = eventResult.ResultId, + SessionResults = eventResult.ScoredSessionResults.Select(sessionResult => new SessionCalculationResult() + { + LeagueId = sessionResult.LeagueId, + SessionNr = sessionResult.SessionNr, + FastestAvgLap = sessionResult.FastestAvgLap, + FastestAvgLapDriverMemberId = sessionResult.FastestAvgLapDriverMemberId, + FastestLap = sessionResult.FastestLap, + FastestLapDriverMemberId = sessionResult.FastestLapDriverMemberId, + FastestQualyLap = sessionResult.FastestQualyLap, + FastestQualyLapDriverMemberId = sessionResult.FastestQualyLapDriverMemberId, + CleanestDrivers = sessionResult.CleanestDrivers.Select(x => x.Id).ToList(), + HardChargers = sessionResult.HardChargers.Select(x => x.Id).ToList(), + Name = sessionResult.Name, + ScoringId = sessionResult.ScoringId, + SessionResultId = sessionResult.SessionResultId, + ResultRows = sessionResult.ScoredResultRows.Select(row => new ResultRowCalculationResult() + { + ScoredResultRowId = row.ScoredResultRowId, + MemberId = row.MemberId, + Firstname = row.Member == null ? string.Empty : row.Member.Firstname, + Lastname = row.Member == null ? string.Empty : row.Member.Lastname, + TeamId = row.TeamId, + TeamName = row.Team == null ? string.Empty : row.Team.Name, + AvgLapTime = row.AvgLapTime, + Car = row.Car, + CarClass = row.CarClass, + CarId = row.CarId, + CarNumber = row.CarNumber, + ClassId = row.ClassId, + CompletedLaps = row.CompletedLaps, + CompletedPct = row.CompletedPct, + FastestLapTime = row.FastestLapTime, + FastLapNr = row.FastLapNr, + FinishPosition = row.FinishPosition, + Division = row.Division, + Incidents = row.Incidents, + Interval = row.Interval, + LeadLaps = row.LeadLaps, + License = row.License, + NewIrating = row.NewIRating, + NewLicenseLevel = row.NewLicenseLevel, + NewSafetyRating = row.NewSafetyRating, + OldIrating = row.OldIRating, + OldLicenseLevel = row.OldLicenseLevel, + OldSafetyRating = row.OldSafetyRating, + QualifyingTime = row.QualifyingTime, + PositionChange = row.PositionChange, + RacePoints = row.RacePoints, + SeasonStartIrating = row.SeasonStartIRating, + StartPosition = row.StartPosition, + Status = row.Status, + TotalPoints = row.RacePoints, + BonusPoints = row.BonusPoints, + ClubName = row.ClubName, + ClubId = row.ClubId, + FinalPosition = row.FinalPosition, + FinalPositionChange = row.FinalPositionChange, + NewCpi = row.NewCpi, + OldCpi = row.OldCpi, + PenaltyPoints = row.PenaltyPoints, + ScoredMemberResultRowIds = row.TeamResultRows.Select(x => x.ScoredResultRowId).ToList(), + PointsEligible = row.PointsEligible, + }) + }) + }; +} diff --git a/src/iRLeagueApiCore.Services/ResultService/DataAccess/StandingCalculationResultStore.cs b/src/iRLeagueApiCore.Services/ResultService/DataAccess/StandingCalculationResultStore.cs new file mode 100644 index 00000000..fb12369b --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/DataAccess/StandingCalculationResultStore.cs @@ -0,0 +1,205 @@ +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.ResultService.DataAccess; + +internal class StandingCalculationResultStore : DatabaseAccessBase, IStandingCalculationResultStore +{ + public StandingCalculationResultStore(LeagueDbContext dbContext) : base(dbContext) + { + } + + public async Task StoreCalculationResult(StandingCalculationResult result, CancellationToken cancellationToken = default) + { + var standing = await GetOrCreateStandingEntity(result, cancellationToken); + var requiredEntities = await GetRequiredEntities(result, cancellationToken); + await MapToStandingEntity(result, standing, requiredEntities, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + } + + private async Task GetOrCreateStandingEntity(StandingCalculationResult result, CancellationToken cancellationToken) + { + var standing = await dbContext.Standings + .Include(x => x.StandingRows) + .ThenInclude(x => x.ResultRows) + .ThenInclude(x => x.ScoredResultRow) + .Where(x => x.EventId == result.EventId) + .Where(x => x.StandingConfigId == result.StandingConfigId) + .FirstOrDefaultAsync(cancellationToken); + if (standing is null) + { + var @event = await dbContext.Events + .Where(x => x.LeagueId == result.LeagueId) + .FirstOrDefaultAsync(x => x.EventId == result.EventId, cancellationToken) + ?? throw new InvalidOperationException($"No event with id {result.EventId} found"); + var season = await dbContext.Seasons + .Where(x => x.LeagueId == result.LeagueId) + .FirstOrDefaultAsync(x => x.SeasonId == result.SeasonId, cancellationToken) + ?? throw new InvalidOperationException($"No season with id {result.SeasonId} found"); + var standingConfig = await dbContext.StandingConfigurations + .Where(x => x.LeagueId == result.LeagueId) + .Where(x => x.StandingConfigId == result.StandingConfigId) + .FirstOrDefaultAsync(cancellationToken); + standing = new StandingEntity() + { + Season = season, + Event = @event, + StandingConfig = standingConfig, + }; + dbContext.Standings.Add(standing); + } + return standing; + } + + private async Task MapToStandingEntity(StandingCalculationResult result, StandingEntity entity, RequiredEntities requiredEntities, + CancellationToken cancellationToken) + { + entity.ChampSeason = await dbContext.ChampSeasons + .FirstOrDefaultAsync(x => x.ChampSeasonId == result.ChampSeasonId, cancellationToken); + entity.Name = result.Name; + entity.IsTeamStanding = result.IsTeamStanding; + foreach (var row in result.StandingRows) + { + StandingRowEntity? rowEntity = default; + if (row.MemberId is not null) + { + rowEntity = entity.StandingRows + .FirstOrDefault(x => x.MemberId == row.MemberId); + } + if (rowEntity is null && row.MemberId is null && row.TeamId is not null) + { + rowEntity = entity.StandingRows + .FirstOrDefault(x => x.TeamId == row.TeamId); + } + if (rowEntity is null) + { + rowEntity = new() + { + Member = requiredEntities.Members.FirstOrDefault(x => x.Id == row.MemberId), + MemberId = row.MemberId, + Team = requiredEntities.Teams.FirstOrDefault(x => x.TeamId == row.TeamId), + TeamId = row.TeamId, + }; + entity.StandingRows.Add(rowEntity); + } + rowEntity.CarClass = row.CarClass; + rowEntity.ClassId = row.ClassId; + rowEntity.CompletedLaps = row.CompletedLaps; + rowEntity.CompletedLapsChange = row.CompletedLapsChange; + rowEntity.DroppedResultCount = row.DroppedResultCount; + rowEntity.FastestLaps = row.FastestLaps; + rowEntity.FastestLapsChange = row.FastestLapsChange; + rowEntity.Incidents = row.Incidents; + rowEntity.IncidentsChange = row.IncidentsChange; + rowEntity.LastPosition = row.LastPosition; + rowEntity.LeadLaps = row.LeadLaps; + rowEntity.LeadLapsChange = row.LeadLapsChange; + rowEntity.PenaltyPoints = row.PenaltyPoints; + rowEntity.PenaltyPointsChange = row.PenaltyPointsChange; + rowEntity.PolePositions = row.PolePositions; + rowEntity.PolePositionsChange = row.PolePositionsChange; + rowEntity.Position = row.Position; + rowEntity.PositionChange = row.PositionChange; + rowEntity.RacePoints = row.RacePoints; + rowEntity.RacePointsChange = row.RacePointsChange; + rowEntity.Races = row.Races; + rowEntity.RacesCounted = row.RacesCounted; + rowEntity.RacesScored = row.RacesScored; + rowEntity.RacesInPoints = row.RacesInPoints; + rowEntity.Team = requiredEntities.Teams.FirstOrDefault(x => x.TeamId == row.TeamId); + rowEntity.Top10 = row.Top10; + rowEntity.Top3 = row.Top3; + rowEntity.Top5 = row.Top5; + rowEntity.TotalPoints = row.TotalPoints; + rowEntity.TotalPointsChange = row.TotalPointsChange; + rowEntity.Wins = row.Wins; + rowEntity.WinsChange = row.WinsChange; + rowEntity.ResultRows = MapToStandingResultRowsList(result.LeagueId, row.ResultRows, rowEntity.ResultRows, requiredEntities); + rowEntity.StartIrating = row.StartIrating; + rowEntity.LastIrating = row.LastIrating; + } + + var memberIds = result.StandingRows.Select(x => x.MemberId); + foreach (var row in entity.StandingRows.Where(x => memberIds.Contains(x.MemberId) == false)) + { + entity.StandingRows.Remove(row); + } + + return entity; + } + + private ICollection MapToStandingResultRowsList(long leagueId, IEnumerable rowsData, + ICollection rowsEntities, RequiredEntities requiredEntities) + { + foreach (var row in rowsData.Where(x => x.ScoredResultRowId != null)) + { + var rowEntity = rowsEntities + .Where(x => x.LeagueId == leagueId) + .Where(x => x.ScoredResultRowRefId == row.ScoredResultRowId) + .FirstOrDefault(); + if (rowEntity is null) + { + rowEntity = new() + { + LeagueId = leagueId, + ScoredResultRow = requiredEntities.ScoredResultRows.First(x => x.ScoredResultRowId == row.ScoredResultRowId) + }; + rowsEntities.Add(rowEntity); + } + rowEntity.IsScored = row.IsScored; + } + return rowsEntities; + } + + private async Task GetRequiredEntities(StandingCalculationResult result, CancellationToken cancellationToken) + { + RequiredEntities requiredEntities = new(); + requiredEntities.Members = await GetMemberEntities(result.StandingRows + .Select(x => x.MemberId) + .NotNull(), cancellationToken); + requiredEntities.Teams = await GetTeamEntities(result.StandingRows + .Select(x => x.TeamId) + .NotNull(), cancellationToken); + requiredEntities.ScoredResultRows = await GetScoredResultRowEntities(result.StandingRows + .SelectMany(x => x.ResultRows) + .Select(x => x.ScoredResultRowId) + .NotNull(), cancellationToken); + return requiredEntities; + } + + private async Task> GetMemberEntities(IEnumerable memberIds, CancellationToken cancellationToken) + { + return await dbContext.Members + .Where(x => memberIds.Contains(x.Id)) + .ToListAsync(cancellationToken); + } + + private async Task> GetTeamEntities(IEnumerable teamIds, CancellationToken cancellationToken) + { + return await dbContext.Teams + .Where(x => teamIds.Contains(x.TeamId)) + .ToListAsync(cancellationToken); + } + + private async Task> GetScoredResultRowEntities(IEnumerable ids, CancellationToken cancellationToken) + { + return await dbContext.ScoredResultRows + .Where(x => ids.Contains(x.ScoredResultRowId)) + .ToListAsync(cancellationToken); + } + + public async Task ClearStaleStandings(IEnumerable standingConfigIds, long eventId, CancellationToken cancellationToken = default) + { + var removeStandings = await dbContext.Standings + .Where(x => x.EventId == eventId) + .Where(x => standingConfigIds.Contains(x.StandingConfigId) == false) + .ToListAsync(cancellationToken); + foreach (var standing in removeStandings) + { + dbContext.Standings.Remove(standing); + } + await dbContext.SaveChangesAsync(cancellationToken); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Excecution/ExecuteEventResultCalculation.cs b/src/iRLeagueApiCore.Services/ResultService/Excecution/ExecuteEventResultCalculation.cs new file mode 100644 index 00000000..ae262521 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Excecution/ExecuteEventResultCalculation.cs @@ -0,0 +1,91 @@ +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking; + +namespace iRLeagueApiCore.Services.ResultService.Excecution; + +internal sealed class ExecuteEventResultCalculation +{ + private readonly ILogger logger; + private readonly IEventCalculationDataProvider dataProvider; + private readonly IEventCalculationConfigurationProvider configProvider; + private readonly IEventCalculationResultStore dataStore; + private readonly ICalculationServiceProvider calculationServiceProvider; + private readonly IStandingCalculationQueue standingCalculationQueue; + + public ExecuteEventResultCalculation(ILogger logger, + IEventCalculationDataProvider dataProvider, + IEventCalculationConfigurationProvider configProvider, + IEventCalculationResultStore dataStore, + ICalculationServiceProvider calculationServiceProvider, + IStandingCalculationQueue standingCalculationQueue) + { + this.logger = logger; + this.dataProvider = dataProvider; + this.configProvider = configProvider; + this.dataStore = dataStore; + this.calculationServiceProvider = calculationServiceProvider; + this.standingCalculationQueue = standingCalculationQueue; + } + + public async ValueTask Execute(long eventId, CancellationToken cancellationToken = default) + { + using var loggerScoppe = logger.BeginScope(new Dictionary { ["ExecutionId"] = new Guid() }); + + logger.LogInformation("--- Start result calculation for event: {EventId} ---", eventId); + await dataProvider.SetLeague(eventId, cancellationToken); + + IEnumerable resultConfigIds = (await configProvider.GetResultConfigIds(eventId, cancellationToken)).Cast(); + if (resultConfigIds.Any() == false) + { + resultConfigIds = new[] { default(long?) }; + logger.LogInformation("No result config found -> Using default."); + } + + var eventResultCount = 0; + logger.LogInformation("Calculating results for config ids: [{ResultConfigIds}]", resultConfigIds); + try + { + foreach (var configId in resultConfigIds) + { + try + { + var config = await configProvider.GetConfiguration(eventId, configId, cancellationToken); + var data = await dataProvider.GetData(config, cancellationToken); + if (data == null) + { + logger.LogInformation("No result data available for event: {EventId} | config: {ConfigId}", eventId, configId); + continue; + } + var calculationService = calculationServiceProvider.GetCalculationService(config); + var result = await calculationService.Calculate(data); + logger.LogInformation("Result calculated for event: {EventId} | config: {ConfigId}\n" + + " - SessionResults: {SessionResultCount}\n" + + " - ResultRows: {ResultRowCount}", eventId, configId, result.SessionResults.Count(), result.SessionResults.SelectMany(x => x.ResultRows).Count()); + await dataStore.StoreCalculationResult(result, cancellationToken); + eventResultCount++; + logger.LogInformation("Results stored"); + } + catch (Exception ex) when (ex is AggregateException || ex is InvalidOperationException || ex is NotImplementedException) + { + logger.LogError("Error thrown while calculating results for configId ({ConfigId}): {Exception}", configId, ex); + } + } + logger.LogInformation("Results calculated for event: {EventId}\n" + + " - EventResults: {EventResultCount}", eventId, eventResultCount); + logger.LogInformation("--- Result calculation finished successfully ---"); + } + catch (Exception ex) when (ex is AggregateException || ex is InvalidOperationException || ex is NotImplementedException) + { + logger.LogError("Error thrown while calculating results: {Exception}", ex); + } + + + logger.LogInformation("Queueing standing calculation for event {EventId}", eventId); + await standingCalculationQueue.QueueStandingCalculationAsync(eventId); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Excecution/ExecuteStandingCalculation.cs b/src/iRLeagueApiCore.Services/ResultService/Excecution/ExecuteStandingCalculation.cs new file mode 100644 index 00000000..64b0aebd --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Excecution/ExecuteStandingCalculation.cs @@ -0,0 +1,84 @@ +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.ResultService.Excecution; + +internal sealed class ExecuteStandingCalculation +{ + private readonly ILogger logger; + private readonly IStandingCalculationDataProvider dataProvider; + private readonly IStandingCalculationConfigurationProvider configProvider; + private readonly IStandingCalculationResultStore dataStore; + private readonly ICalculationServiceProvider calculationServiceProvider; + + public ExecuteStandingCalculation(ILogger logger, IStandingCalculationDataProvider dataProvider, + IStandingCalculationConfigurationProvider configProvider, IStandingCalculationResultStore dataStore, + ICalculationServiceProvider calculationServiceProvider) + { + this.logger = logger; + this.dataProvider = dataProvider; + this.configProvider = configProvider; + this.dataStore = dataStore; + this.calculationServiceProvider = calculationServiceProvider; + } + + public async ValueTask Execute(long eventId, CancellationToken cancellationToken = default) + { + using var loggerScoppe = logger.BeginScope(new Dictionary { ["ExecutionId"] = new Guid() }); + await dataProvider.SetLeague(eventId, cancellationToken); + + logger.LogInformation("--- Start standing calculation for event: {EventId} ---", eventId); + var seasonId = await configProvider.GetSeasonId(eventId, cancellationToken) ?? -1; + if (seasonId == -1) + { + logger.LogInformation("No season found for event {EvenId} - cancelling standing calculation", eventId); + return; + } + IEnumerable standingConfigIds = (await configProvider.GetStandingConfigIds(seasonId, cancellationToken)).Cast(); + if (standingConfigIds.Any() == false) + { + standingConfigIds = new[] { default(long?) }; + logger.LogInformation("No standing config found -> Using default."); + } + + var standingCount = 0; + logger.LogInformation("Calculating standings for config ids: [{StandingConfigIds}]", standingConfigIds); + try + { + foreach (var configId in standingConfigIds) + { + try + { + var config = await configProvider.GetConfiguration(seasonId, eventId, configId, cancellationToken); + var data = await dataProvider.GetData(config, cancellationToken); + if (data == null) + { + logger.LogInformation("No standing data available for event: {EventId} | config: {ConfigId}", eventId, configId); + continue; + } + var calculationService = calculationServiceProvider.GetCalculationService(config); + var result = await calculationService.Calculate(data); + logger.LogInformation("Standing calculated for event: {EventId} | config: {ConfigId}\n" + + " - StandingRows: {StandingRowCount}", eventId, configId, result.StandingRows.Count); + await dataStore.StoreCalculationResult(result, cancellationToken); + standingCount++; + logger.LogInformation("Standing stored"); + } + catch (Exception ex) when (ex is AggregateException || ex is InvalidOperationException || ex is NotImplementedException) + { + logger.LogError("Error thrown while calculating standing for configId ({ConfigId}): {Exception}", configId, ex); + } + } + logger.LogInformation("Standings calculated for season: {SeasonId}, event: {EventId}\n" + + " - Standings: {StandingCount}", seasonId, eventId, standingCount); + await dataStore.ClearStaleStandings(standingConfigIds, eventId); + logger.LogInformation("Cleared stale Standings"); + logger.LogInformation("--- Standing calculation finished successfully ---"); + } + catch (Exception ex) when (ex is AggregateException || ex is InvalidOperationException || ex is NotImplementedException) + { + logger.LogError("Error thrown while calculating standings: {Exception}", ex); + } + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Excecution/IResultCalculationQueue.cs b/src/iRLeagueApiCore.Services/ResultService/Excecution/IResultCalculationQueue.cs new file mode 100644 index 00000000..aa810cf1 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Excecution/IResultCalculationQueue.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Services.ResultService.Excecution; + +public interface IResultCalculationQueue +{ + public Task QueueEventResultAsync(long eventId); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Excecution/IStandingCalculationQueue.cs b/src/iRLeagueApiCore.Services/ResultService/Excecution/IStandingCalculationQueue.cs new file mode 100644 index 00000000..6c89b22a --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Excecution/IStandingCalculationQueue.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Services.ResultService.Excecution; + +internal interface IStandingCalculationQueue +{ + public Task QueueStandingCalculationAsync(long eventId); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Excecution/ResultCalculationQueue.cs b/src/iRLeagueApiCore.Services/ResultService/Excecution/ResultCalculationQueue.cs new file mode 100644 index 00000000..799f734e --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Excecution/ResultCalculationQueue.cs @@ -0,0 +1,26 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace iRLeagueApiCore.Services.ResultService.Excecution; + +internal sealed class ResultCalculationQueue : IResultCalculationQueue +{ + private readonly IServiceProvider serviceProvider; + private readonly IBackgroundTaskQueue taskQueue; + + public ResultCalculationQueue(IServiceProvider serviceProvider, IBackgroundTaskQueue taskQueue) + { + this.serviceProvider = serviceProvider; + this.taskQueue = taskQueue; + } + + public async Task QueueEventResultAsync(long eventId) + { + var scope = serviceProvider.CreateScope(); + await taskQueue.QueueBackgroundWorkItemAsync(async cancellationToken => + { + var resultCalculation = scope.ServiceProvider.GetRequiredService(); + await resultCalculation.Execute(eventId, cancellationToken); + scope.Dispose(); + }); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Excecution/StandingCalculationQueue.cs b/src/iRLeagueApiCore.Services/ResultService/Excecution/StandingCalculationQueue.cs new file mode 100644 index 00000000..f166bc2b --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Excecution/StandingCalculationQueue.cs @@ -0,0 +1,26 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace iRLeagueApiCore.Services.ResultService.Excecution; + +internal sealed class StandingCalculationQueue : IStandingCalculationQueue +{ + private readonly IServiceProvider serviceProvider; + private readonly IBackgroundTaskQueue taskQueue; + + public StandingCalculationQueue(IServiceProvider serviceProvider, IBackgroundTaskQueue taskQueue) + { + this.serviceProvider = serviceProvider; + this.taskQueue = taskQueue; + } + + public async Task QueueStandingCalculationAsync(long eventId) + { + var scope = serviceProvider.CreateScope(); + await taskQueue.QueueBackgroundWorkItemAsync(async cancellationToken => + { + var standingCalculation = scope.ServiceProvider.GetRequiredService(); + await standingCalculation.Execute(eventId, cancellationToken); + scope.Dispose(); + }); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Extensions/CalculationExtensions.cs b/src/iRLeagueApiCore.Services/ResultService/Extensions/CalculationExtensions.cs new file mode 100644 index 00000000..0b65acdb --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Extensions/CalculationExtensions.cs @@ -0,0 +1,31 @@ +namespace iRLeagueApiCore.Services.ResultService.Extensions; + +public static class CalculationExtensions +{ + public static IEnumerable NotNull(this IEnumerable enumerable) where T : struct + { + return enumerable.OfType(); + } + + public static TValue? GetOrDefault(this IDictionary dictionary, TKey? key) + { + if (key == null) + { + return default; + } + dictionary.TryGetValue(key, out TValue? value); + return value; + } + + public static TValue? GetOrDefault(this IDictionary dictionary, Nullable key) where TKey : struct + { + return GetOrDefault(dictionary, key); + } + + public static IEnumerable GetMultiple(this IDictionary dictionary, IEnumerable keys) + { + return dictionary + .Where(x => keys.Contains(x.Key)) + .Select(x => x.Value); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Extensions/EnumerableExtensions.cs b/src/iRLeagueApiCore.Services/ResultService/Extensions/EnumerableExtensions.cs new file mode 100644 index 00000000..85aa2b6e --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Extensions/EnumerableExtensions.cs @@ -0,0 +1,71 @@ +namespace iRLeagueApiCore.Services.ResultService.Extensions; + +public static class EnumerableExtensions +{ + public static IEnumerable ForEach(this IEnumerable enumerable, Action action) + { + foreach (var item in enumerable) + { + action(item); + } + return enumerable; + } + + public static IEnumerable Shuffle(this IEnumerable enumerable, Random? random = default) + { + random ??= new(); + return enumerable + .Select(item => new { item, rnd = random.Next() }) + .OrderBy(x => x.rnd) + .Select(x => x.item); + + } + + /// + /// returns subset of values that are not null + /// + /// + /// + /// + public static IEnumerable NotNull(this IEnumerable enumerable) where T : notnull + { + return enumerable.Where(x => x is not null).OfType(); + } + + /// + /// Returns true when the collection does not contain any elements + /// + /// + /// + /// + public static bool None(this IEnumerable enumerable) => !enumerable.Any(); + /// + /// Returns true when the collection does not contain any elements with the given predicate + /// + /// + /// + /// + /// + public static bool None(this IEnumerable enumerable, Func predicate) => !enumerable.Any(predicate); + /// + /// Returns the maximum value or the default if the sequence is empty + /// + /// + /// + /// + public static T MaxOrDefault(this IEnumerable enumerable) + { + return enumerable.Any() ? enumerable.Max()! : default(T)!; + } + /// + /// Returns the maximum value or the default if the sequence is empty + /// + /// + /// + /// + /// + public static T MaxOrDefault(this IEnumerable enumerable, Func selector) + { + return enumerable.Any() ? enumerable.Max(selector)! : default(T)!; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Extensions/ListExtensions.cs b/src/iRLeagueApiCore.Services/ResultService/Extensions/ListExtensions.cs new file mode 100644 index 00000000..56b6a9b9 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Extensions/ListExtensions.cs @@ -0,0 +1,21 @@ +namespace iRLeagueApiCore.Services.ResultService.Extensions; +public static class ListExtensions +{ + public static void Move(this IList list, int index, int offset) + { + int newIndex = index + offset; + + if (newIndex < 0) + { + newIndex = 0; + } + if (newIndex >= list.Count) + { + newIndex = list.Count - 1; + } + + T entry = list[index]; + list.RemoveAt(index); + list.Insert(newIndex, entry); + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Extensions/ResultServiceCollectionExtensions.cs b/src/iRLeagueApiCore.Services/ResultService/Extensions/ResultServiceCollectionExtensions.cs new file mode 100644 index 00000000..e3f8ad55 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Extensions/ResultServiceCollectionExtensions.cs @@ -0,0 +1,57 @@ +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Excecution; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace Microsoft.Extensions.DependencyInjection; + +public static class ResultServiceCollectionExtensions +{ + public static IServiceCollection AddResultService(this IServiceCollection services) + { + // Result calculation + services.TryAddScoped(s => s.GetRequiredService()); + services.TryAddScoped>( + x => new EventCalculationServiceProvider( + x.GetRequiredService>())); + services.TryAddScoped>( + x => new SessionCalculationServiceProvider()); + services.TryAddScoped(x => new EventCalculationConfigurationProvider( + x.GetRequiredService(), + x.GetRequiredService())); + services.TryAddScoped(x => new EventCalculationDataProvider( + x.GetRequiredService())); + services.TryAddScoped(x => new EventCalculationResultStore( + x.GetRequiredService())); + services.TryAddScoped(x => new SessionCalculationConfigurationProvider( + x.GetRequiredService())); + services.TryAddScoped(x => new ExecuteEventResultCalculation( + x.GetRequiredService>(), + x.GetRequiredService(), + x.GetRequiredService(), + x.GetRequiredService(), + x.GetRequiredService>(), + x.GetRequiredService())); + services.TryAddScoped(x => new ResultCalculationQueue(x, x.GetRequiredService())); + // Standing calculation + services.TryAddScoped>( + x => new StandingCalculationServiceProvider()); + services.TryAddScoped(x => new StandingCalculationConfigurationProvider( + x.GetRequiredService())); + services.TryAddScoped(x => new StandingCalculationDataProvider( + x.GetRequiredService())); + services.TryAddScoped(x => new StandingCalculationResultStore( + x.GetRequiredService())); + services.TryAddScoped(x => new ExecuteStandingCalculation( + x.GetRequiredService>(), + x.GetRequiredService(), + x.GetRequiredService(), + x.GetRequiredService(), + x.GetRequiredService>())); + services.TryAddScoped(x => new StandingCalculationQueue(x, x.GetRequiredService())); + + return services; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Extensions/SortOptionsExtensions.cs b/src/iRLeagueApiCore.Services/ResultService/Extensions/SortOptionsExtensions.cs new file mode 100644 index 00000000..d9e6bd6c --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Extensions/SortOptionsExtensions.cs @@ -0,0 +1,90 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Models; +using MySqlX.XDevAPI.Relational; +using System.Runtime.CompilerServices; + +namespace iRLeagueApiCore.Services.ResultService.Extensions; + +internal static class SortOptionsExtensions +{ + public static Func GetSortingValue(this SortOptions sortOption) where T : ResultRowCalculationData + { + return sortOption switch + { + SortOptions.BonusPtsAsc => row => row.BonusPoints, + SortOptions.BonusPtsDesc => row => -row.BonusPoints, + SortOptions.ComplLapsAsc => row => row.CompletedLaps, + SortOptions.ComplLapsDesc => row => -row.CompletedLaps, + SortOptions.FastLapAsc => row => GetLapTimeSortValue(row.FastestLapTime), + SortOptions.FastLapDesc => row => -GetLapTimeSortValue(row.FastestLapTime), + SortOptions.IncsAsc => row => row.Incidents, + SortOptions.IncsDesc => row => -row.Incidents, + SortOptions.IntvlAsc => row => row.Interval, + SortOptions.IntvlDesc => row => -row.Interval, + SortOptions.LeadLapsAsc => row => row.LeadLaps, + SortOptions.LeadLapsDesc => row => -row.LeadLaps, + SortOptions.PenPtsAsc => row => row.PenaltyPoints, + SortOptions.PenPtsDesc => row => -row.PenaltyPoints, + SortOptions.PosAsc => row => row.FinishPosition, + SortOptions.PosDesc => row => -row.FinishPosition, + SortOptions.QualLapAsc => row => GetLapTimeSortValue(row.QualifyingTime), + SortOptions.QualLapDesc => row => -GetLapTimeSortValue(row.QualifyingTime), + SortOptions.RacePtsAsc => row => row.RacePoints, + SortOptions.RacePtsDesc => row => -row.RacePoints, + SortOptions.StartPosAsc => row => row.StartPosition, + SortOptions.StartPosDesc => row => -row.StartPosition, + SortOptions.TotalPtsAsc => row => row.TotalPoints, + SortOptions.TotalPtsDesc => row => -row.TotalPoints, + SortOptions.TotalPtsWoBonusAsc => row => row.RacePoints - row.PenaltyPoints, + SortOptions.TotalPtsWoBonusDesc => row => -(row.RacePoints - row.PenaltyPoints), + SortOptions.TotalPtsWoPenaltyAsc => row => row.RacePoints + row.BonusPoints, + SortOptions.TotalPtsWoPenaltyDesc => row => -(row.RacePoints + row.BonusPoints), + _ => row => 0, + }; + } + + public static Func GetStandingSortingValue(this SortOptions sortOption) where T : StandingRowCalculationResult + { + return sortOption switch + { + SortOptions.ComplLapsAsc => row => row.CompletedLaps, + SortOptions.ComplLapsDesc => row => -row.CompletedLaps, + SortOptions.IncsAsc => row => row.Incidents, + SortOptions.IncsDesc => row => -row.Incidents, + SortOptions.LeadLapsAsc => row => row.LeadLaps, + SortOptions.LeadLapsDesc => row => -row.LeadLaps, + SortOptions.PenPtsAsc => row => row.PenaltyPoints, + SortOptions.PenPtsDesc => row => -row.PenaltyPoints, + SortOptions.PosAsc => row => row.Position, + SortOptions.PosDesc => row => -row.Position, + SortOptions.RacePtsAsc => row => row.RacePoints, + SortOptions.RacePtsDesc => row => -row.RacePoints, + SortOptions.TotalPtsAsc => row => row.TotalPoints, + SortOptions.TotalPtsDesc => row => -row.TotalPoints, + SortOptions.LastRaceOrderAsc => row => row.ResultRows.LastOrDefault()?.FinalPosition ?? 999, + SortOptions.LastRaceOrderDesc => row => -(row.ResultRows.LastOrDefault()?.FinalPosition ?? 999), + SortOptions.WinsAsc => row => row.Wins, + SortOptions.WinsDesc => row => -row.Wins, + SortOptions.Top3Asc => row => row.Top3, + SortOptions.Top3Desc => row => -row.Top3, + SortOptions.Top5Asc => row => row.Top5, + SortOptions.Top5Desc => row => -row.Top5, + SortOptions.Top10Asc => row => row.Top10, + SortOptions.Top10Desc => row => -row.Top10, + SortOptions.RacesAsc => row => row.Races, + SortOptions.RacesDesc => row => -row.Races, + SortOptions.RacesCountedAsc => row => row.RacesCounted, + SortOptions.RacesCountedDesc => row => -row.RacesCounted, + SortOptions.RacesScoredAsc => row => row.RacesScored, + SortOptions.RacesScoredDesc => row => -row.RacesScored, + SortOptions.RacesInPointsAsc => row => row.RacesInPoints, + SortOptions.RacesInPointsDesc => row => -row.RacesInPoints, + _ => row => 0, + }; + } + + private static TimeSpan GetLapTimeSortValue(TimeSpan lapTime) + { + return lapTime != TimeSpan.Zero ? lapTime : TimeSpan.MaxValue; + } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/AcceptedReviewVoteCalculationData.cs b/src/iRLeagueApiCore.Services/ResultService/Models/AcceptedReviewVoteCalculationData.cs new file mode 100644 index 00000000..0504029c --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/AcceptedReviewVoteCalculationData.cs @@ -0,0 +1,11 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +public sealed class AcceptedReviewVoteCalculationData +{ + public long ReviewVoteId { get; set; } + public long ReviewId { get; set; } + public long? MemberAtFaultId { get; set; } + public long? TeamAtFaultId { get; set; } + public long? VoteCategoryId { get; set; } + public int DefaultPenalty { get; set; } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/AddPenaltyCalculationData.cs b/src/iRLeagueApiCore.Services/ResultService/Models/AddPenaltyCalculationData.cs new file mode 100644 index 00000000..62b2bae5 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/AddPenaltyCalculationData.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.Common.Enums; + +namespace iRLeagueApiCore.Services.ResultService.Models; + +public sealed class AddPenaltyCalculationData +{ + public int SessionNr { get; set; } + public long? MemberId { get; set; } + public long? TeamId { get; set; } + public PenaltyType Type { get; set; } + public double Points { get; set; } + public int Positions { get; set; } + public TimeSpan Time { get; set; } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/AddPenaltyCalculationResult.cs b/src/iRLeagueApiCore.Services/ResultService/Models/AddPenaltyCalculationResult.cs new file mode 100644 index 00000000..8444ced4 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/AddPenaltyCalculationResult.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +public sealed class AddPenaltyCalculationResult +{ + public int PenaltyPoints { get; set; } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/AutoPenaltyConfigurationData.cs b/src/iRLeagueApiCore.Services/ResultService/Models/AutoPenaltyConfigurationData.cs new file mode 100644 index 00000000..e2f6529b --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/AutoPenaltyConfigurationData.cs @@ -0,0 +1,13 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Calculation; + +namespace iRLeagueApiCore.Services.ResultService.Models; +internal sealed class AutoPenaltyConfigurationData +{ + public string Description { get; set; } = string.Empty; + public PenaltyType Type { get; set; } + public int Points { get; set; } + public TimeSpan Time { get; set; } + public int Positions { get; set; } + public FilterGroupRowFilter Conditions { get; set; } = new(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/BonusPointConfiguration.cs b/src/iRLeagueApiCore.Services/ResultService/Models/BonusPointConfiguration.cs new file mode 100644 index 00000000..82614a25 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/BonusPointConfiguration.cs @@ -0,0 +1,10 @@ +using iRLeagueApiCore.Services.ResultService.Calculation; + +namespace iRLeagueApiCore.Services.ResultService.Models; +internal sealed class BonusPointConfiguration +{ + public BonusPointType Type { get; set; } + public int Value { get; set; } + public int Points { get; set; } + public FilterGroupRowFilter Conditions { get; set; } = new(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/EventCalculationConfiguration.cs b/src/iRLeagueApiCore.Services/ResultService/Models/EventCalculationConfiguration.cs new file mode 100644 index 00000000..af0938ea --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/EventCalculationConfiguration.cs @@ -0,0 +1,17 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class EventCalculationConfiguration +{ + public long LeagueId { get; set; } + public long EventId { get; set; } + /// + /// Id of existing result data (if result has been calculated before) + /// + public long? ResultId { get; set; } + public long? ChampSeasonId { get; set; } + public long? ResultConfigId { get; set; } + public long? SourceResultConfigId { get; set; } + + public string DisplayName { get; set; } = string.Empty; + public IEnumerable SessionResultConfigurations { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/EventCalculationData.cs b/src/iRLeagueApiCore.Services/ResultService/Models/EventCalculationData.cs new file mode 100644 index 00000000..fe85018b --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/EventCalculationData.cs @@ -0,0 +1,9 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class EventCalculationData +{ + public long LeagueId { get; set; } + public long EventId { get; set; } + public IEnumerable AddPenalties { get; set; } = Array.Empty(); + public IEnumerable SessionResults { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/EventCalculationResult.cs b/src/iRLeagueApiCore.Services/ResultService/Models/EventCalculationResult.cs new file mode 100644 index 00000000..d5f4e5fe --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/EventCalculationResult.cs @@ -0,0 +1,20 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class EventCalculationResult +{ + public EventCalculationResult() { } + + public EventCalculationResult(EventCalculationData data) + { + LeagueId = data.LeagueId; + EventId = data.EventId; + } + + public long LeagueId { get; set; } + public long EventId { get; set; } + public long? ResultId { get; set; } + public long? ChampSeasonId { get; set; } + public long? ResultConfigId { get; set; } + public string Name { get; set; } = string.Empty; + public IEnumerable SessionResults { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/IPenaltyRow.cs b/src/iRLeagueApiCore.Services/ResultService/Models/IPenaltyRow.cs new file mode 100644 index 00000000..a8f5cf8c --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/IPenaltyRow.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal interface IPenaltyRow +{ + public IEnumerable AddPenalties { get; set; } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/IPointRow.cs b/src/iRLeagueApiCore.Services/ResultService/Models/IPointRow.cs new file mode 100644 index 00000000..e1b60a65 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/IPointRow.cs @@ -0,0 +1,9 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal interface IPointRow +{ + public double RacePoints { get; set; } + public double BonusPoints { get; set; } + public double PenaltyPoints { get; set; } + public double TotalPoints { get; set; } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/ResultRowCalculationData.cs b/src/iRLeagueApiCore.Services/ResultService/Models/ResultRowCalculationData.cs new file mode 100644 index 00000000..d99d2595 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/ResultRowCalculationData.cs @@ -0,0 +1,57 @@ +using System.Diagnostics; + +namespace iRLeagueApiCore.Services.ResultService.Models; + +[DebuggerDisplay("RowId = {ScoredResultRowId}, MemberId = {MemberId}, " + + "TeamId = {TeamId}, RacePoints = {RacePoints}, BonusPoints = {BonusPoints}, " + + "PenaltyPoints = {PenaltyPoints}, TotalPoints = {TotalPoints}")] +internal class ResultRowCalculationData : IPointRow, IPenaltyRow +{ + public long? ScoredResultRowId { get; set; } + public long? MemberId { get; set; } + public string Firstname { get; set; } = string.Empty; + public string Lastname { get; set; } = string.Empty; + public long? TeamId { get; set; } + public string TeamName { get; set; } = string.Empty; + public string TeamColor { get; set; } = string.Empty; + public double StartPosition { get; set; } + public double FinishPosition { get; set; } + public string CarNumber { get; set; } = string.Empty; + public int ClassId { get; set; } + public int ClubId { get; set; } + public string ClubName { get; set; } = string.Empty; + public string Car { get; set; } = string.Empty; + public string CarClass { get; set; } = string.Empty; + public double CompletedLaps { get; set; } + public double LeadLaps { get; set; } + public int FastLapNr { get; set; } + public double Incidents { get; set; } + public int Status { get; set; } + public TimeSpan QualifyingTime { get; set; } + public TimeSpan Interval { get; set; } + public TimeSpan AvgLapTime { get; set; } + public TimeSpan FastestLapTime { get; set; } + public double PositionChange { get; set; } + public int OldIrating { get; set; } + public int NewIrating { get; set; } + public int SeasonStartIrating { get; set; } + public string License { get; set; } = string.Empty; + public int NewCpi { get; set; } + public int OldCpi { get; set; } + public double OldSafetyRating { get; set; } + public double NewSafetyRating { get; set; } + public int CarId { get; set; } + public double CompletedPct { get; set; } + public int Division { get; set; } + public int OldLicenseLevel { get; set; } + public int NewLicenseLevel { get; set; } + public double RacePoints { get; set; } + public double BonusPoints { get; set; } + public double PenaltyPoints { get; set; } + public double TotalPoints { get; set; } + public int FinalPosition { get; set; } + public double FinalPositionChange { get; set; } + public bool PointsEligible { get; set; } + public IEnumerable AddPenalties { get; set; } = Array.Empty(); + public ICollection ReviewPenalties { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/ResultRowCalculationResult.cs b/src/iRLeagueApiCore.Services/ResultService/Models/ResultRowCalculationResult.cs new file mode 100644 index 00000000..58a13a76 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/ResultRowCalculationResult.cs @@ -0,0 +1,61 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class ResultRowCalculationResult : ResultRowCalculationData +{ + public ResultRowCalculationResult() + { + } + + public ResultRowCalculationResult(ResultRowCalculationData data) + { + AddPenalties = data.AddPenalties; + ScoredResultRowId = data.ScoredResultRowId; + MemberId = data.MemberId; + Firstname = data.Firstname; + Lastname = data.Lastname; + TeamId = data.TeamId; + TeamName = data.TeamName; + TeamColor = data.TeamColor; + StartPosition = data.StartPosition; + FinishPosition = data.FinishPosition; + CarNumber = data.CarNumber; + ClassId = data.ClassId; + ClubId = data.ClubId; + ClubName = data.ClubName; + Car = data.Car; + CarClass = data.CarClass; + CompletedLaps = data.CompletedLaps; + LeadLaps = data.LeadLaps; + FastLapNr = data.FastLapNr; + Incidents = data.Incidents; + Status = data.Status; + QualifyingTime = data.QualifyingTime; + Interval = data.Interval; + AvgLapTime = data.AvgLapTime; + FastestLapTime = data.FastestLapTime; + PositionChange = data.PositionChange; + OldIrating = data.OldIrating; + NewIrating = data.NewIrating; + SeasonStartIrating = data.SeasonStartIrating; + License = data.License; + NewCpi = data.NewCpi; + OldCpi = data.OldCpi; + OldSafetyRating = data.OldSafetyRating; + NewSafetyRating = data.NewSafetyRating; + CarId = data.CarId; + CompletedPct = data.CompletedPct; + Division = data.Division; + OldLicenseLevel = data.OldLicenseLevel; + NewLicenseLevel = data.NewLicenseLevel; + RacePoints = data.RacePoints; + BonusPoints = data.BonusPoints; + PenaltyPoints = data.PenaltyPoints; + TotalPoints = data.TotalPoints; + FinalPosition = data.FinalPosition; + FinalPositionChange = data.FinalPositionChange; + PointsEligible = data.PointsEligible; + } + + public bool IsScored { get; set; } + public ICollection ScoredMemberResultRowIds { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/ReviewPenaltyCalculationResult.cs b/src/iRLeagueApiCore.Services/ResultService/Models/ReviewPenaltyCalculationResult.cs new file mode 100644 index 00000000..1fe3ce3b --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/ReviewPenaltyCalculationResult.cs @@ -0,0 +1,8 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +public sealed class ReviewPenaltyCalculationResult +{ + public long ReviewId { get; set; } + public long? ReviewVoteId { get; set; } + public int PenaltyPoints { get; set; } +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/SessionCalculationConfiguration.cs b/src/iRLeagueApiCore.Services/ResultService/Models/SessionCalculationConfiguration.cs new file mode 100644 index 00000000..e1e7dcf2 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/SessionCalculationConfiguration.cs @@ -0,0 +1,29 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Calculation; + +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class SessionCalculationConfiguration +{ + public long LeagueId { get; set; } + public long? SessionId { get; set; } + public int? SessionNr { get; set; } + public long? ScoringId { get; set; } + /// + /// Id of existing session result data (if result has been calculated before) + /// + public long? SessionResultId { get; set; } + public string Name { get; set; } = string.Empty; + public int MaxResultsPerGroup { get; set; } + public bool UseResultSetTeam { get; set; } + public bool UpdateTeamOnRecalculation { get; set; } + public ResultKind ResultKind { get; set; } + public bool IsCombinedResult { get; set; } + public SessionType SessionType { get; set; } + /// + /// Use the points coming from a selected external source in a combined result configuration + /// + public bool UseExternalSourcePoints { get; set; } + + public PointRule PointRule { get; set; } = PointRule.Default(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/SessionCalculationData.cs b/src/iRLeagueApiCore.Services/ResultService/Models/SessionCalculationData.cs new file mode 100644 index 00000000..a381ae34 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/SessionCalculationData.cs @@ -0,0 +1,14 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class SessionCalculationData +{ + public long LeagueId { get; set; } + public long? SessionId { get; set; } + public int? SessionNr { get; set; } + public int Sof { get; set; } + public TimeSpan FastestLap { get; set; } + public TimeSpan FastestQualyLap { get; set; } + public TimeSpan FastestAvgLap { get; set; } + public IEnumerable AcceptedReviewVotes { get; set; } = Array.Empty(); + public IEnumerable ResultRows { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/SessionCalculationResult.cs b/src/iRLeagueApiCore.Services/ResultService/Models/SessionCalculationResult.cs new file mode 100644 index 00000000..fc24cf12 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/SessionCalculationResult.cs @@ -0,0 +1,32 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class SessionCalculationResult +{ + public SessionCalculationResult() + { + } + + public SessionCalculationResult(SessionCalculationData data) + { + LeagueId = data.LeagueId; + SessionId = data.SessionId; + Sof = data.Sof; + } + + public long LeagueId { get; set; } + public long? SessionId { get; set; } + public int? SessionNr { get; set; } + public long? SessionResultId { get; set; } + public long? ScoringId { get; set; } + public string Name { get; set; } = string.Empty; + public int Sof { get; set; } + public TimeSpan FastestLap { get; set; } + public TimeSpan FastestQualyLap { get; set; } + public TimeSpan FastestAvgLap { get; set; } + public long? FastestAvgLapDriverMemberId { get; set; } + public long? FastestLapDriverMemberId { get; set; } + public long? FastestQualyLapDriverMemberId { get; set; } + public ICollection CleanestDrivers { get; set; } = Array.Empty(); + public ICollection HardChargers { get; set; } = Array.Empty(); + public IEnumerable ResultRows { get; set; } = Array.Empty(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/StandingCalculationConfiguration.cs b/src/iRLeagueApiCore.Services/ResultService/Models/StandingCalculationConfiguration.cs new file mode 100644 index 00000000..303f8e62 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/StandingCalculationConfiguration.cs @@ -0,0 +1,19 @@ +using iRLeagueApiCore.Common.Enums; + +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class StandingCalculationConfiguration +{ + public long LeagueId { get; set; } + public long SeasonId { get; set; } + public long EventId { get; set; } + public long? ChampSeasonId { get; set; } + public long? StandingConfigId { get; set; } + public IEnumerable ResultConfigs { get; set; } = Array.Empty(); + public string Name { get; set; } = string.Empty; + public string DisplayName { get; set; } = string.Empty; + public int WeeksCounted { get; set; } + public bool UseCombinedResult { get; set; } + public ResultKind ResultKind { get; set; } + public ICollection SortOptions { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/StandingCalculationData.cs b/src/iRLeagueApiCore.Services/ResultService/Models/StandingCalculationData.cs new file mode 100644 index 00000000..bfa27338 --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/StandingCalculationData.cs @@ -0,0 +1,10 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class StandingCalculationData +{ + public long LeagueId { get; set; } + public long SeasonId { get; set; } + public long EventId { get; set; } + public IList PreviousEventResults { get; set; } = new List(); + public EventCalculationResult CurrentEventResult { get; set; } = default!; +} diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/StandingCalculationResult.cs b/src/iRLeagueApiCore.Services/ResultService/Models/StandingCalculationResult.cs new file mode 100644 index 00000000..b35f379a --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/StandingCalculationResult.cs @@ -0,0 +1,13 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal sealed class StandingCalculationResult +{ + public long LeagueId { get; set; } + public long SeasonId { get; set; } + public long EventId { get; set; } + public long? ChampSeasonId { get; set; } + public long? StandingConfigId { get; set; } + public string Name { get; set; } = string.Empty; + public bool IsTeamStanding { get; set; } + public IList StandingRows { get; set; } = new List(); +} \ No newline at end of file diff --git a/src/iRLeagueApiCore.Services/ResultService/Models/StandingRowCalculationResult.cs b/src/iRLeagueApiCore.Services/ResultService/Models/StandingRowCalculationResult.cs new file mode 100644 index 00000000..59ad878c --- /dev/null +++ b/src/iRLeagueApiCore.Services/ResultService/Models/StandingRowCalculationResult.cs @@ -0,0 +1,81 @@ +namespace iRLeagueApiCore.Services.ResultService.Models; + +internal class StandingRowCalculationResult +{ + public StandingRowCalculationResult() { } + public StandingRowCalculationResult(StandingRowCalculationResult data) + { + MemberId = data.MemberId; + TeamId = data.TeamId; + Position = data.Position; + LastPosition = data.LastPosition; + ClassId = data.ClassId; + CarClass = data.CarClass; + RacePoints = data.RacePoints; + RacePointsChange = data.RacePointsChange; + PenaltyPoints = data.PenaltyPoints; + PenaltyPointsChange = data.PenaltyPointsChange; + TotalPoints = data.TotalPoints; + TotalPointsChange = data.TotalPointsChange; + Races = data.Races; + RacesCounted = data.RacesCounted; + RacesInPoints = data.RacesInPoints; + RacesScored = data.RacesScored; + DroppedResultCount = data.DroppedResultCount; + CompletedLaps = data.CompletedLaps; + CompletedLapsChange = data.CompletedLapsChange; + LeadLaps = data.LeadLaps; + LeadLapsChange = data.LeadLapsChange; + FastestLaps = data.FastestLaps; + FastestLapsChange = data.FastestLapsChange; + PolePositions = data.PolePositions; + PolePositionsChange = data.PolePositionsChange; + Wins = data.Wins; + WinsChange = data.WinsChange; + Top3 = data.Top3; + Top5 = data.Top5; + Top10 = data.Top10; + Incidents = data.Incidents; + IncidentsChange = data.IncidentsChange; + PositionChange = data.PositionChange; + ResultRows = data.ResultRows; + } + + public long? MemberId { get; set; } + public long? TeamId { get; set; } + public int Position { get; set; } + public int LastPosition { get; set; } + public int ClassId { get; set; } + public string CarClass { get; set; } = string.Empty; + public int RacePoints { get; set; } + public int RacePointsChange { get; set; } + public int PenaltyPoints { get; set; } + public int PenaltyPointsChange { get; set; } + public int TotalPoints { get; set; } + public int TotalPointsChange { get; set; } + public int Races { get; set; } + public int RacesCounted { get; set; } + public int RacesScored { get; set; } + public int RacesInPoints { get; set; } + public int DroppedResultCount { get; set; } + public int CompletedLaps { get; set; } + public int CompletedLapsChange { get; set; } + public int LeadLaps { get; set; } + public int LeadLapsChange { get; set; } + public int FastestLaps { get; set; } + public int FastestLapsChange { get; set; } + public int PolePositions { get; set; } + public int PolePositionsChange { get; set; } + public int Wins { get; set; } + public int WinsChange { get; set; } + public int Top3 { get; set; } + public int Top5 { get; set; } + public int Top10 { get; set; } + public int Incidents { get; set; } + public int IncidentsChange { get; set; } + public int PositionChange { get; set; } + public int StartIrating { get; set; } + public int LastIrating { get; set; } + + public IList ResultRows { get; set; } = new List(); +} diff --git a/src/iRLeagueApiCore.Services/iRLeagueApiCore.Services.csproj b/src/iRLeagueApiCore.Services/iRLeagueApiCore.Services.csproj new file mode 100644 index 00000000..8bbcce2f --- /dev/null +++ b/src/iRLeagueApiCore.Services/iRLeagueApiCore.Services.csproj @@ -0,0 +1,34 @@ + + + + net6.0 + enable + enable + enable + 12 + + + + + <_Parameter1>$(MSBuildProjectName).Tests + + + <_Parameter1>DynamicProxyGenAssembly2 + + + + + + + + + + + + + + + + + + diff --git a/src/iRLeagueApiCore.TrackImport/Converters/JsonStringOrNumberToStringConverter.cs b/src/iRLeagueApiCore.TrackImport/Converters/JsonStringOrNumberToStringConverter.cs new file mode 100644 index 00000000..9d3d52b5 --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/Converters/JsonStringOrNumberToStringConverter.cs @@ -0,0 +1,22 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace iRLeagueApiCore.TrackImport.Converters; + +public sealed class JsonStringOrNumberToStringConverter : JsonConverter +{ + public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + return reader.TokenType switch + { + JsonTokenType.String => reader.GetString(), + JsonTokenType.Number => reader.GetInt32().ToString(), + _ => null, + }; + } + + public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) + { + writer.WriteStringValue(value.ToString()); + } +} diff --git a/src/iRLeagueApiCore.TrackImport/Models/IRacingAuthResponse.cs b/src/iRLeagueApiCore.TrackImport/Models/IRacingAuthResponse.cs new file mode 100644 index 00000000..831956da --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/Models/IRacingAuthResponse.cs @@ -0,0 +1,12 @@ +using iRLeagueApiCore.TrackImport.Converters; +using System.Text.Json.Serialization; + +namespace iRLeagueApiCore.TrackImport.Models; + +public sealed class IRacingAuthResponse +{ + [JsonPropertyName("authcode"), JsonConverter(typeof(JsonStringOrNumberToStringConverter))] + public string? Authcode { get; set; } + [JsonPropertyName("message")] + public string? Message { get; set; } +} diff --git a/src/iRLeagueApiCore.TrackImport/Models/LinkResponseModel.cs b/src/iRLeagueApiCore.TrackImport/Models/LinkResponseModel.cs new file mode 100644 index 00000000..cdbe8862 --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/Models/LinkResponseModel.cs @@ -0,0 +1,7 @@ +namespace iRLeagueApiCore.TrackImport.Models; + +public struct LinkResponseModel +{ + public string link { get; set; } + public DateTime expires { get; set; } +} diff --git a/src/iRLeagueApiCore.TrackImport/Models/TrackAssetsModel.cs b/src/iRLeagueApiCore.TrackImport/Models/TrackAssetsModel.cs new file mode 100644 index 00000000..3aba0c2f --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/Models/TrackAssetsModel.cs @@ -0,0 +1,20 @@ +namespace iRLeagueApiCore.TrackImport.Models; + +public struct TrackAssetsModel +{ + public string coordinates { get; set; } + public string detail_copy { get; set; } + public string? detail_techspecs_copy { get; set; } + public string? detail_video { get; set; } + public string folder { get; set; } + public string gallery_images { get; set; } + public string gallery_prefix { get; set; } + public string large_image { get; set; } + public string logo { get; set; } + public string north { get; set; } + public int num_svg_images { get; set; } + public string small_image { get; set; } + public int track_id { get; set; } + public string track_map { get; set; } + public TrackMapLayersModel track_map_layers { get; set; } +} diff --git a/src/iRLeagueApiCore.TrackImport/Models/TrackImportModel.cs b/src/iRLeagueApiCore.TrackImport/Models/TrackImportModel.cs new file mode 100644 index 00000000..8bfbc20f --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/Models/TrackImportModel.cs @@ -0,0 +1,53 @@ +namespace iRLeagueApiCore.TrackImport.Models; + +public struct TrackImportModel +{ + public bool ai_enabled { get; set; } + public bool award_exempt { get; set; } + public string? category { get; set; } + public int category_id { get; set; } + public DateTime closes { get; set; } + public string? config_name { get; set; } + public int corners_per_lap { get; set; } + public DateTime created { get; set; } + public bool free_with_subscription { get; set; } + public bool fully_lit { get; set; } + public int grid_stalls { get; set; } + public bool has_opt_path { get; set; } + public bool has_short_parade_lap { get; set; } + public bool has_start_zone { get; set; } + public bool has_svg_map { get; set; } + public bool is_dirt { get; set; } + public bool is_oval { get; set; } + public int lap_scoring { get; set; } + public double latitude { get; set; } + public string? location { get; set; } + public double longitude { get; set; } + public int max_cars { get; set; } + public bool night_lighting { get; set; } + public double nominal_lap_time { get; set; } + public int number_pitstalls { get; set; } + public string? opens { get; set; } + public int package_id { get; set; } + public int pit_road_speed_limit { get; set; } + public double price { get; set; } + public int priority { get; set; } + public bool purchasable { get; set; } + public int qualify_laps { get; set; } + public bool restart_on_left { get; set; } + public bool retired { get; set; } + public string? search_filters { get; set; } + public string? site_url { get; set; } + public int sku { get; set; } + public int solo_laps { get; set; } + public bool start_on_left { get; set; } + public bool supports_grip_compound { get; set; } + public bool tech_track { get; set; } + public string? time_zone { get; set; } + public double track_config_length { get; set; } + public string? track_dirpath { get; set; } + public int track_id { get; set; } + public string? track_name { get; set; } + + public TrackTypeImportModel[]? track_types { get; set; } +} diff --git a/src/iRLeagueApiCore.TrackImport/Models/TrackMapLayersModel.cs b/src/iRLeagueApiCore.TrackImport/Models/TrackMapLayersModel.cs new file mode 100644 index 00000000..ad510d57 --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/Models/TrackMapLayersModel.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; + +namespace iRLeagueApiCore.TrackImport.Models; + +public struct TrackMapLayersModel +{ + public string background { get; set; } + public string inactive { get; set; } + public string active { get; set; } + public string pitroad { get; set; } + [JsonPropertyName("start-finish")] + public string start_finish { get; set; } + public string turns { get; set; } +} diff --git a/src/iRLeagueApiCore.TrackImport/Models/TrackTypeImportModel.cs b/src/iRLeagueApiCore.TrackImport/Models/TrackTypeImportModel.cs new file mode 100644 index 00000000..c2fc61cd --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/Models/TrackTypeImportModel.cs @@ -0,0 +1,6 @@ +namespace iRLeagueApiCore.TrackImport.Models; + +public struct TrackTypeImportModel +{ + public string track_type { get; set; } +} diff --git a/src/iRLeagueApiCore.TrackImport/Service/TrackImportService.cs b/src/iRLeagueApiCore.TrackImport/Service/TrackImportService.cs new file mode 100644 index 00000000..8d3ae503 --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/Service/TrackImportService.cs @@ -0,0 +1,105 @@ +using iRLeagueApiCore.TrackImport.Models; +using System.Net.Http.Json; +using System.Security.Cryptography; +using System.Text; + +namespace iRLeagueApiCore.TrackImport.Service; + +public sealed class TrackImportService +{ + public const double m2km = 1.60934; + + private readonly HttpClient httpClient; + private const string AuthenticationUrl = "https://members-ng.iracing.com/auth"; + private const string GetTrackDataUrl = "https://members-ng.iracing.com/data/track/get"; + private const string GetTrackAssetsUrl = "https://members-ng.iracing.com/data/track/assets"; + + public TrackImportService(HttpClient httpClient) + { + this.httpClient = httpClient; + } + + public async Task Authenticate(string userName, string password, CancellationToken cancellationToken = default) + { + var data = new Dictionary() + { + { "email", userName }, + { "password", EncodePassword(userName, password) }, + }; + var content = new FormUrlEncodedContent(data); + var response = await httpClient.PostAsync(AuthenticationUrl, content, cancellationToken); + var result = await response.Content.ReadFromJsonAsync(); + if (result?.Authcode == null || result.Authcode == "0") + { + return false; + } + return true; + } + + public async Task> GetTracksData(CancellationToken cancellationToken = default) + { + var result = await httpClient.GetAsync(GetTrackDataUrl); + if (result.IsSuccessStatusCode == false) + { + throw new Exception($"Result was: {result.StatusCode}"); + } + var linkResponse = await result.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); + result = await httpClient.GetAsync(linkResponse.link); + if (result.IsSuccessStatusCode == false) + { + throw new Exception($"Result was: {result.StatusCode}"); + } + var data = await result.Content.ReadFromJsonAsync>(cancellationToken: cancellationToken); + return data!; + } + + public async Task> GetTrackAssets(CancellationToken cancellationToken = default) + { + var result = await httpClient.GetAsync(GetTrackAssetsUrl); + if (result.IsSuccessStatusCode == false) + { + throw new Exception($"Result was: {result.StatusCode}"); + } + var linkResponse = await result.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); + result = await httpClient.GetAsync(linkResponse.link); + if (result.IsSuccessStatusCode == false) + { + throw new Exception($"Result was: {result.StatusCode}"); + } + var data = await result.Content.ReadFromJsonAsync>(cancellationToken: cancellationToken); + return data!; + } + + public async Task LoadTrackSvgs(TrackAssetsModel trackAssets, CancellationToken cancellationToken = default) + { + var svgLayers = new TrackMapLayersModel + { + active = await GetSvg(trackAssets.track_map + trackAssets.track_map_layers.active, cancellationToken), + background = await GetSvg(trackAssets.track_map + trackAssets.track_map_layers.background, cancellationToken), + pitroad = await GetSvg(trackAssets.track_map + trackAssets.track_map_layers.pitroad, cancellationToken), + inactive = await GetSvg(trackAssets.track_map + trackAssets.track_map_layers.inactive, cancellationToken), + start_finish = await GetSvg(trackAssets.track_map + trackAssets.track_map_layers.start_finish, cancellationToken), + turns = await GetSvg(trackAssets.track_map + trackAssets.track_map_layers.turns, cancellationToken) + }; + + return svgLayers; + } + + private async Task GetSvg(string link, CancellationToken cancellationToken = default) + { + var result = await httpClient.GetAsync(link, cancellationToken); + if (result.IsSuccessStatusCode == false) + { + throw new Exception($"Result was: {result.StatusCode}"); + } + return await result.Content.ReadAsStringAsync(cancellationToken: cancellationToken); + } + + public static string EncodePassword(string username, string password) + { + var stringData = $"{password}{username.ToLower()}"; + var sha256 = SHA256.Create(); + byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(stringData)); + return Convert.ToBase64String(bytes); + } +} diff --git a/src/iRLeagueApiCore.TrackImport/ServiceCollectionExtensions.cs b/src/iRLeagueApiCore.TrackImport/ServiceCollectionExtensions.cs new file mode 100644 index 00000000..47ba9b47 --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/ServiceCollectionExtensions.cs @@ -0,0 +1,14 @@ +using iRLeagueApiCore.TrackImport.Service; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace Microsoft.Extensions.DependencyInjection; + +public static class ServiceCollectionExtensions +{ + public static IServiceCollection AddTrackImporter(this IServiceCollection services) + { + services.TryAddScoped(); + services.TryAddScoped(); + return services; + } +} diff --git a/src/iRLeagueApiCore.TrackImport/iRLeagueApiCore.TrackImport.csproj b/src/iRLeagueApiCore.TrackImport/iRLeagueApiCore.TrackImport.csproj new file mode 100644 index 00000000..98f13edc --- /dev/null +++ b/src/iRLeagueApiCore.TrackImport/iRLeagueApiCore.TrackImport.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + a73062ae-a983-4af3-992b-f0c6c4d3e4fc + + + + + + + diff --git a/src/iRLeagueDatabaseCore.Migrations/Program.cs b/src/iRLeagueDatabaseCore.Migrations/Program.cs new file mode 100644 index 00000000..1ab07e0a --- /dev/null +++ b/src/iRLeagueDatabaseCore.Migrations/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("This project is only used to hold the configuration for db migrations"); \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore.Migrations/iRLeagueDatabaseCore.Migrations.csproj b/src/iRLeagueDatabaseCore.Migrations/iRLeagueDatabaseCore.Migrations.csproj new file mode 100644 index 00000000..8542fe04 --- /dev/null +++ b/src/iRLeagueDatabaseCore.Migrations/iRLeagueDatabaseCore.Migrations.csproj @@ -0,0 +1,25 @@ + + + + Exe + net6.0 + enable + enable + f23d4706-a659-4985-a75c-b7b0c56ea10d + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + diff --git a/src/iRLeagueDatabaseCore/Converters/CollectionToStringConverter.cs b/src/iRLeagueDatabaseCore/Converters/CollectionToStringConverter.cs new file mode 100644 index 00000000..1681722e --- /dev/null +++ b/src/iRLeagueDatabaseCore/Converters/CollectionToStringConverter.cs @@ -0,0 +1,40 @@ +using System.Globalization; +using System.Linq.Expressions; + +namespace iRLeagueDatabaseCore.Converters; + +public class CollectionToStringConverter : ValueConverter, string> +{ + private const char defaultDelimiter = ';'; + + public CollectionToStringConverter(CultureInfo culture, char delimiter = ';') : + base(ConvertToString(delimiter, culture), ConvertToArray(delimiter, culture)) + { + } + + public CollectionToStringConverter() : this(CultureInfo.InvariantCulture, defaultDelimiter) + { + } + + public CollectionToStringConverter(char delimiter) : this(CultureInfo.InvariantCulture, delimiter) + { + } + + private static Expression, string>> ConvertToString(char delimiter, CultureInfo culture) => + array => string.Join(delimiter, array.Select(x => Convert.ToString(x, culture))); + + private static Expression>> ConvertToArray(char delimiter, CultureInfo culture) => + str => str.Split(delimiter, StringSplitOptions.RemoveEmptyEntries) + .Select(x => ChangeType(x, culture)) + .ToList(); + + private static T ChangeType(string value, CultureInfo culture) + { + if (typeof(T).IsEnum) + { + return (T)Enum.Parse(typeof(T), value); + } + + return (T)Convert.ChangeType(value, typeof(T), culture); + } +} diff --git a/src/iRLeagueDatabaseCore/Converters/DictionaryToStringConverter.cs b/src/iRLeagueDatabaseCore/Converters/DictionaryToStringConverter.cs new file mode 100644 index 00000000..d0c0a176 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Converters/DictionaryToStringConverter.cs @@ -0,0 +1,42 @@ +using System.Globalization; +using System.Linq.Expressions; + +namespace iRLeagueDatabaseCore.Converters; + +public class DictionaryToStringConverter : ValueConverter, string> +{ + private const char defaultPairDelimiter = ';'; + private const char defaultValueDelimiter = ':'; + + public DictionaryToStringConverter() : this(defaultPairDelimiter, defaultValueDelimiter) + { + } + + public DictionaryToStringConverter(CultureInfo culture, char pairDelimiter = ';', char valueDelimiter = ':') : + base(ConvertToString(pairDelimiter, valueDelimiter, culture), ConvertToDictionary(pairDelimiter, valueDelimiter, culture)) + { + } + + public DictionaryToStringConverter(char pairDelimiter = ';', char valueDelimiter = ':') : + this(CultureInfo.InvariantCulture, pairDelimiter, valueDelimiter) + { + } + + private static Expression, string>> ConvertToString(char pairDelimiter, char valueDelimiter, CultureInfo culture) => + dict => string.Join(pairDelimiter, dict + .Select(x => string.Join(valueDelimiter, Convert.ToString(x.Key, culture), Convert.ToString(x.Value, culture)))); + + private static Expression>> ConvertToDictionary(char pairDelimiter, char valueDelimiter, CultureInfo culture) => + str => str.Split(pairDelimiter, StringSplitOptions.RemoveEmptyEntries) + .Select(x => x.Split(valueDelimiter, StringSplitOptions.None)) + .ToDictionary(x => ChangeType(x[0], culture), x => ChangeType(x[1], culture)); + + private static T ChangeType(string value, CultureInfo culture) + { + if (typeof(T).IsEnum) + { + return (T)Enum.Parse(typeof(T), value); + } + return (T)Convert.ChangeType(value, typeof(T), culture); + } +} diff --git a/src/iRLeagueDatabaseCore/ILeagueDbContext.cs b/src/iRLeagueDatabaseCore/ILeagueDbContext.cs new file mode 100644 index 00000000..ee11f815 --- /dev/null +++ b/src/iRLeagueDatabaseCore/ILeagueDbContext.cs @@ -0,0 +1,43 @@ +namespace iRLeagueDatabaseCore.Models; + +public interface ILeagueDbContext +{ + public DbSet AcceptedReviewVotes { get; set; } + public DbSet AddPenaltys { get; set; } + public DbSet AutoPenaltyConfigs { get; set; } + public DbSet ReviewComments { get; set; } + public DbSet ReviewCommentVotes { get; set; } + public DbSet CustomIncidents { get; set; } + public DbSet Championships { get; set; } + public DbSet ChampSeasons { get; set; } + public DbSet DriverStatisticRows { get; set; } + public DbSet Events { get; set; } + public DbSet IncidentReviews { get; set; } + public DbSet Leagues { get; set; } + public DbSet Members { get; set; } + public DbSet LeagueMembers { get; set; } + public DbSet Payments { get; set; } + public DbSet PointRules { get; set; } + public DbSet Protests { get; set; } + public DbSet EventResults { get; set; } + public DbSet ResultConfigurations { get; set; } + public DbSet ResultRows { get; set; } + public DbSet FilterOptions { get; set; } + public DbSet ReviewPenaltys { get; set; } + public DbSet Schedules { get; set; } + public DbSet ScoredEventResults { get; set; } + public DbSet ScoredResultRows { get; set; } + public DbSet ScoredSessionResults { get; set; } + public DbSet Scorings { get; set; } + public DbSet Standings { get; set; } + public DbSet Seasons { get; set; } + public DbSet Sessions { get; set; } + public DbSet StatisticSets { get; set; } + public DbSet Subscriptions { get; set; } + public DbSet Teams { get; set; } + public DbSet VoteCategories { get; set; } + public DbSet TrackGroups { get; set; } + public DbSet IRSimSessionDetails { get; set; } + public DbSet TrackConfigs { get; set; } + public DbSet SessionResults { get; set; } +} \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/ILeagueProvider.cs b/src/iRLeagueDatabaseCore/ILeagueProvider.cs new file mode 100644 index 00000000..ef2a5ae4 --- /dev/null +++ b/src/iRLeagueDatabaseCore/ILeagueProvider.cs @@ -0,0 +1,9 @@ +namespace iRLeagueDatabaseCore; +public interface ILeagueProvider +{ + public long LeagueId { get; } + public bool HasLeagueName { get; } + public string LeagueName { get; } + + public void SetLeague(long leagueId, string leagueName = null); +} diff --git a/src/iRLeagueDatabaseCore/LeagueDbContext.cs b/src/iRLeagueDatabaseCore/LeagueDbContext.cs new file mode 100644 index 00000000..31626fcb --- /dev/null +++ b/src/iRLeagueDatabaseCore/LeagueDbContext.cs @@ -0,0 +1,157 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; + +namespace iRLeagueDatabaseCore.Models; + +public partial class LeagueDbContext : DbContext, ILeagueDbContext +{ + public ILeagueProvider LeagueProvider { get; init; } + + public LeagueDbContext(DbContextOptions options, ILeagueProvider leagueProvider) + : base(options) + { + LeagueProvider = leagueProvider; + } + + public virtual DbSet AcceptedReviewVotes { get; set; } + public virtual DbSet AddPenaltys { get; set; } + public virtual DbSet AutoPenaltyConfigs { get; set; } + public virtual DbSet ReviewComments { get; set; } + public virtual DbSet ReviewCommentVotes { get; set; } + public virtual DbSet CustomIncidents { get; set; } + public virtual DbSet Championships { get; set; } + public virtual DbSet ChampSeasons { get; set; } + public virtual DbSet DriverStatisticRows { get; set; } + public virtual DbSet Events { get; set; } + public virtual DbSet IncidentReviews { get; set; } + public virtual DbSet Leagues { get; set; } + public virtual DbSet Members { get; set; } + public virtual DbSet LeagueMembers { get; set; } + public virtual DbSet Payments { get; set; } + public virtual DbSet PointRules { get; set; } + public virtual DbSet Protests { get; set; } + public virtual DbSet EventResults { get; set; } + public virtual DbSet ResultConfigurations { get; set; } + public virtual DbSet ResultRows { get; set; } + public virtual DbSet FilterOptions { get; set; } + public virtual DbSet ReviewPenaltys { get; set; } + public virtual DbSet Schedules { get; set; } + public virtual DbSet ScoredEventResults { get; set; } + public virtual DbSet ScoredResultRows { get; set; } + public virtual DbSet ScoredSessionResults { get; set; } + public virtual DbSet Scorings { get; set; } + public virtual DbSet Standings { get; set; } + public virtual DbSet StandingConfigurations { get; set; } + public virtual DbSet Subscriptions { get; set; } + public virtual DbSet Seasons { get; set; } + public virtual DbSet Sessions { get; set; } + public virtual DbSet StatisticSets { get; set; } + public virtual DbSet Teams { get; set; } + public virtual DbSet VoteCategories { get; set; } + public virtual DbSet TrackGroups { get; set; } + public virtual DbSet IRSimSessionDetails { get; set; } + public virtual DbSet TrackConfigs { get; set; } + public virtual DbSet SessionResults { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.HasAnnotation("Relational:Collation", "Latin1_General_CI_AS"); + + modelBuilder.ApplyConfigurationsFromAssembly(typeof(LeagueDbContext).Assembly); + + OnModelCreatingPartial(modelBuilder); + + ConfigureMultiTenancy(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); + + private void ConfigureMultiTenancy(ModelBuilder builder) + { + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + builder.Entity() + .HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId); + } +} diff --git a/src/iRLeagueDatabaseCore/Migration.sql b/src/iRLeagueDatabaseCore/Migration.sql new file mode 100644 index 00000000..eb929043 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migration.sql @@ -0,0 +1,89 @@ +USE TestDatabase; + +START TRANSACTION; + +CREATE TEMPORARY TABLE TmpChampionships ( + LeagueId BIGINT NOT NULL, + ChampionshipId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + ResultConfigId BIGINT NOT NULL, + Name VARCHAR(80), + DisplayName VARCHAR(255), + Version INT DEFAULT 1 +); + +INSERT INTO TmpChampionships (LeagueId, ResultConfigId, Name, DisplayName) + SELECT LeagueId, ResultConfigId, Name, DisplayName + FROM ResultConfigurations; + +DELETE FROM Championships; + +INSERT INTO Championships (LeagueId, ChampionshipId, Name, DisplayName, Version) + SELECT LeagueId, ChampionshipId, Name, DisplayName, Version + FROM TmpChampionships; + +SELECT * FROM Championships; + +CREATE TEMPORARY TABLE TmpChampSeasons ( + LeagueId BIGINT NOT NULL, + ChampSeasonId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + ChampionshipId BIGINT NOT NULL, + SeasonId BIGINT NOT NULL, + StandingConfigId BIGINT +); + +INSERT INTO TmpChampSeasons (LeagueId, ChampionshipId, SeasonId, StandingConfigId) + SELECT c.LeagueId, c.ChampionshipId, sch.SeasonId, s.StandingConfigId + FROM ScoredEventResults AS er + JOIN Events AS ev + ON er.EventId=ev.EventId + JOIN Schedules AS sch + ON ev.ScheduleId=sch.ScheduleId + JOIN ResultConfigurations AS r + ON er.ResultConfigId=r.ResultConfigId + JOIN TmpChampionships AS c + ON r.ResultConfigId=c.ResultConfigId + JOIN StandingConfigs_ResultConfigs AS s_r + ON r.ResultConfigId=s_r.ResultConfigId + JOIN StandingConfigurations AS s + ON s_r.StandingConfigId=s.StandingConfigId + GROUP BY c.ChampionshipId, sch.SeasonId, s.StandingConfigId; + +INSERT INTO ChampSeasons + SELECT * FROM TmpChampSeasons; + +SELECT * FROM ChampSeasons; + +INSERT INTO ChampSeasons_ResultConfigs + SELECT cs.LeagueId, cs.ChampSeasonId, c.ResultConfigId + FROM TmpChampSeasons AS cs + JOIN TmpChampionships AS c + ON cs.ChampionshipId=c.ChampionshipId; + +SELECT * FROM ChampSeasons_ResultConfigs; + +UPDATE ScoredEventResults AS er + JOIN Events AS ev + ON er.EventId=ev.EventId + JOIN Schedules AS sch + ON ev.ScheduleId=sch.ScheduleId + JOIN ChampSeasons_ResultConfigs as cs_rc + ON er.ResultConfigId=cs_rc.ResultConfigId + JOIN ChampSeasons cs + ON cs_rc.ChampSeasonId=cs.ChampSeasonId + AND sch.SeasonId=cs.SeasonId + SET er.ChampSeasonId=cs.ChampSeasonId; + +SELECT LeagueId, EventId, ResultConfigId, ChampSeasonId + FROM ScoredEventResults; + +UPDATE Standings AS s + JOIN ChampSeasons AS cs + ON s.StandingConfigId=cs.StandingConfigId + SET s.ChampSeasonId=cs.ChampSeasonId; + +SELECT LeagueId, StandingConfigId, ChampSeasonId FROM Standings; + +DROP TABLE TmpChampionships; +DROP TABLE TmpChampSeasons; + +ROLLBACK; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/MigrationCarNumberAsString.sql b/src/iRLeagueDatabaseCore/MigrationCarNumberAsString.sql new file mode 100644 index 00000000..d083cbbf --- /dev/null +++ b/src/iRLeagueDatabaseCore/MigrationCarNumberAsString.sql @@ -0,0 +1,42 @@ +USE LeagueDatabase; + +START TRANSACTION; + +-- pre migration +-- safe the CarNumber values as ints + +CREATE TEMPORARY TABLE TmpResultRowsNumbers ( + ResultRowId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + CarNumber INT NOT NULL +); + +INSERT INTO TmpResultRowsNumbers (ResultRowId, CarNumber) + SELECT ResultRowId, CarNumber + FROM ResultRows; + +CREATE TEMPORARY TABLE TmpScoredResultRowsNumbers ( + ScoredResultRowId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + CarNumber INT NOT NULL +); + +INSERT INTO TmpScoredResultRowsNumbers (ScoredResultRowId, CarNumber) + SELECT ScoredResultRowId, CarNumber + FROM ScoredResultRows; + +-- post migration +-- restore CarNumber values as string + +UPDATE ResultRows `rows` + JOIN TmpResultRowsNumbers `numbers` + ON `numbers`.ResultRowId=`rows`.ResultRowId + SET `rows`.CarNumber = `numbers`.CarNumber; + +UPDATE ScoredResultRows `rows` + JOIN TmpScoredResultRowsNumbers `numbers` + ON `numbers`.ScoredResultRowId=`rows`.ScoredResultRowId + SET `rows`.CarNumber = `numbers`.CarNumber; + +DROP TABLE TmpResultRowsNumbers; +DROP TABLE TmpScoredResultRowsNumbers; + +ROLLBACK; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/MigrationChangeBonusPointColumnTypeToJson.sql b/src/iRLeagueDatabaseCore/MigrationChangeBonusPointColumnTypeToJson.sql new file mode 100644 index 00000000..b3f12890 --- /dev/null +++ b/src/iRLeagueDatabaseCore/MigrationChangeBonusPointColumnTypeToJson.sql @@ -0,0 +1,94 @@ +/* Migrate the filterOptionEntity used on ResultConfigs to use json column for Conditions + * instead of previous FilterConditionEntity + */ + +USE TestDatabase; + +SET autocommit=0; +START TRANSACTION; + +-- Pre migration +-- Create Temporary table holding the bonus points before changing column type +CREATE TEMPORARY TABLE TmpBonusPoints ( + LeagueId BIGINT NOT NULL, + PointRuleId BIGINT NOT NULL PRIMARY KEY, + BonusPoints TEXT +); + +INSERT INTO TmpBonusPoints (LeagueId, PointRuleId, BonusPoints) + SELECT LeagueId, PointRuleId, BonusPoints + FROM PointRules; + +UPDATE PointRules + SET BonusPoints='[]'; + +-- Post migration +-- Create function to convert bonus values from single string into json array +DELIMITER // + +DROP FUNCTION IF EXISTS splitStringToBonusPoints; + +CREATE FUNCTION splitStringToBonusPoints(inputString TEXT, + pointDelimiter TEXT) + RETURNS TEXT + DETERMINISTIC +BEGIN + DECLARE bonusType TEXT; + DECLARE bonusValue TEXT; + DECLARE bonusPoints TEXT; + SET bonusType = SUBSTRING_INDEX(inputString,pointDelimiter,1); + SET bonusPoints = SUBSTRING(SUBSTRING_INDEX(inputString,pointDelimiter,2), LENGTH(bonusType)+2, 10); + SET bonusValue = IF(LENGTH(bonusType)>1, SUBSTRING(bonusType, 2, 10), '0'); + SET bonusType = SUBSTRING(bonusType, 1, 1); + SET bonusType = CASE bonusType + WHEN 'p' THEN '0' + WHEN 'q' THEN '1' + WHEN 'f' THEN '2' + WHEN 'a' THEN '3' + WHEN 'c' THEN '4' + WHEN 'n' THEN '5' + WHEN 'g' THEN '6' + WHEN 'd' THEN '7' + WHEN 'l' THEN '8' + WHEN 'm' THEN '9' + END; + RETURN CONCAT('{"Type":',bonusType,',"Value":',bonusValue,',"Points":',bonusPoints,',"Conditions":[]}'); +END; + +DROP FUNCTION IF EXISTS splitToArray; + +CREATE FUNCTION splitToArray( + inputString TEXT, + arrayDelimiter TEXT, + pointDelimiter TEXT) + RETURNS TEXT + DETERMINISTIC +BEGIN + DECLARE tempString TEXT; + SET tempString = '['; + WHILE LOCATE(arrayDelimiter,inputString) > 1 DO + SET tempString = CONCAT(tempString, splitStringToBonusPoints(SUBSTRING_INDEX(inputString,arrayDelimiter,1), pointDelimiter), ','); + SET inputString = REGEXP_REPLACE(inputString, ( + SELECT LEFT(inputString, LOCATE(arrayDelimiter, inputString)) + ),'',1,1); + END WHILE; + SET tempString = CONCAT(tempString, splitStringToBonusPoints(SUBSTRING_INDEX(inputString,arrayDelimiter,1), pointDelimiter), ']'); + RETURN tempString; +END; // + +DELIMITER ; + +-- Populate `Conditions` column with stored values and perform necessary value conversions +UPDATE TmpBonusPoints + SET BonusPoints = splitToArray(BonusPoints, ';', ':'); +UPDATE PointRules AS pr + JOIN TmpBonusPoints AS tmp + ON tmp.PointRuleId=pr.PointRuleId + SET pr.BonusPoints = tmp.BonusPoints + WHERE tmp.BonusPoints IS NOT NULL; + +DROP TABLE TmpBonusPoints; +DROP FUNCTION splitToArray; +DROP FUNCTION splitStringToBonusPoints; + +ROLLBACK; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/MigrationFiltersForChampSeason.sql b/src/iRLeagueDatabaseCore/MigrationFiltersForChampSeason.sql new file mode 100644 index 00000000..9a4035db --- /dev/null +++ b/src/iRLeagueDatabaseCore/MigrationFiltersForChampSeason.sql @@ -0,0 +1,20 @@ +/* Migrate the filterOptionEntity used on ResultConfigs to use json column for Conditions + * instead of previous FilterConditionEntity + */ + +USE TestDatabase; + +START TRANSACTION; + +-- Populate `Conditions` column with stored values and perform necessary value conversions +UPDATE FilterOptions AS f + JOIN ResultConfigurations AS rc + ON rc.ResultConfigId=f.ResultFilterResultConfigId + JOIN ChampSeasons AS cs + ON cs.ChampSeasonId=rc.ChampSeasonId + JOIN Seasons AS s + ON cs.SeasonId=s.SeasonId + WHERE s.Finished=0 AND cs.IsActive + SET f.ChampSeasonId = rc.ChampSeasonId, f.ResultFilterResultConfigId=NULL; + +ROLLBACK; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/MigrationLeagueDbContextFactory.cs b/src/iRLeagueDatabaseCore/MigrationLeagueDbContextFactory.cs new file mode 100644 index 00000000..e22cc559 --- /dev/null +++ b/src/iRLeagueDatabaseCore/MigrationLeagueDbContextFactory.cs @@ -0,0 +1,20 @@ +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore.Design; +using Moq; + +namespace iRLeagueDatabaseCore; + +internal class MigrationLeagueDbContextFactory : IDesignTimeDbContextFactory +{ + public LeagueDbContext CreateDbContext(string[] args) + { + var connectionString = Environment.GetEnvironmentVariable("EFCORETOOLSDB") + ?? throw new InvalidOperationException("No connection string for migration provided. Please set $env:EFCORETOOLSDB"); + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseMySQL(connectionString); + var leagueProvider = Mock.Of(); + + var dbContext = new LeagueDbContext(optionsBuilder.Options, leagueProvider); + return dbContext; + } +} diff --git a/src/iRLeagueDatabaseCore/MigrationMoveResultKindToChampSeasonTable.sql b/src/iRLeagueDatabaseCore/MigrationMoveResultKindToChampSeasonTable.sql new file mode 100644 index 00000000..01a5c4c9 --- /dev/null +++ b/src/iRLeagueDatabaseCore/MigrationMoveResultKindToChampSeasonTable.sql @@ -0,0 +1,38 @@ +/* Migrate the filterOptionEntity used on ResultConfigs to use json column for Conditions + * instead of previous FilterConditionEntity + */ + +USE TestDatabase; + +START TRANSACTION; + +DROP TABLE IF EXISTS TmpResultConfigKinds; + +CREATE TEMPORARY TABLE TmpResultConfigKinds( + LeagueId BIGINT NOT NULL, + ResultConfigId BIGINT NOT NULL, + ChampSeasonId BIGINT NOT NULL, + ResultKind VARCHAR(50) NOT NULL, + PRIMARY KEY(LeagueId, ResultConfigId) +); + +INSERT INTO TmpResultConfigKinds(LeagueId, ResultConfigId, ChampSeasonId, ResultKind) + SELECT LeagueId, ResultConfigId, ChampSeasonId, ResultKind FROM ResultConfigurations; + +SELECT * FROM TmpResultConfigKinds; + +-- Populate `Conditions` column with stored values and perform necessary value conversions +UPDATE ChampSeasons AS cs + JOIN TmpResultConfigKinds as rc + ON cs.ChampSeasonId=rc.ChampSeasonId + SET cs.ResultKind=rc.ResultKind; + +UPDATE ChampSeasons + SET ResultKind='Member' + WHERE ResultKind=''; + +SELECT LeagueId, ChampSeasonId, ResultKind FROM ChampSeasons; + +DROP TABLE TmpResultConfigKinds; + +ROLLBACK; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/MigrationMultiplePenaltiesPerReview.sql b/src/iRLeagueDatabaseCore/MigrationMultiplePenaltiesPerReview.sql new file mode 100644 index 00000000..23d97756 --- /dev/null +++ b/src/iRLeagueDatabaseCore/MigrationMultiplePenaltiesPerReview.sql @@ -0,0 +1,42 @@ +/* Migrate existing PenaltyPoints of ReviewPenaltys table to new JsonColum values + * AddPenaltys has been dropped in the previous migration so no values need to be converted here + */ + +USE TestDatabase; + +START TRANSACTION; + +-- Pre migration +-- Copy data to temp table before dropping +CREATE TEMPORARY TABLE TmpReviewPenaltys( + LeagueId BIGINT NOT NULL, + ResultRowId BIGINT NOT NULL, + ReviewId BIGINT NOT NULL, + ReviewVoteId BIGINT NOT NULL, + `Value` JSON NULL, + PRIMARY KEY (LeagueId, ResultRowId, ReviewId, ReviewVoteId) +); + +INSERT INTO TmpReviewPenaltys + SELECT * FROM ReviewPenaltys; + +-- drop table and create new with corrct primary key +DROP TABLE ReviewPenaltys; +CREATE TABLE ReviewPenaltys( + LeagueId BIGINT NOT NULL, + ResultRowId BIGINT NOT NULL, + ReviewId BIGINT NOT NULL, + ReviewVoteId BIGINT NOT NULL, + `Value` JSON NULL, + PRIMARY KEY (LeagueId, ResultRowId, ReviewId, ReviewVoteId) +); +-- Handle creation of indexes and fk inside ef migration + +-- Post migration +-- Copy data into newly created table after creation of indexes and fk +INSERT INTO ReviewPenaltys + SELECT * FROM TmpReviewPenaltys + +DROP TABLE TmpReviewPenaltys; + +ROLLBACK; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/MigrationPenaltyValueJsonColumn.sql b/src/iRLeagueDatabaseCore/MigrationPenaltyValueJsonColumn.sql new file mode 100644 index 00000000..200cc2b9 --- /dev/null +++ b/src/iRLeagueDatabaseCore/MigrationPenaltyValueJsonColumn.sql @@ -0,0 +1,31 @@ +/* Migrate existing PenaltyPoints of ReviewPenaltys table to new JsonColum values + * AddPenaltys has been dropped in the previous migration so no values need to be converted here + */ + +USE TestDatabase; + +START TRANSACTION; + +-- Pre migration +-- Create Temporary table holding the pointValues +CREATE TEMPORARY TABLE TmpPenaltyPoints ( + LeagueId BIGINT NOT NULL, + ResultRowId BIGINT NOT NULL, + ReviewId BIGINT NOT NULL, + PenaltyPoints INT NOT NULL, + PRIMARY KEY (LeagueId, ResultRowId, ReviewId) +); + +INSERT INTO TmpPenaltyPoints (LeagueId, ResultRowId, ReviewId, PenaltyPoints) + SELECT LeagueId, ResultRowId, ReviewId, PenaltyPoints + FROM ReviewPenaltys; + +-- Post migration +UPDATE ReviewPenaltys AS rp + JOIN TmpPenaltyPoints AS tmp + ON rp.ResultRowId=tmp.ResultRowId AND rp.ReviewId=tmp.ReviewId + SET rp.`Value` = CONCAT('{\"Type\": 0, \"Points\": ', tmp.PenaltyPoints, '}'); + +DROP TABLE TmpPenaltyPoints; + +ROLLBACK; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/MigrationResultConfigsManyToOneChampSeaons.sql b/src/iRLeagueDatabaseCore/MigrationResultConfigsManyToOneChampSeaons.sql new file mode 100644 index 00000000..2e9a1325 --- /dev/null +++ b/src/iRLeagueDatabaseCore/MigrationResultConfigsManyToOneChampSeaons.sql @@ -0,0 +1,15 @@ +USE TestDatabase; + +START TRANSACTION; + +DELETE r FROM ResultConfigurations r + LEFT JOIN ChampSeasons_ResultConfigs cr + ON cr.ResultConfigId=r.ResultConfigId + WHERE cr.ChampSeasonId is NULL; + +UPDATE ResultConfigurations r + JOIN ChampSeasons_ResultConfigs cr + ON cr.ResultConfigId=r.ResultConfigId + SET r.ChampSeasonId=cr.ChampSeasonId; + +ROLLBACK; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/MigrationUseJsonFiltersOnResultConfig.sql b/src/iRLeagueDatabaseCore/MigrationUseJsonFiltersOnResultConfig.sql new file mode 100644 index 00000000..b0643c7d --- /dev/null +++ b/src/iRLeagueDatabaseCore/MigrationUseJsonFiltersOnResultConfig.sql @@ -0,0 +1,89 @@ +/* Migrate the filterOptionEntity used on ResultConfigs to use json column for Conditions + * instead of previous FilterConditionEntity + */ + +USE TestDatabase; + +START TRANSACTION; + +-- Pre migration +-- Create Temporary table holding the filter conditions before dropping table +CREATE TEMPORARY TABLE TmpFilterConditions ( + LeagueId BIGINT NOT NULL, + ConditionId BIGINT NOT NULL, + FilterOptionId BIGINT NOT NULL, + FilterType LONGTEXT NOT NULL, + ColumnPropertyName LONGTEXT NULL, + Comparator LONGTEXT NOT NULL, + `Action` LONGTEXT NOT NULL, + FilterValues LONGTEXT NULL, + PRIMARY KEY (LeagueId, ConditionId) +); + +INSERT INTO TmpFilterConditions (LeagueId, ConditionId, FilterOptionId, FilterType, ColumnPropertyName, Comparator, Action, FilterValues) + SELECT LeagueId, ConditionId, FilterOptionId, FilterType, ColumnPropertyName, Comparator, Action, FilterValues + FROM FilterConditions; + +-- Post migration +-- Create function to convert Filter values from single string into json array +DELIMITER // + +DROP FUNCTION IF EXISTS splitStringToJsonArray; + +CREATE FUNCTION splitStringToJsonArray( + inputString TEXT, + delimiterChar CHAR(1)) + RETURNS TEXT + DETERMINISTIC +BEGIN + DECLARE temp_string TEXT; + SET temp_string = '["'; + WHILE LOCATE(delimiterChar,inputString) > 1 DO + SET temp_string = CONCAT(temp_string, SUBSTRING_INDEX(inputString,delimiterChar,1), '","'); + SET inputString = REGEXP_REPLACE(inputString, ( + SELECT LEFT(inputString, LOCATE(delimiterChar, inputString)) + ),'',1,1); + END WHILE; + SET temp_string = CONCAT(temp_string, inputString, '"]'); + RETURN temp_string; +END; // + +DELIMITER ; + +-- Populate `Conditions` column with stored values and perform necessary value conversions +UPDATE FilterOptions AS f + JOIN (SELECT FilterOptionId, + CASE FilterType + WHEN 'ColumnProperty' THEN 0 + WHEN 'Member' THEN 1 + WHEN 'Team' THEN 2 + END AS FilterType, + ColumnPropertyName, + CASE Comparator + WHEN 'IsSmaller' THEN 0 + WHEN 'IsSmallerOrEqual' THEN 1 + WHEN 'IsEqual' THEN 2 + WHEN 'IsBiggerOrEqual' THEN 3 + WHEN 'IsBigger' THEN 4 + WHEN 'NotEqual' THEN 5 + WHEN 'InList' THEN 6 + WHEN 'ForEach' THEN 7 + END AS Comparator, + CASE `Action` + WHEN 'Keep' THEN 0 + WHEN 'Remove' THEN 1 + END AS `Action`, + FilterValues + FROM TmpFilterConditions) AS fc + ON fc.FilterOptionId = f.FilterOptionId + SET f.Conditions = CONCAT( + '[{"Action": ', fc.`Action`, + ', "Comparator": ', fc.Comparator, + ', "FilterType": ', fc.FilterType, + ', "FilterValues": ', splitStringToJsonArray(fc.FilterValues, ';'), + ', "ColumnPropertyName": "', fc.ColumnPropertyName, '"}]'); + +DROP TABLE TmpFilterConditions; +DROP FUNCTION splitStringToJsonArray; + +ROLLBACK; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/Migrations/20221213221059_InitialCreate.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20221213221059_InitialCreate.Designer.cs new file mode 100644 index 00000000..16346314 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20221213221059_InitialCreate.Designer.cs @@ -0,0 +1,3422 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20221213221059_InitialCreate")] + partial class InitialCreate + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.HasKey("ResultConfigId", "LeagueId", "StandingConfigId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("StandingConfigs_ResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany() + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultConfig"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20221213221059_InitialCreate.cs b/src/iRLeagueDatabaseCore/Migrations/20221213221059_InitialCreate.cs new file mode 100644 index 00000000..7961857e --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20221213221059_InitialCreate.cs @@ -0,0 +1,2268 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using MySql.EntityFrameworkCore.Metadata; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Leagues", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "varchar(85)", maxLength: 85, nullable: false), + NameFull = table.Column(type: "longtext", nullable: true), + CreatedOn = table.Column(type: "datetime(6)", nullable: true), + LastModifiedOn = table.Column(type: "datetime(6)", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Leagues", x => x.Id); + table.UniqueConstraint("AK_Leagues_Name", x => x.Name); + }); + + migrationBuilder.CreateTable( + name: "Members", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + Firstname = table.Column(type: "longtext", nullable: true), + Lastname = table.Column(type: "longtext", nullable: true), + IRacingId = table.Column(type: "longtext", nullable: true), + DanLisaId = table.Column(type: "longtext", nullable: true), + DiscordId = table.Column(type: "longtext", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Members", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "StandingConfigurations", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + StandingConfigId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "longtext", nullable: true), + ResultKind = table.Column(type: "int", nullable: false), + UseCombinedResult = table.Column(type: "tinyint(1)", nullable: false), + WeeksCounted = table.Column(type: "int", nullable: false), + CreatedOn = table.Column(type: "datetime(6)", nullable: true), + LastModifiedOn = table.Column(type: "datetime(6)", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_StandingConfigurations", x => new { x.LeagueId, x.StandingConfigId }); + table.UniqueConstraint("AK_StandingConfigurations_StandingConfigId", x => x.StandingConfigId); + }); + + migrationBuilder.CreateTable( + name: "TrackGroups", + columns: table => new + { + TrackGroupId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + TrackName = table.Column(type: "longtext", nullable: true), + Location = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TrackGroups", x => x.TrackGroupId); + }); + + migrationBuilder.CreateTable( + name: "CustomIncidents", + columns: table => new + { + IncidentId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + LeagueId = table.Column(type: "bigint", nullable: false), + Text = table.Column(type: "longtext", nullable: true), + Index = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CustomIncidents", x => new { x.LeagueId, x.IncidentId }); + table.UniqueConstraint("AK_CustomIncidents_IncidentId", x => x.IncidentId); + table.ForeignKey( + name: "FK_CustomIncidents_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "PointRules", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + PointRuleId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "longtext", nullable: true), + PointsPerPlace = table.Column(type: "longtext", nullable: true), + BonusPoints = table.Column(type: "longtext", nullable: true), + MaxPoints = table.Column(type: "int", nullable: false), + PointDropOff = table.Column(type: "int", nullable: false), + PointsSortOptions = table.Column(type: "longtext", nullable: true), + FinalSortOptions = table.Column(type: "longtext", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PointRules", x => new { x.LeagueId, x.PointRuleId }); + table.UniqueConstraint("AK_PointRules_PointRuleId", x => x.PointRuleId); + table.ForeignKey( + name: "FK_PointRules_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ResultConfigurations", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ResultConfigId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + SourceResultConfigId = table.Column(type: "bigint", nullable: true), + Name = table.Column(type: "longtext", nullable: true), + DisplayName = table.Column(type: "longtext", nullable: true), + ResultKind = table.Column(type: "longtext", nullable: false), + ResultsPerTeam = table.Column(type: "int", nullable: false), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ResultConfigurations", x => new { x.LeagueId, x.ResultConfigId }); + table.UniqueConstraint("AK_ResultConfigurations_ResultConfigId", x => x.ResultConfigId); + table.ForeignKey( + name: "FK_ResultConfigurations_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ResultConfigurations_ResultConfigurations_LeagueId_SourceRes~", + columns: x => new { x.LeagueId, x.SourceResultConfigId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }); + }); + + migrationBuilder.CreateTable( + name: "Teams", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + TeamId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "longtext", nullable: true), + Profile = table.Column(type: "longtext", nullable: true), + TeamColor = table.Column(type: "longtext", nullable: true), + TeamHomepage = table.Column(type: "longtext", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Teams", x => new { x.LeagueId, x.TeamId }); + table.UniqueConstraint("AK_Teams_TeamId", x => x.TeamId); + table.ForeignKey( + name: "FK_Teams_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "VoteCategories", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + CatId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + Text = table.Column(type: "longtext", nullable: true), + Index = table.Column(type: "int", nullable: false), + DefaultPenalty = table.Column(type: "int", nullable: false), + ImportId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_VoteCategories", x => new { x.LeagueId, x.CatId }); + table.UniqueConstraint("AK_VoteCategories_CatId", x => x.CatId); + table.ForeignKey( + name: "FK_VoteCategories_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TrackConfigs", + columns: table => new + { + TrackId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + TrackGroupId = table.Column(type: "bigint", nullable: false), + ConfigName = table.Column(type: "longtext", nullable: true), + LengthKm = table.Column(type: "double", nullable: false), + Turns = table.Column(type: "int", nullable: false), + ConfigType = table.Column(type: "longtext", nullable: false), + HasNightLighting = table.Column(type: "tinyint(1)", nullable: false), + LegacyTrackId = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TrackConfigs", x => x.TrackId); + table.ForeignKey( + name: "FK_TrackConfigs_TrackGroups_TrackGroupId", + column: x => x.TrackGroupId, + principalTable: "TrackGroups", + principalColumn: "TrackGroupId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "FilterOptions", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + FilterOptionId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + PointFilterResultConfigId = table.Column(type: "bigint", nullable: true), + ResultFilterResultConfigId = table.Column(type: "bigint", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_FilterOptions", x => new { x.LeagueId, x.FilterOptionId }); + table.UniqueConstraint("AK_FilterOptions_FilterOptionId", x => x.FilterOptionId); + table.ForeignKey( + name: "FK_FilterOptions_ResultConfigurations_LeagueId_PointFilterResul~", + columns: x => new { x.LeagueId, x.PointFilterResultConfigId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }); + table.ForeignKey( + name: "FK_FilterOptions_ResultConfigurations_LeagueId_ResultFilterResu~", + columns: x => new { x.LeagueId, x.ResultFilterResultConfigId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }); + }); + + migrationBuilder.CreateTable( + name: "StandingConfigs_ResultConfigs", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + StandingConfigId = table.Column(type: "bigint", nullable: false), + ResultConfigId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_StandingConfigs_ResultConfigs", x => new { x.ResultConfigId, x.LeagueId, x.StandingConfigId }); + table.ForeignKey( + name: "FK_StandingConfigs_ResultConfigs_ResultConfigurations_LeagueId_~", + columns: x => new { x.LeagueId, x.ResultConfigId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_StandingConfigs_ResultConfigs_StandingConfigurations_LeagueI~", + columns: x => new { x.LeagueId, x.StandingConfigId }, + principalTable: "StandingConfigurations", + principalColumns: new[] { "LeagueId", "StandingConfigId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "LeagueMembers", + columns: table => new + { + MemberId = table.Column(type: "bigint", nullable: false), + LeagueId = table.Column(type: "bigint", nullable: false), + TeamId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_LeagueMembers", x => new { x.LeagueId, x.MemberId }); + table.ForeignKey( + name: "FK_LeagueMembers_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_LeagueMembers_Members_MemberId", + column: x => x.MemberId, + principalTable: "Members", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_LeagueMembers_Teams_LeagueId_TeamId", + columns: x => new { x.LeagueId, x.TeamId }, + principalTable: "Teams", + principalColumns: new[] { "LeagueId", "TeamId" }); + }); + + migrationBuilder.CreateTable( + name: "FilterConditions", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ConditionId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + FilterOptionId = table.Column(type: "bigint", nullable: false), + FilterType = table.Column(type: "longtext", nullable: false), + ColumnPropertyName = table.Column(type: "longtext", nullable: true), + Comparator = table.Column(type: "longtext", nullable: false), + Action = table.Column(type: "longtext", nullable: false), + FilterValues = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_FilterConditions", x => new { x.LeagueId, x.ConditionId }); + table.UniqueConstraint("AK_FilterConditions_ConditionId", x => x.ConditionId); + table.ForeignKey( + name: "FK_FilterConditions_FilterOptions_LeagueId_FilterOptionId", + columns: x => new { x.LeagueId, x.FilterOptionId }, + principalTable: "FilterOptions", + principalColumns: new[] { "LeagueId", "FilterOptionId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AcceptedReviewVotes", + columns: table => new + { + ReviewVoteId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + LeagueId = table.Column(type: "bigint", nullable: false), + ReviewId = table.Column(type: "bigint", nullable: false), + MemberAtFaultId = table.Column(type: "bigint", nullable: true), + VoteCategoryId = table.Column(type: "bigint", nullable: true), + Description = table.Column(type: "longtext", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AcceptedReviewVotes", x => new { x.LeagueId, x.ReviewVoteId }); + table.UniqueConstraint("AK_AcceptedReviewVotes_ReviewVoteId", x => x.ReviewVoteId); + table.ForeignKey( + name: "FK_AcceptedReviewVotes_Members_MemberAtFaultId", + column: x => x.MemberAtFaultId, + principalTable: "Members", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_AcceptedReviewVotes_VoteCategories_LeagueId_VoteCategoryId", + columns: x => new { x.LeagueId, x.VoteCategoryId }, + principalTable: "VoteCategories", + principalColumns: new[] { "LeagueId", "CatId" }); + }); + + migrationBuilder.CreateTable( + name: "AddPenaltys", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ScoredResultRowId = table.Column(type: "bigint", nullable: false), + PenaltyPoints = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AddPenaltys", x => new { x.LeagueId, x.ScoredResultRowId }); + }); + + migrationBuilder.CreateTable( + name: "DriverStatisticRows", + columns: table => new + { + StatisticSetId = table.Column(type: "bigint", nullable: false), + LeagueId = table.Column(type: "bigint", nullable: false), + MemberId = table.Column(type: "bigint", nullable: false), + FirstResultRowId = table.Column(type: "bigint", nullable: true), + LastResultRowId = table.Column(type: "bigint", nullable: true), + StartIRating = table.Column(type: "int", nullable: false), + EndIRating = table.Column(type: "int", nullable: false), + StartSRating = table.Column(type: "double", nullable: false), + EndSRating = table.Column(type: "double", nullable: false), + FirstSessionId = table.Column(type: "bigint", nullable: true), + FirstSessionDate = table.Column(type: "datetime", nullable: true), + FirstRaceId = table.Column(type: "bigint", nullable: true), + FirstRaceDate = table.Column(type: "datetime", nullable: true), + LastSessionId = table.Column(type: "bigint", nullable: true), + LastSessionDate = table.Column(type: "datetime", nullable: true), + LastRaceId = table.Column(type: "bigint", nullable: true), + LastRaceDate = table.Column(type: "datetime", nullable: true), + RacePoints = table.Column(type: "double", nullable: false), + TotalPoints = table.Column(type: "double", nullable: false), + BonusPoints = table.Column(type: "double", nullable: false), + Races = table.Column(type: "int", nullable: false), + Wins = table.Column(type: "int", nullable: false), + Poles = table.Column(type: "int", nullable: false), + Top3 = table.Column(type: "int", nullable: false), + Top5 = table.Column(type: "int", nullable: false), + Top10 = table.Column(type: "int", nullable: false), + Top15 = table.Column(type: "int", nullable: false), + Top20 = table.Column(type: "int", nullable: false), + Top25 = table.Column(type: "int", nullable: false), + RacesInPoints = table.Column(type: "int", nullable: false), + RacesCompleted = table.Column(type: "int", nullable: false), + Incidents = table.Column(type: "double", nullable: false), + PenaltyPoints = table.Column(type: "double", nullable: false), + FastestLaps = table.Column(type: "int", nullable: false), + IncidentsUnderInvestigation = table.Column(type: "int", nullable: false), + IncidentsWithPenalty = table.Column(type: "int", nullable: false), + LeadingLaps = table.Column(type: "double", nullable: false), + CompletedLaps = table.Column(type: "double", nullable: false), + CurrentSeasonPosition = table.Column(type: "int", nullable: false), + DrivenKm = table.Column(type: "double", nullable: false), + LeadingKm = table.Column(type: "double", nullable: false), + AvgFinishPosition = table.Column(type: "double", nullable: false), + AvgFinalPosition = table.Column(type: "double", nullable: false), + AvgStartPosition = table.Column(type: "double", nullable: false), + AvgPointsPerRace = table.Column(type: "double", nullable: false), + AvgIncidentsPerRace = table.Column(type: "double", nullable: false), + AvgIncidentsPerLap = table.Column(type: "double", nullable: false), + AvgIncidentsPerKm = table.Column(type: "double", nullable: false), + AvgPenaltyPointsPerRace = table.Column(type: "double", nullable: false), + AvgPenaltyPointsPerLap = table.Column(type: "double", nullable: false), + AvgPenaltyPointsPerKm = table.Column(type: "double", nullable: false), + AvgIRating = table.Column(type: "double", nullable: false), + AvgSRating = table.Column(type: "double", nullable: false), + BestFinishPosition = table.Column(type: "double", nullable: false), + WorstFinishPosition = table.Column(type: "double", nullable: false), + FirstRaceFinishPosition = table.Column(type: "double", nullable: false), + LastRaceFinishPosition = table.Column(type: "double", nullable: false), + BestFinalPosition = table.Column(type: "int", nullable: false), + WorstFinalPosition = table.Column(type: "int", nullable: false), + FirstRaceFinalPosition = table.Column(type: "int", nullable: false), + LastRaceFinalPosition = table.Column(type: "int", nullable: false), + BestStartPosition = table.Column(type: "double", nullable: false), + WorstStartPosition = table.Column(type: "double", nullable: false), + FirstRaceStartPosition = table.Column(type: "double", nullable: false), + LastRaceStartPosition = table.Column(type: "double", nullable: false), + Titles = table.Column(type: "int", nullable: false), + HardChargerAwards = table.Column(type: "int", nullable: false), + CleanestDriverAwards = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DriverStatisticRows", x => new { x.LeagueId, x.StatisticSetId, x.MemberId }); + table.ForeignKey( + name: "FK_DriverStatisticRows_Members_MemberId", + column: x => x.MemberId, + principalTable: "Members", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "EventResultConfigs", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + EventRefId = table.Column(type: "bigint", nullable: false), + ResultConfigRefId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EventResultConfigs", x => new { x.EventRefId, x.LeagueId, x.ResultConfigRefId }); + table.ForeignKey( + name: "FK_EventResultConfigs_ResultConfigurations_LeagueId_ResultConfi~", + columns: x => new { x.LeagueId, x.ResultConfigRefId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "EventResults", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + EventId = table.Column(type: "bigint", nullable: false), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true), + RequiresRecalculation = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EventResults", x => new { x.LeagueId, x.EventId }); + }); + + migrationBuilder.CreateTable( + name: "Events", + columns: table => new + { + EventId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + LeagueId = table.Column(type: "bigint", nullable: false), + ScheduleId = table.Column(type: "bigint", nullable: false), + TrackId = table.Column(type: "bigint", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true), + EventType = table.Column(type: "longtext", nullable: false), + Date = table.Column(type: "datetime", nullable: true), + Duration = table.Column(type: "bigint", nullable: false), + Name = table.Column(type: "longtext", nullable: true), + IrSessionId = table.Column(type: "longtext", nullable: true), + IrResultLink = table.Column(type: "longtext", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Events", x => new { x.LeagueId, x.EventId }); + table.UniqueConstraint("AK_Events_EventId", x => x.EventId); + table.ForeignKey( + name: "FK_Events_TrackConfigs_TrackId", + column: x => x.TrackId, + principalTable: "TrackConfigs", + principalColumn: "TrackId", + onDelete: ReferentialAction.SetNull); + }); + + migrationBuilder.CreateTable( + name: "IRSimSessionDetails", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + SessionDetailsId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + EventId = table.Column(type: "bigint", nullable: false), + IRSubsessionId = table.Column(type: "bigint", nullable: false), + IRSeasonId = table.Column(type: "bigint", nullable: false), + IRSeasonName = table.Column(type: "longtext", nullable: true), + IRSeasonYear = table.Column(type: "int", nullable: false), + IRSeasonQuarter = table.Column(type: "int", nullable: false), + IRRaceWeek = table.Column(type: "int", nullable: false), + IRSessionId = table.Column(type: "bigint", nullable: false), + LicenseCategory = table.Column(type: "int", nullable: false), + SessionName = table.Column(type: "longtext", nullable: true), + StartTime = table.Column(type: "datetime", nullable: true), + EndTime = table.Column(type: "datetime", nullable: true), + CornersPerLap = table.Column(type: "int", nullable: false), + KmDistPerLap = table.Column(type: "double", nullable: false), + MaxWeeks = table.Column(type: "int", nullable: false), + EventStrengthOfField = table.Column(type: "int", nullable: false), + EventAverageLap = table.Column(type: "bigint", nullable: false), + EventLapsComplete = table.Column(type: "int", nullable: false), + NumCautions = table.Column(type: "int", nullable: false), + NumCautionLaps = table.Column(type: "int", nullable: false), + NumLeadChanges = table.Column(type: "int", nullable: false), + TimeOfDay = table.Column(type: "int", nullable: false), + DamageModel = table.Column(type: "int", nullable: false), + IRTrackId = table.Column(type: "int", nullable: false), + TrackName = table.Column(type: "longtext", nullable: true), + ConfigName = table.Column(type: "longtext", nullable: true), + TrackCategoryId = table.Column(type: "int", nullable: false), + Category = table.Column(type: "longtext", nullable: true), + WeatherType = table.Column(type: "int", nullable: false), + TempUnits = table.Column(type: "int", nullable: false), + TempValue = table.Column(type: "int", nullable: false), + RelHumidity = table.Column(type: "int", nullable: false), + Fog = table.Column(type: "int", nullable: false), + WindDir = table.Column(type: "int", nullable: false), + WindUnits = table.Column(type: "int", nullable: false), + Skies = table.Column(type: "int", nullable: false), + WeatherVarInitial = table.Column(type: "int", nullable: false), + WeatherVarOngoing = table.Column(type: "int", nullable: false), + SimStartUtcTime = table.Column(type: "datetime", nullable: true), + SimStartUtcOffset = table.Column(type: "bigint", nullable: false), + LeaveMarbles = table.Column(type: "tinyint(1)", nullable: false), + PracticeRubber = table.Column(type: "int", nullable: false), + QualifyRubber = table.Column(type: "int", nullable: false), + WarmupRubber = table.Column(type: "int", nullable: false), + RaceRubber = table.Column(type: "int", nullable: false), + PracticeGripCompound = table.Column(type: "int", nullable: false), + QualifyGripCompund = table.Column(type: "int", nullable: false), + WarmupGripCompound = table.Column(type: "int", nullable: false), + RaceGripCompound = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IRSimSessionDetails", x => new { x.LeagueId, x.SessionDetailsId }); + table.UniqueConstraint("AK_IRSimSessionDetails_SessionDetailsId", x => x.SessionDetailsId); + table.ForeignKey( + name: "FK_IRSimSessionDetails_Events_LeagueId_EventId", + columns: x => new { x.LeagueId, x.EventId }, + principalTable: "Events", + principalColumns: new[] { "LeagueId", "EventId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ScoredEventResults", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ResultId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + EventId = table.Column(type: "bigint", nullable: false), + ResultConfigId = table.Column(type: "bigint", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true), + Name = table.Column(type: "longtext", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true), + EventResultEntityEventId = table.Column(type: "bigint", nullable: true), + EventResultEntityLeagueId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ScoredEventResults", x => new { x.LeagueId, x.ResultId }); + table.UniqueConstraint("AK_ScoredEventResults_ResultId", x => x.ResultId); + table.ForeignKey( + name: "FK_ScoredEventResults_EventResults_EventResultEntityLeagueId_Ev~", + columns: x => new { x.EventResultEntityLeagueId, x.EventResultEntityEventId }, + principalTable: "EventResults", + principalColumns: new[] { "LeagueId", "EventId" }); + table.ForeignKey( + name: "FK_ScoredEventResults_Events_LeagueId_EventId", + columns: x => new { x.LeagueId, x.EventId }, + principalTable: "Events", + principalColumns: new[] { "LeagueId", "EventId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ScoredEventResults_ResultConfigurations_LeagueId_ResultConfi~", + columns: x => new { x.LeagueId, x.ResultConfigId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }); + }); + + migrationBuilder.CreateTable( + name: "Sessions", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + SessionId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + EventId = table.Column(type: "bigint", nullable: false), + SessionNr = table.Column(type: "int", nullable: false), + Name = table.Column(type: "longtext", nullable: true), + SessionType = table.Column(type: "longtext", nullable: false), + StartOffset = table.Column(type: "bigint", nullable: false), + Duration = table.Column(type: "bigint", nullable: false), + Laps = table.Column(type: "int", nullable: false), + ImportId = table.Column(type: "bigint", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Sessions", x => new { x.LeagueId, x.SessionId }); + table.UniqueConstraint("AK_Sessions_SessionId", x => x.SessionId); + table.ForeignKey( + name: "FK_Sessions_Events_LeagueId_EventId", + columns: x => new { x.LeagueId, x.EventId }, + principalTable: "Events", + principalColumns: new[] { "LeagueId", "EventId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IncidentReviews", + columns: table => new + { + ReviewId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + LeagueId = table.Column(type: "bigint", nullable: false), + SessionId = table.Column(type: "bigint", nullable: false), + AuthorUserId = table.Column(type: "longtext", nullable: true), + AuthorName = table.Column(type: "longtext", nullable: true), + IncidentKind = table.Column(type: "longtext", nullable: true), + FullDescription = table.Column(type: "longtext", nullable: true), + OnLap = table.Column(type: "longtext", nullable: true), + Corner = table.Column(type: "longtext", nullable: true), + TimeStamp = table.Column(type: "bigint", nullable: false), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true), + ResultLongText = table.Column(type: "longtext", nullable: true), + IncidentNr = table.Column(type: "longtext", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IncidentReviews", x => new { x.LeagueId, x.ReviewId }); + table.UniqueConstraint("AK_IncidentReviews_ReviewId", x => x.ReviewId); + table.ForeignKey( + name: "FK_IncidentReviews_Sessions_LeagueId_SessionId", + columns: x => new { x.LeagueId, x.SessionId }, + principalTable: "Sessions", + principalColumns: new[] { "LeagueId", "SessionId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SessionResults", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + SessionId = table.Column(type: "bigint", nullable: false), + EventId = table.Column(type: "bigint", nullable: false), + IRSimSessionDetailsId = table.Column(type: "bigint", nullable: true), + SimSessionType = table.Column(type: "int", nullable: false), + CreatedOn = table.Column(type: "datetime(6)", nullable: true), + LastModifiedOn = table.Column(type: "datetime(6)", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SessionResults", x => new { x.LeagueId, x.SessionId }); + table.ForeignKey( + name: "FK_SessionResults_EventResults_LeagueId_EventId", + columns: x => new { x.LeagueId, x.EventId }, + principalTable: "EventResults", + principalColumns: new[] { "LeagueId", "EventId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_SessionResults_IRSimSessionDetails_LeagueId_IRSimSessionDeta~", + columns: x => new { x.LeagueId, x.IRSimSessionDetailsId }, + principalTable: "IRSimSessionDetails", + principalColumns: new[] { "LeagueId", "SessionDetailsId" }); + table.ForeignKey( + name: "FK_SessionResults_Sessions_LeagueId_SessionId", + columns: x => new { x.LeagueId, x.SessionId }, + principalTable: "Sessions", + principalColumns: new[] { "LeagueId", "SessionId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IncidentReviewsInvolvedMembers", + columns: table => new + { + InvolvedMembersId = table.Column(type: "bigint", nullable: false), + InvolvedReviewsLeagueId = table.Column(type: "bigint", nullable: false), + InvolvedReviewsReviewId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IncidentReviewsInvolvedMembers", x => new { x.InvolvedMembersId, x.InvolvedReviewsLeagueId, x.InvolvedReviewsReviewId }); + table.ForeignKey( + name: "FK_IncidentReviewsInvolvedMembers_IncidentReviews_InvolvedRevie~", + columns: x => new { x.InvolvedReviewsLeagueId, x.InvolvedReviewsReviewId }, + principalTable: "IncidentReviews", + principalColumns: new[] { "LeagueId", "ReviewId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_IncidentReviewsInvolvedMembers_Members_InvolvedMembersId", + column: x => x.InvolvedMembersId, + principalTable: "Members", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ReviewComments", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + CommentId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + ReviewId = table.Column(type: "bigint", nullable: true), + ReplyToCommentId = table.Column(type: "bigint", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true), + Date = table.Column(type: "datetime", nullable: true), + AuthorUserId = table.Column(type: "longtext", nullable: true), + AuthorName = table.Column(type: "longtext", nullable: true), + Text = table.Column(type: "longtext", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ReviewComments", x => new { x.LeagueId, x.CommentId }); + table.UniqueConstraint("AK_ReviewComments_CommentId", x => x.CommentId); + table.ForeignKey( + name: "FK_ReviewComments_IncidentReviews_LeagueId_ReviewId", + columns: x => new { x.LeagueId, x.ReviewId }, + principalTable: "IncidentReviews", + principalColumns: new[] { "LeagueId", "ReviewId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ReviewComments_ReviewComments_LeagueId_ReplyToCommentId", + columns: x => new { x.LeagueId, x.ReplyToCommentId }, + principalTable: "ReviewComments", + principalColumns: new[] { "LeagueId", "CommentId" }); + }); + + migrationBuilder.CreateTable( + name: "ResultRows", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ResultRowId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + SubSessionId = table.Column(type: "bigint", nullable: false), + MemberId = table.Column(type: "bigint", nullable: false), + TeamId = table.Column(type: "bigint", nullable: true), + PointsEligible = table.Column(type: "tinyint(1)", nullable: false), + StartPosition = table.Column(type: "double", nullable: false), + FinishPosition = table.Column(type: "double", nullable: false), + CarNumber = table.Column(type: "int", nullable: false), + ClassId = table.Column(type: "int", nullable: false), + Car = table.Column(type: "longtext", nullable: true), + CarClass = table.Column(type: "longtext", nullable: true), + CompletedLaps = table.Column(type: "double", nullable: false), + LeadLaps = table.Column(type: "double", nullable: false), + FastLapNr = table.Column(type: "int", nullable: false), + Incidents = table.Column(type: "double", nullable: false), + Status = table.Column(type: "int", nullable: false), + QualifyingTime = table.Column(type: "bigint", nullable: false), + Interval = table.Column(type: "bigint", nullable: false), + AvgLapTime = table.Column(type: "bigint", nullable: false), + FastestLapTime = table.Column(type: "bigint", nullable: false), + PositionChange = table.Column(type: "double", nullable: false), + IRacingId = table.Column(type: "longtext", nullable: true), + SimSessionType = table.Column(type: "int", nullable: false), + OldIRating = table.Column(type: "int", nullable: false), + NewIRating = table.Column(type: "int", nullable: false), + SeasonStartIRating = table.Column(type: "int", nullable: false), + License = table.Column(type: "longtext", nullable: true), + OldSafetyRating = table.Column(type: "double", nullable: false), + NewSafetyRating = table.Column(type: "double", nullable: false), + OldCpi = table.Column(type: "int", nullable: false), + NewCpi = table.Column(type: "int", nullable: false), + ClubId = table.Column(type: "int", nullable: false), + ClubName = table.Column(type: "longtext", nullable: true), + CarId = table.Column(type: "int", nullable: false), + CompletedPct = table.Column(type: "double", nullable: false), + QualifyingTimeAt = table.Column(type: "datetime", nullable: true), + Division = table.Column(type: "int", nullable: false), + OldLicenseLevel = table.Column(type: "int", nullable: false), + NewLicenseLevel = table.Column(type: "int", nullable: false), + NumPitStops = table.Column(type: "int", nullable: false), + PittedLaps = table.Column(type: "longtext", nullable: true), + NumOfftrackLaps = table.Column(type: "int", nullable: false), + OfftrackLaps = table.Column(type: "longtext", nullable: true), + NumContactLaps = table.Column(type: "int", nullable: false), + ContactLaps = table.Column(type: "longtext", nullable: true), + RacePoints = table.Column(type: "double", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ResultRows", x => new { x.LeagueId, x.ResultRowId }); + table.UniqueConstraint("AK_ResultRows_ResultRowId", x => x.ResultRowId); + table.ForeignKey( + name: "FK_ResultRows_LeagueMembers_LeagueId_MemberId", + columns: x => new { x.LeagueId, x.MemberId }, + principalTable: "LeagueMembers", + principalColumns: new[] { "LeagueId", "MemberId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ResultRows_Members_MemberId", + column: x => x.MemberId, + principalTable: "Members", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_ResultRows_SessionResults_LeagueId_SubSessionId", + columns: x => new { x.LeagueId, x.SubSessionId }, + principalTable: "SessionResults", + principalColumns: new[] { "LeagueId", "SessionId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ResultRows_Teams_LeagueId_TeamId", + columns: x => new { x.LeagueId, x.TeamId }, + principalTable: "Teams", + principalColumns: new[] { "LeagueId", "TeamId" }); + }); + + migrationBuilder.CreateTable( + name: "ReviewCommentVotes", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ReviewVoteId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + CommentId = table.Column(type: "bigint", nullable: false), + MemberAtFaultId = table.Column(type: "bigint", nullable: true), + VoteCategoryId = table.Column(type: "bigint", nullable: true), + Description = table.Column(type: "longtext", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ReviewCommentVotes", x => new { x.LeagueId, x.ReviewVoteId }); + table.UniqueConstraint("AK_ReviewCommentVotes_ReviewVoteId", x => x.ReviewVoteId); + table.ForeignKey( + name: "FK_ReviewCommentVotes_Members_MemberAtFaultId", + column: x => x.MemberAtFaultId, + principalTable: "Members", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_ReviewCommentVotes_ReviewComments_LeagueId_CommentId", + columns: x => new { x.LeagueId, x.CommentId }, + principalTable: "ReviewComments", + principalColumns: new[] { "LeagueId", "CommentId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ReviewCommentVotes_VoteCategories_LeagueId_VoteCategoryId", + columns: x => new { x.LeagueId, x.VoteCategoryId }, + principalTable: "VoteCategories", + principalColumns: new[] { "LeagueId", "CatId" }); + }); + + migrationBuilder.CreateTable( + name: "LeagueStatisticSetsStatisticSets", + columns: table => new + { + DependendStatisticSetsLeagueId = table.Column(type: "bigint", nullable: false), + DependendStatisticSetsId = table.Column(type: "bigint", nullable: false), + LeagueStatisticSetsLeagueId = table.Column(type: "bigint", nullable: false), + LeagueStatisticSetsId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_LeagueStatisticSetsStatisticSets", x => new { x.DependendStatisticSetsLeagueId, x.DependendStatisticSetsId, x.LeagueStatisticSetsLeagueId, x.LeagueStatisticSetsId }); + }); + + migrationBuilder.CreateTable( + name: "ReviewPenaltys", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ResultRowId = table.Column(type: "bigint", nullable: false), + ReviewId = table.Column(type: "bigint", nullable: false), + PenaltyPoints = table.Column(type: "int", nullable: false), + ReviewVoteId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ReviewPenaltys", x => new { x.LeagueId, x.ResultRowId, x.ReviewId }); + table.ForeignKey( + name: "FK_ReviewPenaltys_AcceptedReviewVotes_LeagueId_ReviewVoteId", + columns: x => new { x.LeagueId, x.ReviewVoteId }, + principalTable: "AcceptedReviewVotes", + principalColumns: new[] { "LeagueId", "ReviewVoteId" }); + table.ForeignKey( + name: "FK_ReviewPenaltys_IncidentReviews_LeagueId_ReviewId", + columns: x => new { x.LeagueId, x.ReviewId }, + principalTable: "IncidentReviews", + principalColumns: new[] { "LeagueId", "ReviewId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Schedules", + columns: table => new + { + ScheduleId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + LeagueId = table.Column(type: "bigint", nullable: false), + Name = table.Column(type: "longtext", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true), + SeasonId = table.Column(type: "bigint", nullable: false), + ImportId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Schedules", x => new { x.LeagueId, x.ScheduleId }); + table.UniqueConstraint("AK_Schedules_ScheduleId", x => x.ScheduleId); + }); + + migrationBuilder.CreateTable( + name: "Scorings", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ScoringId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + ResultConfigId = table.Column(type: "bigint", nullable: false), + PointsRuleId = table.Column(type: "bigint", nullable: true), + Index = table.Column(type: "int", nullable: false), + Name = table.Column(type: "longtext", nullable: true), + MaxResultsPerGroup = table.Column(type: "int", nullable: false), + ExtScoringSourceId = table.Column(type: "bigint", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true), + UseResultSetTeam = table.Column(type: "tinyint(1)", nullable: false), + UpdateTeamOnRecalculation = table.Column(type: "tinyint(1)", nullable: false), + ShowResults = table.Column(type: "tinyint(1)", nullable: false), + IsCombinedResult = table.Column(type: "tinyint(1)", nullable: false), + ScheduleEntityLeagueId = table.Column(type: "bigint", nullable: true), + ScheduleEntityScheduleId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Scorings", x => new { x.LeagueId, x.ScoringId }); + table.UniqueConstraint("AK_Scorings_ScoringId", x => x.ScoringId); + table.ForeignKey( + name: "FK_Scorings_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Scorings_PointRules_LeagueId_PointsRuleId", + columns: x => new { x.LeagueId, x.PointsRuleId }, + principalTable: "PointRules", + principalColumns: new[] { "LeagueId", "PointRuleId" }); + table.ForeignKey( + name: "FK_Scorings_ResultConfigurations_LeagueId_ResultConfigId", + columns: x => new { x.LeagueId, x.ResultConfigId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Scorings_Schedules_ScheduleEntityLeagueId_ScheduleEntitySche~", + columns: x => new { x.ScheduleEntityLeagueId, x.ScheduleEntityScheduleId }, + principalTable: "Schedules", + principalColumns: new[] { "LeagueId", "ScheduleId" }); + table.ForeignKey( + name: "FK_Scorings_Scorings_LeagueId_ExtScoringSourceId", + columns: x => new { x.LeagueId, x.ExtScoringSourceId }, + principalTable: "Scorings", + principalColumns: new[] { "LeagueId", "ScoringId" }); + }); + + migrationBuilder.CreateTable( + name: "ScoredSessionResults", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + SessionResultId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + ResultId = table.Column(type: "bigint", nullable: false), + ScoringId = table.Column(type: "bigint", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true), + SessionNr = table.Column(type: "int", nullable: false), + Name = table.Column(type: "longtext", nullable: true), + FastestLap = table.Column(type: "bigint", nullable: false), + FastestQualyLap = table.Column(type: "bigint", nullable: false), + FastestAvgLap = table.Column(type: "bigint", nullable: false), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true), + Discriminator = table.Column(type: "longtext", nullable: true), + FastestAvgLapDriverMemberId = table.Column(type: "bigint", nullable: true), + FastestLapDriverMemberId = table.Column(type: "bigint", nullable: true), + FastestQualyLapDriverMemberId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ScoredSessionResults", x => new { x.LeagueId, x.SessionResultId }); + table.UniqueConstraint("AK_ScoredSessionResults_SessionResultId", x => x.SessionResultId); + table.ForeignKey( + name: "FK_ScoredSessionResults_Members_FastestAvgLapDriverMemberId", + column: x => x.FastestAvgLapDriverMemberId, + principalTable: "Members", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_ScoredSessionResults_Members_FastestLapDriverMemberId", + column: x => x.FastestLapDriverMemberId, + principalTable: "Members", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_ScoredSessionResults_Members_FastestQualyLapDriverMemberId", + column: x => x.FastestQualyLapDriverMemberId, + principalTable: "Members", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_ScoredSessionResults_ScoredEventResults_LeagueId_ResultId", + columns: x => new { x.LeagueId, x.ResultId }, + principalTable: "ScoredEventResults", + principalColumns: new[] { "LeagueId", "ResultId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ScoredSessionResults_Scorings_LeagueId_ScoringId", + columns: x => new { x.LeagueId, x.ScoringId }, + principalTable: "Scorings", + principalColumns: new[] { "LeagueId", "ScoringId" }); + }); + + migrationBuilder.CreateTable( + name: "Seasons", + columns: table => new + { + SeasonId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + LeagueId = table.Column(type: "bigint", nullable: false), + SeasonName = table.Column(type: "longtext", nullable: true), + HideCommentsBeforeVoted = table.Column(type: "tinyint(1)", nullable: false), + Finished = table.Column(type: "tinyint(1)", nullable: false), + SeasonStart = table.Column(type: "datetime", nullable: true), + SeasonEnd = table.Column(type: "datetime", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true), + MainScoringLeagueId = table.Column(type: "bigint", nullable: true), + MainScoringScoringId = table.Column(type: "bigint", nullable: true), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Seasons", x => new { x.LeagueId, x.SeasonId }); + table.UniqueConstraint("AK_Seasons_SeasonId", x => x.SeasonId); + table.ForeignKey( + name: "FK_Seasons_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Seasons_Scorings_MainScoringLeagueId_MainScoringScoringId", + columns: x => new { x.MainScoringLeagueId, x.MainScoringScoringId }, + principalTable: "Scorings", + principalColumns: new[] { "LeagueId", "ScoringId" }); + }); + + migrationBuilder.CreateTable( + name: "ScoredResultRows", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ScoredResultRowId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + SessionResultId = table.Column(type: "bigint", nullable: false), + MemberId = table.Column(type: "bigint", nullable: true), + TeamId = table.Column(type: "bigint", nullable: true), + ImportId = table.Column(type: "bigint", nullable: true), + BonusPoints = table.Column(type: "double", nullable: false), + PenaltyPoints = table.Column(type: "double", nullable: false), + FinalPosition = table.Column(type: "int", nullable: false), + FinalPositionChange = table.Column(type: "double", nullable: false), + TotalPoints = table.Column(type: "double", nullable: false), + PointsEligible = table.Column(type: "tinyint(1)", nullable: false), + StartPosition = table.Column(type: "double", nullable: false), + FinishPosition = table.Column(type: "double", nullable: false), + CarNumber = table.Column(type: "int", nullable: false), + ClassId = table.Column(type: "int", nullable: false), + Car = table.Column(type: "longtext", nullable: true), + CarClass = table.Column(type: "longtext", nullable: true), + CompletedLaps = table.Column(type: "double", nullable: false), + LeadLaps = table.Column(type: "double", nullable: false), + FastLapNr = table.Column(type: "int", nullable: false), + Incidents = table.Column(type: "double", nullable: false), + Status = table.Column(type: "int", nullable: false), + QualifyingTime = table.Column(type: "bigint", nullable: false), + Interval = table.Column(type: "bigint", nullable: false), + AvgLapTime = table.Column(type: "bigint", nullable: false), + FastestLapTime = table.Column(type: "bigint", nullable: false), + PositionChange = table.Column(type: "double", nullable: false), + IRacingId = table.Column(type: "longtext", nullable: true), + SimSessionType = table.Column(type: "int", nullable: false), + OldIRating = table.Column(type: "int", nullable: false), + NewIRating = table.Column(type: "int", nullable: false), + SeasonStartIRating = table.Column(type: "int", nullable: false), + License = table.Column(type: "longtext", nullable: true), + OldSafetyRating = table.Column(type: "double", nullable: false), + NewSafetyRating = table.Column(type: "double", nullable: false), + OldCpi = table.Column(type: "int", nullable: false), + NewCpi = table.Column(type: "int", nullable: false), + ClubId = table.Column(type: "int", nullable: false), + ClubName = table.Column(type: "longtext", nullable: true), + CarId = table.Column(type: "int", nullable: false), + CompletedPct = table.Column(type: "double", nullable: false), + QualifyingTimeAt = table.Column(type: "datetime", nullable: true), + Division = table.Column(type: "int", nullable: false), + OldLicenseLevel = table.Column(type: "int", nullable: false), + NewLicenseLevel = table.Column(type: "int", nullable: false), + NumPitStops = table.Column(type: "int", nullable: false), + PittedLaps = table.Column(type: "longtext", nullable: true), + NumOfftrackLaps = table.Column(type: "int", nullable: false), + OfftrackLaps = table.Column(type: "longtext", nullable: true), + NumContactLaps = table.Column(type: "int", nullable: false), + ContactLaps = table.Column(type: "longtext", nullable: true), + RacePoints = table.Column(type: "double", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ScoredResultRows", x => new { x.LeagueId, x.ScoredResultRowId }); + table.UniqueConstraint("AK_ScoredResultRows_ScoredResultRowId", x => x.ScoredResultRowId); + table.ForeignKey( + name: "FK_ScoredResultRows_Members_MemberId", + column: x => x.MemberId, + principalTable: "Members", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_ScoredResultRows_ScoredSessionResults_LeagueId_SessionResult~", + columns: x => new { x.LeagueId, x.SessionResultId }, + principalTable: "ScoredSessionResults", + principalColumns: new[] { "LeagueId", "SessionResultId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ScoredResultRows_Teams_LeagueId_TeamId", + columns: x => new { x.LeagueId, x.TeamId }, + principalTable: "Teams", + principalColumns: new[] { "LeagueId", "TeamId" }); + }); + + migrationBuilder.CreateTable( + name: "ScoredResultsCleanestDrivers", + columns: table => new + { + CleanestDriversId = table.Column(type: "bigint", nullable: false), + CleanestDriverResultsLeagueId = table.Column(type: "bigint", nullable: false), + CleanestDriverResultsSessionResultId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ScoredResultsCleanestDrivers", x => new { x.CleanestDriversId, x.CleanestDriverResultsLeagueId, x.CleanestDriverResultsSessionResultId }); + table.ForeignKey( + name: "FK_ScoredResultsCleanestDrivers_Members_CleanestDriversId", + column: x => x.CleanestDriversId, + principalTable: "Members", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ScoredResultsCleanestDrivers_ScoredSessionResults_CleanestDr~", + columns: x => new { x.CleanestDriverResultsLeagueId, x.CleanestDriverResultsSessionResultId }, + principalTable: "ScoredSessionResults", + principalColumns: new[] { "LeagueId", "SessionResultId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ScoredResultsHardChargers", + columns: table => new + { + HardChargersId = table.Column(type: "bigint", nullable: false), + HardChargerResultsLeagueId = table.Column(type: "bigint", nullable: false), + HardChargerResultsSessionResultId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ScoredResultsHardChargers", x => new { x.HardChargersId, x.HardChargerResultsLeagueId, x.HardChargerResultsSessionResultId }); + table.ForeignKey( + name: "FK_ScoredResultsHardChargers_Members_HardChargersId", + column: x => x.HardChargersId, + principalTable: "Members", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ScoredResultsHardChargers_ScoredSessionResults_HardChargerRe~", + columns: x => new { x.HardChargerResultsLeagueId, x.HardChargerResultsSessionResultId }, + principalTable: "ScoredSessionResults", + principalColumns: new[] { "LeagueId", "SessionResultId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Standings", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + StandingId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + SeasonId = table.Column(type: "bigint", nullable: false), + StandingConfigId = table.Column(type: "bigint", nullable: true), + EventId = table.Column(type: "bigint", nullable: false), + Name = table.Column(type: "longtext", nullable: true), + IsTeamStanding = table.Column(type: "tinyint(1)", nullable: false), + ImportId = table.Column(type: "bigint", nullable: true), + CreatedOn = table.Column(type: "datetime(6)", nullable: true), + LastModifiedOn = table.Column(type: "datetime(6)", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Standings", x => new { x.LeagueId, x.StandingId }); + table.UniqueConstraint("AK_Standings_StandingId", x => x.StandingId); + table.ForeignKey( + name: "FK_Standings_Events_LeagueId_EventId", + columns: x => new { x.LeagueId, x.EventId }, + principalTable: "Events", + principalColumns: new[] { "LeagueId", "EventId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Standings_Seasons_LeagueId_SeasonId", + columns: x => new { x.LeagueId, x.SeasonId }, + principalTable: "Seasons", + principalColumns: new[] { "LeagueId", "SeasonId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Standings_StandingConfigurations_LeagueId_StandingConfigId", + columns: x => new { x.LeagueId, x.StandingConfigId }, + principalTable: "StandingConfigurations", + principalColumns: new[] { "LeagueId", "StandingConfigId" }); + }); + + migrationBuilder.CreateTable( + name: "StatisticSets", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "longtext", nullable: true), + UpdateInterval = table.Column(type: "bigint", nullable: false), + UpdateTime = table.Column(type: "datetime", nullable: true), + RequiresRecalculation = table.Column(type: "tinyint(1)", nullable: false), + CreatedOn = table.Column(type: "datetime", nullable: true), + LastModifiedOn = table.Column(type: "datetime", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true), + CurrentChampId = table.Column(type: "bigint", nullable: true), + SeasonId = table.Column(type: "bigint", nullable: true), + StandingId = table.Column(type: "bigint", nullable: true), + FinishedRaces = table.Column(type: "int", nullable: true), + IsSeasonFinished = table.Column(type: "tinyint(1)", nullable: true), + ImportSource = table.Column(type: "longtext", nullable: true), + Description = table.Column(type: "longtext", nullable: true), + FirstDate = table.Column(type: "datetime", nullable: true), + LastDate = table.Column(type: "datetime", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_StatisticSets", x => new { x.LeagueId, x.Id }); + table.UniqueConstraint("AK_StatisticSets_Id", x => x.Id); + table.ForeignKey( + name: "FK_StatisticSets_Members_CurrentChampId", + column: x => x.CurrentChampId, + principalTable: "Members", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_StatisticSets_Seasons_LeagueId_SeasonId", + columns: x => new { x.LeagueId, x.SeasonId }, + principalTable: "Seasons", + principalColumns: new[] { "LeagueId", "SeasonId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ScoredTeamResultRowsResultRows", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + TeamResultRowRefId = table.Column(type: "bigint", nullable: false), + TeamParentRowRefId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ScoredTeamResultRowsResultRows", x => new { x.TeamParentRowRefId, x.LeagueId, x.TeamResultRowRefId }); + table.ForeignKey( + name: "FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1", + columns: x => new { x.LeagueId, x.TeamResultRowRefId }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Tea~", + columns: x => new { x.LeagueId, x.TeamParentRowRefId }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "StandingRows", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + StandingRowId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + StandingId = table.Column(type: "bigint", nullable: false), + MemberId = table.Column(type: "bigint", nullable: true), + TeamId = table.Column(type: "bigint", nullable: true), + Position = table.Column(type: "int", nullable: false), + LastPosition = table.Column(type: "int", nullable: false), + ClassId = table.Column(type: "int", nullable: false), + CarClass = table.Column(type: "longtext", nullable: true), + RacePoints = table.Column(type: "int", nullable: false), + RacePointsChange = table.Column(type: "int", nullable: false), + PenaltyPoints = table.Column(type: "int", nullable: false), + PenaltyPointsChange = table.Column(type: "int", nullable: false), + TotalPoints = table.Column(type: "int", nullable: false), + TotalPointsChange = table.Column(type: "int", nullable: false), + Races = table.Column(type: "int", nullable: false), + RacesCounted = table.Column(type: "int", nullable: false), + DroppedResultCount = table.Column(type: "int", nullable: false), + CompletedLaps = table.Column(type: "int", nullable: false), + CompletedLapsChange = table.Column(type: "int", nullable: false), + LeadLaps = table.Column(type: "int", nullable: false), + LeadLapsChange = table.Column(type: "int", nullable: false), + FastestLaps = table.Column(type: "int", nullable: false), + FastestLapsChange = table.Column(type: "int", nullable: false), + PolePositions = table.Column(type: "int", nullable: false), + PolePositionsChange = table.Column(type: "int", nullable: false), + Wins = table.Column(type: "int", nullable: false), + WinsChange = table.Column(type: "int", nullable: false), + Top3 = table.Column(type: "int", nullable: false), + Top5 = table.Column(type: "int", nullable: false), + Top10 = table.Column(type: "int", nullable: false), + Incidents = table.Column(type: "int", nullable: false), + IncidentsChange = table.Column(type: "int", nullable: false), + PositionChange = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_StandingRows", x => new { x.LeagueId, x.StandingRowId }); + table.UniqueConstraint("AK_StandingRows_StandingRowId", x => x.StandingRowId); + table.ForeignKey( + name: "FK_StandingRows_Members_MemberId", + column: x => x.MemberId, + principalTable: "Members", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_StandingRows_Standings_LeagueId_StandingId", + columns: x => new { x.LeagueId, x.StandingId }, + principalTable: "Standings", + principalColumns: new[] { "LeagueId", "StandingId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_StandingRows_Teams_LeagueId_TeamId", + columns: x => new { x.LeagueId, x.TeamId }, + principalTable: "Teams", + principalColumns: new[] { "LeagueId", "TeamId" }); + }); + + migrationBuilder.CreateTable( + name: "StandingRows_ScoredResultRows", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + StandingRowRefId = table.Column(type: "bigint", nullable: false), + ScoredResultRowRefId = table.Column(type: "bigint", nullable: false), + IsScored = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_StandingRows_ScoredResultRows", x => new { x.ScoredResultRowRefId, x.LeagueId, x.StandingRowRefId }); + table.ForeignKey( + name: "FK_StandingRows_ScoredResultRows_ScoredResultRows_LeagueId_Scor~", + columns: x => new { x.LeagueId, x.ScoredResultRowRefId }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_StandingRows_ScoredResultRows_StandingRows_LeagueId_Standing~", + columns: x => new { x.LeagueId, x.StandingRowRefId }, + principalTable: "StandingRows", + principalColumns: new[] { "LeagueId", "StandingRowId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AcceptedReviewVotes_LeagueId_ReviewId", + table: "AcceptedReviewVotes", + columns: new[] { "LeagueId", "ReviewId" }); + + migrationBuilder.CreateIndex( + name: "IX_AcceptedReviewVotes_LeagueId_VoteCategoryId", + table: "AcceptedReviewVotes", + columns: new[] { "LeagueId", "VoteCategoryId" }); + + migrationBuilder.CreateIndex( + name: "IX_AcceptedReviewVotes_MemberAtFaultId", + table: "AcceptedReviewVotes", + column: "MemberAtFaultId"); + + migrationBuilder.CreateIndex( + name: "IX_AcceptedReviewVotes_ReviewId", + table: "AcceptedReviewVotes", + column: "ReviewId"); + + migrationBuilder.CreateIndex( + name: "IX_AcceptedReviewVotes_VoteCategoryId", + table: "AcceptedReviewVotes", + column: "VoteCategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_AddPenaltys_LeagueId_ScoredResultRowId", + table: "AddPenaltys", + columns: new[] { "LeagueId", "ScoredResultRowId" }); + + migrationBuilder.CreateIndex( + name: "IX_DriverStatisticRows_LeagueId_FirstRaceId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "FirstRaceId" }); + + migrationBuilder.CreateIndex( + name: "IX_DriverStatisticRows_LeagueId_FirstResultRowId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "FirstResultRowId" }); + + migrationBuilder.CreateIndex( + name: "IX_DriverStatisticRows_LeagueId_FirstSessionId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "FirstSessionId" }); + + migrationBuilder.CreateIndex( + name: "IX_DriverStatisticRows_LeagueId_LastRaceId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "LastRaceId" }); + + migrationBuilder.CreateIndex( + name: "IX_DriverStatisticRows_LeagueId_LastResultRowId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "LastResultRowId" }); + + migrationBuilder.CreateIndex( + name: "IX_DriverStatisticRows_LeagueId_LastSessionId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "LastSessionId" }); + + migrationBuilder.CreateIndex( + name: "IX_DriverStatisticRows_MemberId", + table: "DriverStatisticRows", + column: "MemberId"); + + migrationBuilder.CreateIndex( + name: "IX_DriverStatisticRows_StatisticSetId", + table: "DriverStatisticRows", + column: "StatisticSetId"); + + migrationBuilder.CreateIndex( + name: "IX_EventResultConfigs_LeagueId_EventRefId", + table: "EventResultConfigs", + columns: new[] { "LeagueId", "EventRefId" }); + + migrationBuilder.CreateIndex( + name: "IX_EventResultConfigs_LeagueId_ResultConfigRefId", + table: "EventResultConfigs", + columns: new[] { "LeagueId", "ResultConfigRefId" }); + + migrationBuilder.CreateIndex( + name: "IX_EventResults_EventId", + table: "EventResults", + column: "EventId"); + + migrationBuilder.CreateIndex( + name: "IX_Events_LeagueId_ScheduleId", + table: "Events", + columns: new[] { "LeagueId", "ScheduleId" }); + + migrationBuilder.CreateIndex( + name: "IX_Events_TrackId", + table: "Events", + column: "TrackId"); + + migrationBuilder.CreateIndex( + name: "IX_FilterConditions_LeagueId_FilterOptionId", + table: "FilterConditions", + columns: new[] { "LeagueId", "FilterOptionId" }); + + migrationBuilder.CreateIndex( + name: "IX_FilterOptions_LeagueId_PointFilterResultConfigId", + table: "FilterOptions", + columns: new[] { "LeagueId", "PointFilterResultConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_FilterOptions_LeagueId_ResultFilterResultConfigId", + table: "FilterOptions", + columns: new[] { "LeagueId", "ResultFilterResultConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_IncidentReviews_LeagueId_SessionId", + table: "IncidentReviews", + columns: new[] { "LeagueId", "SessionId" }); + + migrationBuilder.CreateIndex( + name: "IX_IncidentReviews_SessionId", + table: "IncidentReviews", + column: "SessionId"); + + migrationBuilder.CreateIndex( + name: "IX_IncidentReviewsInvolvedMembers_InvolvedReviewsLeagueId_Invol~", + table: "IncidentReviewsInvolvedMembers", + columns: new[] { "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId" }); + + migrationBuilder.CreateIndex( + name: "IX_IRSimSessionDetails_LeagueId_EventId", + table: "IRSimSessionDetails", + columns: new[] { "LeagueId", "EventId" }); + + migrationBuilder.CreateIndex( + name: "IX_LeagueMembers_LeagueId_TeamId", + table: "LeagueMembers", + columns: new[] { "LeagueId", "TeamId" }); + + migrationBuilder.CreateIndex( + name: "IX_LeagueMembers_MemberId", + table: "LeagueMembers", + column: "MemberId"); + + migrationBuilder.CreateIndex( + name: "IX_LeagueStatisticSetsStatisticSets_LeagueStatisticSetsLeagueId~", + table: "LeagueStatisticSetsStatisticSets", + columns: new[] { "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId" }); + + migrationBuilder.CreateIndex( + name: "IX_ResultConfigurations_LeagueId_SourceResultConfigId", + table: "ResultConfigurations", + columns: new[] { "LeagueId", "SourceResultConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_ResultRows_LeagueId_MemberId", + table: "ResultRows", + columns: new[] { "LeagueId", "MemberId" }); + + migrationBuilder.CreateIndex( + name: "IX_ResultRows_LeagueId_SubSessionId", + table: "ResultRows", + columns: new[] { "LeagueId", "SubSessionId" }); + + migrationBuilder.CreateIndex( + name: "IX_ResultRows_LeagueId_TeamId", + table: "ResultRows", + columns: new[] { "LeagueId", "TeamId" }); + + migrationBuilder.CreateIndex( + name: "IX_ResultRows_MemberId", + table: "ResultRows", + column: "MemberId"); + + migrationBuilder.CreateIndex( + name: "IX_ReviewComments_LeagueId_ReplyToCommentId", + table: "ReviewComments", + columns: new[] { "LeagueId", "ReplyToCommentId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewComments_LeagueId_ReviewId", + table: "ReviewComments", + columns: new[] { "LeagueId", "ReviewId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewComments_ReplyToCommentId", + table: "ReviewComments", + column: "ReplyToCommentId"); + + migrationBuilder.CreateIndex( + name: "IX_ReviewComments_ReviewId", + table: "ReviewComments", + column: "ReviewId"); + + migrationBuilder.CreateIndex( + name: "IX_ReviewCommentVotes_CommentId", + table: "ReviewCommentVotes", + column: "CommentId"); + + migrationBuilder.CreateIndex( + name: "IX_ReviewCommentVotes_LeagueId_CommentId", + table: "ReviewCommentVotes", + columns: new[] { "LeagueId", "CommentId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewCommentVotes_LeagueId_VoteCategoryId", + table: "ReviewCommentVotes", + columns: new[] { "LeagueId", "VoteCategoryId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewCommentVotes_MemberAtFaultId", + table: "ReviewCommentVotes", + column: "MemberAtFaultId"); + + migrationBuilder.CreateIndex( + name: "IX_ReviewCommentVotes_VoteCategoryId", + table: "ReviewCommentVotes", + column: "VoteCategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_LeagueId_ResultRowId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ResultRowId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_LeagueId_ReviewId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ReviewId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_LeagueId_ReviewVoteId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ReviewVoteId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_ReviewId", + table: "ReviewPenaltys", + column: "ReviewId"); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_ReviewVoteId", + table: "ReviewPenaltys", + column: "ReviewVoteId"); + + migrationBuilder.CreateIndex( + name: "IX_Schedules_LeagueId_SeasonId", + table: "Schedules", + columns: new[] { "LeagueId", "SeasonId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredEventResults_EventResultEntityLeagueId_EventResultEnti~", + table: "ScoredEventResults", + columns: new[] { "EventResultEntityLeagueId", "EventResultEntityEventId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredEventResults_LeagueId_EventId", + table: "ScoredEventResults", + columns: new[] { "LeagueId", "EventId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredEventResults_LeagueId_ResultConfigId", + table: "ScoredEventResults", + columns: new[] { "LeagueId", "ResultConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredResultRows_LeagueId_SessionResultId", + table: "ScoredResultRows", + columns: new[] { "LeagueId", "SessionResultId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredResultRows_LeagueId_TeamId", + table: "ScoredResultRows", + columns: new[] { "LeagueId", "TeamId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredResultRows_MemberId", + table: "ScoredResultRows", + column: "MemberId"); + + migrationBuilder.CreateIndex( + name: "IX_ScoredResultRows_TeamId", + table: "ScoredResultRows", + column: "TeamId"); + + migrationBuilder.CreateIndex( + name: "IX_ScoredResultsCleanestDrivers_CleanestDriverResultsLeagueId_C~", + table: "ScoredResultsCleanestDrivers", + columns: new[] { "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredResultsHardChargers_HardChargerResultsLeagueId_HardCha~", + table: "ScoredResultsHardChargers", + columns: new[] { "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredSessionResults_FastestAvgLapDriverMemberId", + table: "ScoredSessionResults", + column: "FastestAvgLapDriverMemberId"); + + migrationBuilder.CreateIndex( + name: "IX_ScoredSessionResults_FastestLapDriverMemberId", + table: "ScoredSessionResults", + column: "FastestLapDriverMemberId"); + + migrationBuilder.CreateIndex( + name: "IX_ScoredSessionResults_FastestQualyLapDriverMemberId", + table: "ScoredSessionResults", + column: "FastestQualyLapDriverMemberId"); + + migrationBuilder.CreateIndex( + name: "IX_ScoredSessionResults_LeagueId_ResultId", + table: "ScoredSessionResults", + columns: new[] { "LeagueId", "ResultId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredSessionResults_LeagueId_ScoringId", + table: "ScoredSessionResults", + columns: new[] { "LeagueId", "ScoringId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredTeamResultRowsResultRows_LeagueId_TeamParentRowRefId", + table: "ScoredTeamResultRowsResultRows", + columns: new[] { "LeagueId", "TeamParentRowRefId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredTeamResultRowsResultRows_LeagueId_TeamResultRowRefId", + table: "ScoredTeamResultRowsResultRows", + columns: new[] { "LeagueId", "TeamResultRowRefId" }); + + migrationBuilder.CreateIndex( + name: "IX_Scorings_ExtScoringSourceId", + table: "Scorings", + column: "ExtScoringSourceId"); + + migrationBuilder.CreateIndex( + name: "IX_Scorings_LeagueId_ExtScoringSourceId", + table: "Scorings", + columns: new[] { "LeagueId", "ExtScoringSourceId" }); + + migrationBuilder.CreateIndex( + name: "IX_Scorings_LeagueId_PointsRuleId", + table: "Scorings", + columns: new[] { "LeagueId", "PointsRuleId" }); + + migrationBuilder.CreateIndex( + name: "IX_Scorings_LeagueId_ResultConfigId", + table: "Scorings", + columns: new[] { "LeagueId", "ResultConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_Scorings_ScheduleEntityLeagueId_ScheduleEntityScheduleId", + table: "Scorings", + columns: new[] { "ScheduleEntityLeagueId", "ScheduleEntityScheduleId" }); + + migrationBuilder.CreateIndex( + name: "IX_Seasons_MainScoringLeagueId_MainScoringScoringId", + table: "Seasons", + columns: new[] { "MainScoringLeagueId", "MainScoringScoringId" }); + + migrationBuilder.CreateIndex( + name: "IX_SessionResults_LeagueId_EventId", + table: "SessionResults", + columns: new[] { "LeagueId", "EventId" }); + + migrationBuilder.CreateIndex( + name: "IX_SessionResults_LeagueId_IRSimSessionDetailsId", + table: "SessionResults", + columns: new[] { "LeagueId", "IRSimSessionDetailsId" }); + + migrationBuilder.CreateIndex( + name: "IX_SessionResults_SessionId", + table: "SessionResults", + column: "SessionId"); + + migrationBuilder.CreateIndex( + name: "IX_Sessions_EventId_SessionId", + table: "Sessions", + columns: new[] { "EventId", "SessionId" }); + + migrationBuilder.CreateIndex( + name: "IX_Sessions_LeagueId_EventId", + table: "Sessions", + columns: new[] { "LeagueId", "EventId" }); + + migrationBuilder.CreateIndex( + name: "IX_StandingConfigs_ResultConfigs_LeagueId_ResultConfigId", + table: "StandingConfigs_ResultConfigs", + columns: new[] { "LeagueId", "ResultConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_StandingConfigs_ResultConfigs_LeagueId_StandingConfigId", + table: "StandingConfigs_ResultConfigs", + columns: new[] { "LeagueId", "StandingConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_StandingRows_LeagueId_StandingId", + table: "StandingRows", + columns: new[] { "LeagueId", "StandingId" }); + + migrationBuilder.CreateIndex( + name: "IX_StandingRows_LeagueId_TeamId", + table: "StandingRows", + columns: new[] { "LeagueId", "TeamId" }); + + migrationBuilder.CreateIndex( + name: "IX_StandingRows_MemberId", + table: "StandingRows", + column: "MemberId"); + + migrationBuilder.CreateIndex( + name: "IX_StandingRows_ScoredResultRows_LeagueId_ScoredResultRowRefId", + table: "StandingRows_ScoredResultRows", + columns: new[] { "LeagueId", "ScoredResultRowRefId" }); + + migrationBuilder.CreateIndex( + name: "IX_StandingRows_ScoredResultRows_LeagueId_StandingRowRefId", + table: "StandingRows_ScoredResultRows", + columns: new[] { "LeagueId", "StandingRowRefId" }); + + migrationBuilder.CreateIndex( + name: "IX_Standings_LeagueId_EventId", + table: "Standings", + columns: new[] { "LeagueId", "EventId" }); + + migrationBuilder.CreateIndex( + name: "IX_Standings_LeagueId_SeasonId", + table: "Standings", + columns: new[] { "LeagueId", "SeasonId" }); + + migrationBuilder.CreateIndex( + name: "IX_Standings_LeagueId_StandingConfigId", + table: "Standings", + columns: new[] { "LeagueId", "StandingConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_StatisticSets_CurrentChampId", + table: "StatisticSets", + column: "CurrentChampId"); + + migrationBuilder.CreateIndex( + name: "IX_StatisticSets_LeagueId_SeasonId", + table: "StatisticSets", + columns: new[] { "LeagueId", "SeasonId" }); + + migrationBuilder.CreateIndex( + name: "IX_StatisticSets_LeagueId_StandingId", + table: "StatisticSets", + columns: new[] { "LeagueId", "StandingId" }); + + migrationBuilder.CreateIndex( + name: "IX_TrackConfigs_TrackGroupId", + table: "TrackConfigs", + column: "TrackGroupId"); + + migrationBuilder.AddForeignKey( + name: "FK_AcceptedReviewVotes_IncidentReviews_LeagueId_ReviewId", + table: "AcceptedReviewVotes", + columns: new[] { "LeagueId", "ReviewId" }, + principalTable: "IncidentReviews", + principalColumns: new[] { "LeagueId", "ReviewId" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_AddPenaltys_ScoredResultRows_LeagueId_ScoredResultRowId", + table: "AddPenaltys", + columns: new[] { "LeagueId", "ScoredResultRowId" }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }); + + migrationBuilder.AddForeignKey( + name: "FK_DriverStatisticRows_ScoredResultRows_LeagueId_FirstResultRow~", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "FirstResultRowId" }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }); + + migrationBuilder.AddForeignKey( + name: "FK_DriverStatisticRows_ScoredResultRows_LeagueId_LastResultRowId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "LastResultRowId" }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }); + + migrationBuilder.AddForeignKey( + name: "FK_DriverStatisticRows_Sessions_LeagueId_FirstRaceId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "FirstRaceId" }, + principalTable: "Sessions", + principalColumns: new[] { "LeagueId", "SessionId" }); + + migrationBuilder.AddForeignKey( + name: "FK_DriverStatisticRows_Sessions_LeagueId_FirstSessionId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "FirstSessionId" }, + principalTable: "Sessions", + principalColumns: new[] { "LeagueId", "SessionId" }); + + migrationBuilder.AddForeignKey( + name: "FK_DriverStatisticRows_Sessions_LeagueId_LastRaceId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "LastRaceId" }, + principalTable: "Sessions", + principalColumns: new[] { "LeagueId", "SessionId" }); + + migrationBuilder.AddForeignKey( + name: "FK_DriverStatisticRows_Sessions_LeagueId_LastSessionId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "LastSessionId" }, + principalTable: "Sessions", + principalColumns: new[] { "LeagueId", "SessionId" }); + + migrationBuilder.AddForeignKey( + name: "FK_DriverStatisticRows_StatisticSets_LeagueId_StatisticSetId", + table: "DriverStatisticRows", + columns: new[] { "LeagueId", "StatisticSetId" }, + principalTable: "StatisticSets", + principalColumns: new[] { "LeagueId", "Id" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_EventResultConfigs_Events_LeagueId_EventRefId", + table: "EventResultConfigs", + columns: new[] { "LeagueId", "EventRefId" }, + principalTable: "Events", + principalColumns: new[] { "LeagueId", "EventId" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_EventResults_Events_LeagueId_EventId", + table: "EventResults", + columns: new[] { "LeagueId", "EventId" }, + principalTable: "Events", + principalColumns: new[] { "LeagueId", "EventId" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Events_Schedules_LeagueId_ScheduleId", + table: "Events", + columns: new[] { "LeagueId", "ScheduleId" }, + principalTable: "Schedules", + principalColumns: new[] { "LeagueId", "ScheduleId" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_LeagueStatisticSetsStatisticSets_StatisticSets_DependendStat~", + table: "LeagueStatisticSetsStatisticSets", + columns: new[] { "DependendStatisticSetsLeagueId", "DependendStatisticSetsId" }, + principalTable: "StatisticSets", + principalColumns: new[] { "LeagueId", "Id" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_LeagueStatisticSetsStatisticSets_StatisticSets_LeagueStatist~", + table: "LeagueStatisticSetsStatisticSets", + columns: new[] { "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId" }, + principalTable: "StatisticSets", + principalColumns: new[] { "LeagueId", "Id" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_ReviewPenaltys_ScoredResultRows_LeagueId_ResultRowId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ResultRowId" }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Schedules_Seasons_LeagueId_SeasonId", + table: "Schedules", + columns: new[] { "LeagueId", "SeasonId" }, + principalTable: "Seasons", + principalColumns: new[] { "LeagueId", "SeasonId" }, + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_PointRules_Leagues_LeagueId", + table: "PointRules"); + + migrationBuilder.DropForeignKey( + name: "FK_ResultConfigurations_Leagues_LeagueId", + table: "ResultConfigurations"); + + migrationBuilder.DropForeignKey( + name: "FK_Scorings_Leagues_LeagueId", + table: "Scorings"); + + migrationBuilder.DropForeignKey( + name: "FK_Seasons_Leagues_LeagueId", + table: "Seasons"); + + migrationBuilder.DropForeignKey( + name: "FK_Scorings_ResultConfigurations_LeagueId_ResultConfigId", + table: "Scorings"); + + migrationBuilder.DropForeignKey( + name: "FK_Scorings_Schedules_ScheduleEntityLeagueId_ScheduleEntitySche~", + table: "Scorings"); + + migrationBuilder.DropTable( + name: "AddPenaltys"); + + migrationBuilder.DropTable( + name: "CustomIncidents"); + + migrationBuilder.DropTable( + name: "DriverStatisticRows"); + + migrationBuilder.DropTable( + name: "EventResultConfigs"); + + migrationBuilder.DropTable( + name: "FilterConditions"); + + migrationBuilder.DropTable( + name: "IncidentReviewsInvolvedMembers"); + + migrationBuilder.DropTable( + name: "LeagueStatisticSetsStatisticSets"); + + migrationBuilder.DropTable( + name: "ResultRows"); + + migrationBuilder.DropTable( + name: "ReviewCommentVotes"); + + migrationBuilder.DropTable( + name: "ReviewPenaltys"); + + migrationBuilder.DropTable( + name: "ScoredResultsCleanestDrivers"); + + migrationBuilder.DropTable( + name: "ScoredResultsHardChargers"); + + migrationBuilder.DropTable( + name: "ScoredTeamResultRowsResultRows"); + + migrationBuilder.DropTable( + name: "StandingConfigs_ResultConfigs"); + + migrationBuilder.DropTable( + name: "StandingRows_ScoredResultRows"); + + migrationBuilder.DropTable( + name: "FilterOptions"); + + migrationBuilder.DropTable( + name: "StatisticSets"); + + migrationBuilder.DropTable( + name: "LeagueMembers"); + + migrationBuilder.DropTable( + name: "SessionResults"); + + migrationBuilder.DropTable( + name: "ReviewComments"); + + migrationBuilder.DropTable( + name: "AcceptedReviewVotes"); + + migrationBuilder.DropTable( + name: "ScoredResultRows"); + + migrationBuilder.DropTable( + name: "StandingRows"); + + migrationBuilder.DropTable( + name: "IRSimSessionDetails"); + + migrationBuilder.DropTable( + name: "IncidentReviews"); + + migrationBuilder.DropTable( + name: "VoteCategories"); + + migrationBuilder.DropTable( + name: "ScoredSessionResults"); + + migrationBuilder.DropTable( + name: "Standings"); + + migrationBuilder.DropTable( + name: "Teams"); + + migrationBuilder.DropTable( + name: "Sessions"); + + migrationBuilder.DropTable( + name: "Members"); + + migrationBuilder.DropTable( + name: "ScoredEventResults"); + + migrationBuilder.DropTable( + name: "StandingConfigurations"); + + migrationBuilder.DropTable( + name: "EventResults"); + + migrationBuilder.DropTable( + name: "Events"); + + migrationBuilder.DropTable( + name: "TrackConfigs"); + + migrationBuilder.DropTable( + name: "TrackGroups"); + + migrationBuilder.DropTable( + name: "Leagues"); + + migrationBuilder.DropTable( + name: "ResultConfigurations"); + + migrationBuilder.DropTable( + name: "Schedules"); + + migrationBuilder.DropTable( + name: "Seasons"); + + migrationBuilder.DropTable( + name: "Scorings"); + + migrationBuilder.DropTable( + name: "PointRules"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20221216064912_AddStandingIrating.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20221216064912_AddStandingIrating.Designer.cs new file mode 100644 index 00000000..b925822d --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20221216064912_AddStandingIrating.Designer.cs @@ -0,0 +1,3428 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20221216064912_AddStandingIrating")] + partial class AddStandingIrating + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.HasKey("ResultConfigId", "LeagueId", "StandingConfigId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("StandingConfigs_ResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany() + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultConfig"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20221216064912_AddStandingIrating.cs b/src/iRLeagueDatabaseCore/Migrations/20221216064912_AddStandingIrating.cs new file mode 100644 index 00000000..2366e681 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20221216064912_AddStandingIrating.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AddStandingIrating : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LastIrating", + table: "StandingRows", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "StartIrating", + table: "StandingRows", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LastIrating", + table: "StandingRows"); + + migrationBuilder.DropColumn( + name: "StartIrating", + table: "StandingRows"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20221218194901_UseExternalPointsOption.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20221218194901_UseExternalPointsOption.Designer.cs new file mode 100644 index 00000000..478bb210 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20221218194901_UseExternalPointsOption.Designer.cs @@ -0,0 +1,3431 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20221218194901_UseExternalPointsOption")] + partial class UseExternalPointsOption + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.HasKey("ResultConfigId", "LeagueId", "StandingConfigId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("StandingConfigs_ResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany() + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultConfig"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20221218194901_UseExternalPointsOption.cs b/src/iRLeagueDatabaseCore/Migrations/20221218194901_UseExternalPointsOption.cs new file mode 100644 index 00000000..205e4bac --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20221218194901_UseExternalPointsOption.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class UseExternalPointsOption : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "UseExternalSourcePoints", + table: "Scorings", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "UseExternalSourcePoints", + table: "Scorings"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20221231141402_ProtestEntity.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20221231141402_ProtestEntity.Designer.cs new file mode 100644 index 00000000..60a90089 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20221231141402_ProtestEntity.Designer.cs @@ -0,0 +1,3524 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20221231141402_ProtestEntity")] + partial class ProtestEntity + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.HasKey("ResultConfigId", "LeagueId", "StandingConfigId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("StandingConfigs_ResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany() + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultConfig"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20221231141402_ProtestEntity.cs b/src/iRLeagueDatabaseCore/Migrations/20221231141402_ProtestEntity.cs new file mode 100644 index 00000000..c640ed68 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20221231141402_ProtestEntity.cs @@ -0,0 +1,98 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using MySql.EntityFrameworkCore.Metadata; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class ProtestEntity : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Protests", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ProtestId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + SessionId = table.Column(type: "bigint", nullable: false), + AuthorMemberId = table.Column(type: "bigint", nullable: false), + FullDescription = table.Column(type: "longtext", nullable: true), + OnLap = table.Column(type: "longtext", nullable: true), + Corner = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Protests", x => new { x.LeagueId, x.ProtestId }); + table.UniqueConstraint("AK_Protests_ProtestId", x => x.ProtestId); + table.ForeignKey( + name: "FK_Protests_LeagueMembers_LeagueId_AuthorMemberId", + columns: x => new { x.LeagueId, x.AuthorMemberId }, + principalTable: "LeagueMembers", + principalColumns: new[] { "LeagueId", "MemberId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Protests_Sessions_LeagueId_SessionId", + columns: x => new { x.LeagueId, x.SessionId }, + principalTable: "Sessions", + principalColumns: new[] { "LeagueId", "SessionId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Protests_LeagueMembers", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ProtestId = table.Column(type: "bigint", nullable: false), + MemberId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Protests_LeagueMembers", x => new { x.MemberId, x.LeagueId, x.ProtestId }); + table.ForeignKey( + name: "FK_Protests_LeagueMembers_LeagueMembers_LeagueId_MemberId", + columns: x => new { x.LeagueId, x.MemberId }, + principalTable: "LeagueMembers", + principalColumns: new[] { "LeagueId", "MemberId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Protests_LeagueMembers_Protests_LeagueId_ProtestId", + columns: x => new { x.LeagueId, x.ProtestId }, + principalTable: "Protests", + principalColumns: new[] { "LeagueId", "ProtestId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Protests_LeagueId_AuthorMemberId", + table: "Protests", + columns: new[] { "LeagueId", "AuthorMemberId" }); + + migrationBuilder.CreateIndex( + name: "IX_Protests_LeagueId_SessionId", + table: "Protests", + columns: new[] { "LeagueId", "SessionId" }); + + migrationBuilder.CreateIndex( + name: "IX_Protests_LeagueMembers_LeagueId_MemberId", + table: "Protests_LeagueMembers", + columns: new[] { "LeagueId", "MemberId" }); + + migrationBuilder.CreateIndex( + name: "IX_Protests_LeagueMembers_LeagueId_ProtestId", + table: "Protests_LeagueMembers", + columns: new[] { "LeagueId", "ProtestId" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Protests_LeagueMembers"); + + migrationBuilder.DropTable( + name: "Protests"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230105071615_ProtestSettings.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230105071615_ProtestSettings.Designer.cs new file mode 100644 index 00000000..656e0bb0 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230105071615_ProtestSettings.Designer.cs @@ -0,0 +1,3536 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230105071615_ProtestSettings")] + partial class ProtestSettings + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.HasKey("ResultConfigId", "LeagueId", "StandingConfigId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("StandingConfigs_ResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigs_ResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany() + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultConfig"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230105071615_ProtestSettings.cs b/src/iRLeagueDatabaseCore/Migrations/20230105071615_ProtestSettings.cs new file mode 100644 index 00000000..ea3b137d --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230105071615_ProtestSettings.cs @@ -0,0 +1,59 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class ProtestSettings : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "EnableProtests", + table: "Leagues", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "ProtestCoolDownPeriod", + table: "Leagues", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "ProtestsClosedAfter", + table: "Leagues", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "ProtestsPublic", + table: "Leagues", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "EnableProtests", + table: "Leagues"); + + migrationBuilder.DropColumn( + name: "ProtestCoolDownPeriod", + table: "Leagues"); + + migrationBuilder.DropColumn( + name: "ProtestsClosedAfter", + table: "Leagues"); + + migrationBuilder.DropColumn( + name: "ProtestsPublic", + table: "Leagues"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230203161835_ChampionshipEntities.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230203161835_ChampionshipEntities.Designer.cs new file mode 100644 index 00000000..f8db8e99 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230203161835_ChampionshipEntities.Designer.cs @@ -0,0 +1,3688 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230203161835_ChampionshipEntities")] + partial class ChampionshipEntities + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasons_ResultConfigurations", b => + { + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.HasKey("ChampSeasonId", "LeagueId", "ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ChampSeasons_ResultConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasons_ResultConfigurations", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany() + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChampSeason"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230203161835_ChampionshipEntities.cs b/src/iRLeagueDatabaseCore/Migrations/20230203161835_ChampionshipEntities.cs new file mode 100644 index 00000000..1499a417 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230203161835_ChampionshipEntities.cs @@ -0,0 +1,313 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using MySql.EntityFrameworkCore.Metadata; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class ChampionshipEntities : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ChampSeasonId", + table: "Standings", + type: "bigint", + nullable: true); + + migrationBuilder.AddColumn( + name: "ChampSeasonId", + table: "ScoredEventResults", + type: "bigint", + nullable: true); + + migrationBuilder.CreateTable( + name: "Championships", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ChampionshipId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "varchar(80)", maxLength: 80, nullable: true), + DisplayName = table.Column(type: "varchar(255)", maxLength: 255, nullable: true), + CreatedOn = table.Column(type: "datetime(6)", nullable: true), + LastModifiedOn = table.Column(type: "datetime(6)", nullable: true), + Version = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "longtext", nullable: true), + CreatedByUserName = table.Column(type: "longtext", nullable: true), + LastModifiedByUserId = table.Column(type: "longtext", nullable: true), + LastModifiedByUserName = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Championships", x => new { x.LeagueId, x.ChampionshipId }); + table.UniqueConstraint("AK_Championships_ChampionshipId", x => x.ChampionshipId); + table.ForeignKey( + name: "FK_Championships_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ChampSeasons", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ChampSeasonId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + ChampionshipId = table.Column(type: "bigint", nullable: false), + SeasonId = table.Column(type: "bigint", nullable: false), + StandingConfigId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ChampSeasons", x => new { x.LeagueId, x.ChampSeasonId }); + table.UniqueConstraint("AK_ChampSeasons_ChampSeasonId", x => x.ChampSeasonId); + table.ForeignKey( + name: "FK_ChampSeasons_Championships_LeagueId_ChampionshipId", + columns: x => new { x.LeagueId, x.ChampionshipId }, + principalTable: "Championships", + principalColumns: new[] { "LeagueId", "ChampionshipId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ChampSeasons_Seasons_LeagueId_SeasonId", + columns: x => new { x.LeagueId, x.SeasonId }, + principalTable: "Seasons", + principalColumns: new[] { "LeagueId", "SeasonId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ChampSeasons_StandingConfigurations_LeagueId_StandingConfigId", + columns: x => new { x.LeagueId, x.StandingConfigId }, + principalTable: "StandingConfigurations", + principalColumns: new[] { "LeagueId", "StandingConfigId" }); + }); + + migrationBuilder.CreateTable( + name: "ChampSeasons_ResultConfigs", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ChampSeasonId = table.Column(type: "bigint", nullable: false), + ResultConfigId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChampSeasons_ResultConfigs", x => new { x.ChampSeasonId, x.LeagueId, x.ResultConfigId }); + table.ForeignKey( + name: "FK_ChampSeasons_ResultConfigs_ChampSeasons_LeagueId_ChampSeason~", + columns: x => new { x.LeagueId, x.ChampSeasonId }, + principalTable: "ChampSeasons", + principalColumns: new[] { "LeagueId", "ChampSeasonId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ChampSeasons_ResultConfigs_ResultConfigurations_LeagueId_Res~", + columns: x => new { x.LeagueId, x.ResultConfigId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Standings_LeagueId_ChampSeasonId", + table: "Standings", + columns: new[] { "LeagueId", "ChampSeasonId" }); + + migrationBuilder.CreateIndex( + name: "IX_ScoredEventResults_LeagueId_ChampSeasonId", + table: "ScoredEventResults", + columns: new[] { "LeagueId", "ChampSeasonId" }); + + migrationBuilder.CreateIndex( + name: "IX_ChampSeasons_LeagueId_ChampionshipId", + table: "ChampSeasons", + columns: new[] { "LeagueId", "ChampionshipId" }); + + migrationBuilder.CreateIndex( + name: "IX_ChampSeasons_LeagueId_SeasonId", + table: "ChampSeasons", + columns: new[] { "LeagueId", "SeasonId" }); + + migrationBuilder.CreateIndex( + name: "IX_ChampSeasons_LeagueId_StandingConfigId", + table: "ChampSeasons", + columns: new[] { "LeagueId", "StandingConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_ChampSeasons_ResultConfigs_LeagueId_ChampSeasonId", + table: "ChampSeasons_ResultConfigs", + columns: new[] { "LeagueId", "ChampSeasonId" }); + + migrationBuilder.CreateIndex( + name: "IX_ChampSeasons_ResultConfigs_LeagueId_ResultConfigId", + table: "ChampSeasons_ResultConfigs", + columns: new[] { "LeagueId", "ResultConfigId" }); + + migrationBuilder.AddForeignKey( + name: "FK_ScoredEventResults_ChampSeasons_LeagueId_ChampSeasonId", + table: "ScoredEventResults", + columns: new[] { "LeagueId", "ChampSeasonId" }, + principalTable: "ChampSeasons", + principalColumns: new[] { "LeagueId", "ChampSeasonId" }); + + migrationBuilder.AddForeignKey( + name: "FK_Standings_ChampSeasons_LeagueId_ChampSeasonId", + table: "Standings", + columns: new[] { "LeagueId", "ChampSeasonId" }, + principalTable: "ChampSeasons", + principalColumns: new[] { "LeagueId", "ChampSeasonId" }); + + // Migrate old result configs to new championships + migrationBuilder.Sql(@" +CREATE TEMPORARY TABLE TmpChampionships ( + LeagueId BIGINT NOT NULL, + ChampionshipId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + ResultConfigId BIGINT NOT NULL, + Name VARCHAR(80), + DisplayName VARCHAR(255), + Version INT DEFAULT 1 +); + +INSERT INTO TmpChampionships (LeagueId, ResultConfigId, Name, DisplayName) + SELECT LeagueId, ResultConfigId, Name, DisplayName + FROM ResultConfigurations; + +DELETE FROM Championships; + +INSERT INTO Championships (LeagueId, ChampionshipId, Name, DisplayName, Version) + SELECT LeagueId, ChampionshipId, Name, DisplayName, Version + FROM TmpChampionships; + +CREATE TEMPORARY TABLE TmpChampSeasons ( + LeagueId BIGINT NOT NULL, + ChampSeasonId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + ChampionshipId BIGINT NOT NULL, + SeasonId BIGINT NOT NULL, + StandingConfigId BIGINT +); + +INSERT INTO TmpChampSeasons (LeagueId, ChampionshipId, SeasonId, StandingConfigId) + SELECT c.LeagueId, c.ChampionshipId, sch.SeasonId, s.StandingConfigId + FROM ScoredEventResults AS er + JOIN Events AS ev + ON er.EventId=ev.EventId + JOIN Schedules AS sch + ON ev.ScheduleId=sch.ScheduleId + JOIN ResultConfigurations AS r + ON er.ResultConfigId=r.ResultConfigId + JOIN TmpChampionships AS c + ON r.ResultConfigId=c.ResultConfigId + JOIN StandingConfigs_ResultConfigs AS s_r + ON r.ResultConfigId=s_r.ResultConfigId + JOIN StandingConfigurations AS s + ON s_r.StandingConfigId=s.StandingConfigId + GROUP BY c.ChampionshipId, sch.SeasonId, s.StandingConfigId; + +INSERT INTO ChampSeasons + SELECT * FROM TmpChampSeasons; + +INSERT INTO ChampSeasons_ResultConfigs + SELECT cs.LeagueId, cs.ChampSeasonId, c.ResultConfigId + FROM TmpChampSeasons AS cs + JOIN TmpChampionships AS c + ON cs.ChampionshipId=c.ChampionshipId; + +UPDATE ScoredEventResults AS er + JOIN Events AS ev + ON er.EventId=ev.EventId + JOIN Schedules AS sch + ON ev.ScheduleId=sch.ScheduleId + JOIN ChampSeasons_ResultConfigs as cs_rc + ON er.ResultConfigId=cs_rc.ResultConfigId + JOIN ChampSeasons cs + ON cs_rc.ChampSeasonId=cs.ChampSeasonId + AND sch.SeasonId=cs.SeasonId + SET er.ChampSeasonId=cs.ChampSeasonId; + +UPDATE Standings AS s + JOIN ChampSeasons AS cs + ON s.StandingConfigId=cs.StandingConfigId + SET s.ChampSeasonId=cs.ChampSeasonId; + +DROP TABLE TmpChampionships; +DROP TABLE TmpChampSeasons; + "); + + migrationBuilder.DropTable( + name: "StandingConfigs_ResultConfigs"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ScoredEventResults_ChampSeasons_LeagueId_ChampSeasonId", + table: "ScoredEventResults"); + + migrationBuilder.DropForeignKey( + name: "FK_Standings_ChampSeasons_LeagueId_ChampSeasonId", + table: "Standings"); + + migrationBuilder.DropTable( + name: "ChampSeasons_ResultConfigs"); + + migrationBuilder.DropTable( + name: "ChampSeasons"); + + migrationBuilder.DropTable( + name: "Championships"); + + migrationBuilder.DropIndex( + name: "IX_Standings_LeagueId_ChampSeasonId", + table: "Standings"); + + migrationBuilder.DropIndex( + name: "IX_ScoredEventResults_LeagueId_ChampSeasonId", + table: "ScoredEventResults"); + + migrationBuilder.DropColumn( + name: "ChampSeasonId", + table: "Standings"); + + migrationBuilder.DropColumn( + name: "ChampSeasonId", + table: "ScoredEventResults"); + + migrationBuilder.CreateTable( + name: "StandingConfigs_ResultConfigs", + columns: table => new + { + ResultConfigId = table.Column(type: "bigint", nullable: false), + LeagueId = table.Column(type: "bigint", nullable: false), + StandingConfigId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_StandingConfigs_ResultConfigs", x => new { x.ResultConfigId, x.LeagueId, x.StandingConfigId }); + table.ForeignKey( + name: "FK_StandingConfigs_ResultConfigs_ResultConfigurations_LeagueId_~", + columns: x => new { x.LeagueId, x.ResultConfigId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_StandingConfigs_ResultConfigs_StandingConfigurations_LeagueI~", + columns: x => new { x.LeagueId, x.StandingConfigId }, + principalTable: "StandingConfigurations", + principalColumns: new[] { "LeagueId", "StandingConfigId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_StandingConfigs_ResultConfigs_LeagueId_ResultConfigId", + table: "StandingConfigs_ResultConfigs", + columns: new[] { "LeagueId", "ResultConfigId" }); + + migrationBuilder.CreateIndex( + name: "IX_StandingConfigs_ResultConfigs_LeagueId_StandingConfigId", + table: "StandingConfigs_ResultConfigs", + columns: new[] { "LeagueId", "StandingConfigId" }); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230204120733_AddStandingConfigToLeague.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230204120733_AddStandingConfigToLeague.Designer.cs new file mode 100644 index 00000000..49af841a --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230204120733_AddStandingConfigToLeague.Designer.cs @@ -0,0 +1,3701 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230204120733_AddStandingConfigToLeague")] + partial class AddStandingConfigToLeague + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasons_ResultConfigurations", b => + { + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.HasKey("ChampSeasonId", "LeagueId", "ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ChampSeasons_ResultConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasons_ResultConfigurations", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany() + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChampSeason"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230204120733_AddStandingConfigToLeague.cs b/src/iRLeagueDatabaseCore/Migrations/20230204120733_AddStandingConfigToLeague.cs new file mode 100644 index 00000000..acf0ad99 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230204120733_AddStandingConfigToLeague.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AddStandingConfigToLeague : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddForeignKey( + name: "FK_StandingConfigurations_Leagues_LeagueId", + table: "StandingConfigurations", + column: "LeagueId", + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_StandingConfigurations_Leagues_LeagueId", + table: "StandingConfigurations"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230218115909_ArchivableChampionship.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230218115909_ArchivableChampionship.Designer.cs new file mode 100644 index 00000000..3edaca29 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230218115909_ArchivableChampionship.Designer.cs @@ -0,0 +1,3728 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230218115909_ArchivableChampionship")] + partial class ArchivableChampionship + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasons_ResultConfigurations", b => + { + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.HasKey("ChampSeasonId", "LeagueId", "ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ChampSeasons_ResultConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasons_ResultConfigurations", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany() + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChampSeason"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230218115909_ArchivableChampionship.cs b/src/iRLeagueDatabaseCore/Migrations/20230218115909_ArchivableChampionship.cs new file mode 100644 index 00000000..f6439261 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230218115909_ArchivableChampionship.cs @@ -0,0 +1,112 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class ArchivableChampionship : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CreatedByUserId", + table: "ChampSeasons", + type: "longtext", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreatedByUserName", + table: "ChampSeasons", + type: "longtext", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreatedOn", + table: "ChampSeasons", + type: "datetime(6)", + nullable: true); + + migrationBuilder.AddColumn( + name: "IsActive", + table: "ChampSeasons", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "LastModifiedByUserId", + table: "ChampSeasons", + type: "longtext", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifiedByUserName", + table: "ChampSeasons", + type: "longtext", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifiedOn", + table: "ChampSeasons", + type: "datetime(6)", + nullable: true); + + migrationBuilder.AddColumn( + name: "Version", + table: "ChampSeasons", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "IsArchived", + table: "Championships", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + // activate all existing champ seasons + migrationBuilder.Sql("UPDATE ChampSeasons SET IsActive = 1;"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CreatedByUserId", + table: "ChampSeasons"); + + migrationBuilder.DropColumn( + name: "CreatedByUserName", + table: "ChampSeasons"); + + migrationBuilder.DropColumn( + name: "CreatedOn", + table: "ChampSeasons"); + + migrationBuilder.DropColumn( + name: "IsActive", + table: "ChampSeasons"); + + migrationBuilder.DropColumn( + name: "LastModifiedByUserId", + table: "ChampSeasons"); + + migrationBuilder.DropColumn( + name: "LastModifiedByUserName", + table: "ChampSeasons"); + + migrationBuilder.DropColumn( + name: "LastModifiedOn", + table: "ChampSeasons"); + + migrationBuilder.DropColumn( + name: "Version", + table: "ChampSeasons"); + + migrationBuilder.DropColumn( + name: "IsArchived", + table: "Championships"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230305101715_ResultConfigsManyToOneChampSeason.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230305101715_ResultConfigsManyToOneChampSeason.Designer.cs new file mode 100644 index 00000000..a65f67f2 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230305101715_ResultConfigsManyToOneChampSeason.Designer.cs @@ -0,0 +1,3704 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230305101715_ResultConfigsManyToOneChampSeason")] + partial class ResultConfigsManyToOneChampSeason + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230305101715_ResultConfigsManyToOneChampSeason.cs b/src/iRLeagueDatabaseCore/Migrations/20230305101715_ResultConfigsManyToOneChampSeason.cs new file mode 100644 index 00000000..6c416ff1 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230305101715_ResultConfigsManyToOneChampSeason.cs @@ -0,0 +1,99 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class ResultConfigsManyToOneChampSeason : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ChampSeasonId", + table: "ResultConfigurations", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.CreateIndex( + name: "IX_ResultConfigurations_LeagueId_ChampSeasonId", + table: "ResultConfigurations", + columns: new[] { "LeagueId", "ChampSeasonId" }); + + // Set foreign key for ChampSeasonId (may result in loss of information for ChampSeasons that share a result config + // Also deletes result configs that are not assigned to a ChampSeason + migrationBuilder.Sql(@" + DELETE r FROM ResultConfigurations r + LEFT JOIN ChampSeasons_ResultConfigs cr + ON cr.ResultConfigId=r.ResultConfigId + WHERE cr.ChampSeasonId is NULL; + + UPDATE ResultConfigurations r + JOIN ChampSeasons_ResultConfigs cr + ON cr.ResultConfigId=r.ResultConfigId + SET r.ChampSeasonId=cr.ChampSeasonId; + "); + + migrationBuilder.AddForeignKey( + name: "FK_ResultConfigurations_ChampSeasons_LeagueId_ChampSeasonId", + table: "ResultConfigurations", + columns: new[] { "LeagueId", "ChampSeasonId" }, + principalTable: "ChampSeasons", + principalColumns: new[] { "LeagueId", "ChampSeasonId" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.DropTable( + name: "ChampSeasons_ResultConfigs"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ResultConfigurations_ChampSeasons_LeagueId_ChampSeasonId", + table: "ResultConfigurations"); + + migrationBuilder.DropIndex( + name: "IX_ResultConfigurations_LeagueId_ChampSeasonId", + table: "ResultConfigurations"); + + migrationBuilder.DropColumn( + name: "ChampSeasonId", + table: "ResultConfigurations"); + + migrationBuilder.CreateTable( + name: "ChampSeasons_ResultConfigs", + columns: table => new + { + ChampSeasonId = table.Column(type: "bigint", nullable: false), + LeagueId = table.Column(type: "bigint", nullable: false), + ResultConfigId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChampSeasons_ResultConfigs", x => new { x.ChampSeasonId, x.LeagueId, x.ResultConfigId }); + table.ForeignKey( + name: "FK_ChampSeasons_ResultConfigs_ChampSeasons_LeagueId_ChampSeason~", + columns: x => new { x.LeagueId, x.ChampSeasonId }, + principalTable: "ChampSeasons", + principalColumns: new[] { "LeagueId", "ChampSeasonId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ChampSeasons_ResultConfigs_ResultConfigurations_LeagueId_Res~", + columns: x => new { x.LeagueId, x.ResultConfigId }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ChampSeasons_ResultConfigs_LeagueId_ChampSeasonId", + table: "ChampSeasons_ResultConfigs", + columns: new[] { "LeagueId", "ChampSeasonId" }); + + migrationBuilder.CreateIndex( + name: "IX_ChampSeasons_ResultConfigs_LeagueId_ResultConfigId", + table: "ChampSeasons_ResultConfigs", + columns: new[] { "LeagueId", "ResultConfigId" }); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230330143121_LeaguePrivacy.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230330143121_LeaguePrivacy.Designer.cs new file mode 100644 index 00000000..55fa8bfa --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230330143121_LeaguePrivacy.Designer.cs @@ -0,0 +1,3707 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230330143121_LeaguePrivacy")] + partial class LeaguePrivacy + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230330143121_LeaguePrivacy.cs b/src/iRLeagueDatabaseCore/Migrations/20230330143121_LeaguePrivacy.cs new file mode 100644 index 00000000..0094e91b --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230330143121_LeaguePrivacy.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class LeaguePrivacy : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LeaguePublic", + table: "Leagues", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LeaguePublic", + table: "Leagues"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230406144016_LeagueDescription.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230406144016_LeagueDescription.Designer.cs new file mode 100644 index 00000000..5c63aa3b --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230406144016_LeagueDescription.Designer.cs @@ -0,0 +1,3713 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230406144016_LeagueDescription")] + partial class LeagueDescription + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230406144016_LeagueDescription.cs b/src/iRLeagueDatabaseCore/Migrations/20230406144016_LeagueDescription.cs new file mode 100644 index 00000000..590d85f5 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230406144016_LeagueDescription.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class LeagueDescription : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Description", + table: "Leagues", + type: "longtext", + nullable: true); + + migrationBuilder.AddColumn( + name: "DescriptionPlain", + table: "Leagues", + type: "longtext", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Description", + table: "Leagues"); + + migrationBuilder.DropColumn( + name: "DescriptionPlain", + table: "Leagues"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230507114234_AddLeagueInitializedColumn.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230507114234_AddLeagueInitializedColumn.Designer.cs new file mode 100644 index 00000000..71bd4aa7 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230507114234_AddLeagueInitializedColumn.Designer.cs @@ -0,0 +1,3716 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230507114234_AddLeagueInitializedColumn")] + partial class AddLeagueInitializedColumn + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230507114234_AddLeagueInitializedColumn.cs b/src/iRLeagueDatabaseCore/Migrations/20230507114234_AddLeagueInitializedColumn.cs new file mode 100644 index 00000000..3613f0c0 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230507114234_AddLeagueInitializedColumn.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AddLeagueInitializedColumn : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsInitialized", + table: "Leagues", + type: "tinyint(1)", + nullable: false, + defaultValue: true); + + migrationBuilder.AlterColumn( + name: "IsInitialized", + table: "Leagues", + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsInitialized", + table: "Leagues"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230531145825_ChampSeason_DefaultResultConfig.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230531145825_ChampSeason_DefaultResultConfig.Designer.cs new file mode 100644 index 00000000..16610031 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230531145825_ChampSeason_DefaultResultConfig.Designer.cs @@ -0,0 +1,3727 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230531145825_ChampSeason_DefaultResultConfig")] + partial class ChampSeason_DefaultResultConfig + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithOne("AddPenalty") + .HasForeignKey("iRLeagueDatabaseCore.Models.AddPenaltyEntity", "LeagueId", "ScoredResultRowId") + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalty"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230531145825_ChampSeason_DefaultResultConfig.cs b/src/iRLeagueDatabaseCore/Migrations/20230531145825_ChampSeason_DefaultResultConfig.cs new file mode 100644 index 00000000..ed7631a3 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230531145825_ChampSeason_DefaultResultConfig.cs @@ -0,0 +1,45 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class ChampSeason_DefaultResultConfig : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DefaultResultConfigId", + table: "ChampSeasons", + type: "bigint", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_ChampSeasons_LeagueId_DefaultResultConfigId", + table: "ChampSeasons", + columns: new[] { "LeagueId", "DefaultResultConfigId" }); + + migrationBuilder.AddForeignKey( + name: "FK_ChampSeasons_ResultConfigurations_LeagueId_DefaultResultConf~", + table: "ChampSeasons", + columns: new[] { "LeagueId", "DefaultResultConfigId" }, + principalTable: "ResultConfigurations", + principalColumns: new[] { "LeagueId", "ResultConfigId" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ChampSeasons_ResultConfigurations_LeagueId_DefaultResultConf~", + table: "ChampSeasons"); + + migrationBuilder.DropIndex( + name: "IX_ChampSeasons_LeagueId_DefaultResultConfigId", + table: "ChampSeasons"); + + migrationBuilder.DropColumn( + name: "DefaultResultConfigId", + table: "ChampSeasons"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230603160948_DropAddPenaltyTable.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230603160948_DropAddPenaltyTable.Designer.cs new file mode 100644 index 00000000..33bf83a3 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230603160948_DropAddPenaltyTable.Designer.cs @@ -0,0 +1,3697 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230603160948_DropAddPenaltyTable")] + partial class DropAddPenaltyTable + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230603160948_DropAddPenaltyTable.cs b/src/iRLeagueDatabaseCore/Migrations/20230603160948_DropAddPenaltyTable.cs new file mode 100644 index 00000000..fbb0eb26 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230603160948_DropAddPenaltyTable.cs @@ -0,0 +1,41 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class DropAddPenaltyTable : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AddPenaltys"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AddPenaltys", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ScoredResultRowId = table.Column(type: "bigint", nullable: false), + PenaltyPoints = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AddPenaltys", x => new { x.LeagueId, x.ScoredResultRowId }); + table.ForeignKey( + name: "FK_AddPenaltys_ScoredResultRows_LeagueId_ScoredResultRowId", + columns: x => new { x.LeagueId, x.ScoredResultRowId }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }); + }); + + migrationBuilder.CreateIndex( + name: "IX_AddPenaltys_LeagueId_ScoredResultRowId", + table: "AddPenaltys", + columns: new[] { "LeagueId", "ScoredResultRowId" }); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230603161313_PenaltyValueJsonColumn.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230603161313_PenaltyValueJsonColumn.Designer.cs new file mode 100644 index 00000000..053e79f7 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230603161313_PenaltyValueJsonColumn.Designer.cs @@ -0,0 +1,3734 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230603161313_PenaltyValueJsonColumn")] + partial class PenaltyValueJsonColumn + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230603161313_PenaltyValueJsonColumn.cs b/src/iRLeagueDatabaseCore/Migrations/20230603161313_PenaltyValueJsonColumn.cs new file mode 100644 index 00000000..35c9b653 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230603161313_PenaltyValueJsonColumn.cs @@ -0,0 +1,92 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using MySql.EntityFrameworkCore.Metadata; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class PenaltyValueJsonColumn : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(@" + -- Pre migration + -- Create Temporary table holding the pointValues + CREATE TEMPORARY TABLE TmpPenaltyPoints ( + LeagueId BIGINT NOT NULL, + ResultRowId BIGINT NOT NULL, + ReviewId BIGINT NOT NULL, + PenaltyPoints INT NOT NULL, + PRIMARY KEY (LeagueId, ResultRowId, ReviewId) + ); + + INSERT INTO TmpPenaltyPoints (LeagueId, ResultRowId, ReviewId, PenaltyPoints) + SELECT LeagueId, ResultRowId, ReviewId, PenaltyPoints + FROM ReviewPenaltys; + "); + + migrationBuilder.DropColumn( + name: "PenaltyPoints", + table: "ReviewPenaltys"); + + migrationBuilder.AddColumn( + name: "Value", + table: "ReviewPenaltys", + type: "json", + nullable: true); + + migrationBuilder.CreateTable( + name: "AddPenaltys", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + AddPenaltyId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + ScoredResultRowId = table.Column(type: "bigint", nullable: false), + Value = table.Column(type: "json", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AddPenaltys", x => new { x.LeagueId, x.AddPenaltyId }); + table.UniqueConstraint("AK_AddPenaltys_AddPenaltyId", x => x.AddPenaltyId); + table.ForeignKey( + name: "FK_AddPenaltys_ScoredResultRows_LeagueId_ScoredResultRowId", + columns: x => new { x.LeagueId, x.ScoredResultRowId }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }); + }); + + migrationBuilder.CreateIndex( + name: "IX_AddPenaltys_LeagueId_ScoredResultRowId", + table: "AddPenaltys", + columns: new[] { "LeagueId", "ScoredResultRowId" }); + + migrationBuilder.Sql(@" + -- Post migration + UPDATE ReviewPenaltys AS rp + JOIN TmpPenaltyPoints AS tmp + ON rp.ResultRowId=tmp.ResultRowId AND rp.ReviewId=tmp.ReviewId + SET rp.`Value` = CONCAT('{\""Type\"": 0, \""Points\"": ', tmp.PenaltyPoints, '}'); + + DROP TABLE TmpPenaltyPoints; + "); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AddPenaltys"); + + migrationBuilder.DropColumn( + name: "Value", + table: "ReviewPenaltys"); + + migrationBuilder.AddColumn( + name: "PenaltyPoints", + table: "ReviewPenaltys", + type: "int", + nullable: false, + defaultValue: 0); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230603235606_EnableMultipleReviewPenalties.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230603235606_EnableMultipleReviewPenalties.Designer.cs new file mode 100644 index 00000000..2a8c358b --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230603235606_EnableMultipleReviewPenalties.Designer.cs @@ -0,0 +1,3735 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230603235606_EnableMultipleReviewPenalties")] + partial class EnableMultipleReviewPenalties + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230603235606_EnableMultipleReviewPenalties.cs b/src/iRLeagueDatabaseCore/Migrations/20230603235606_EnableMultipleReviewPenalties.cs new file mode 100644 index 00000000..1e2c116b --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230603235606_EnableMultipleReviewPenalties.cs @@ -0,0 +1,129 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class EnableMultipleReviewPenalties : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(@" + -- Pre migration + -- Copy data to temp table before dropping + CREATE TEMPORARY TABLE TmpReviewPenaltys( + LeagueId BIGINT NOT NULL, + ResultRowId BIGINT NOT NULL, + ReviewId BIGINT NOT NULL, + ReviewVoteId BIGINT NOT NULL, + `Value` JSON NULL, + PRIMARY KEY (LeagueId, ResultRowId, ReviewId, ReviewVoteId) + ); + + INSERT INTO TmpReviewPenaltys + SELECT * FROM ReviewPenaltys; + + -- drop table and create new with corrct primary key + DROP TABLE ReviewPenaltys; + CREATE TABLE ReviewPenaltys( + LeagueId BIGINT NOT NULL, + ResultRowId BIGINT NOT NULL, + ReviewId BIGINT NOT NULL, + ReviewVoteId BIGINT NOT NULL, + `Value` JSON NULL, + PRIMARY KEY (LeagueId, ResultRowId, ReviewId, ReviewVoteId) + ); + -- Handle creation of indexes and fk inside ef migration + "); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_LeagueId_ResultRowId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ResultRowId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_LeagueId_ReviewId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ReviewId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_LeagueId_ReviewVoteId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ReviewVoteId" }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_ReviewId", + table: "ReviewPenaltys", + column: "ReviewId"); + + migrationBuilder.CreateIndex( + name: "IX_ReviewPenaltys_ReviewVoteId", + table: "ReviewPenaltys", + column: "ReviewVoteId"); + + migrationBuilder.AddForeignKey( + name: "FK_ReviewPenaltys_AcceptedReviewVotes_LeagueId_ReviewVoteId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ReviewVoteId" }, + principalTable: "AcceptedReviewVotes", + principalColumns: new[] { "LeagueId", "ReviewVoteId" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_ReviewPenaltys_IncidentReviews_LeagueId_ReviewId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ReviewId" }, + principalTable: "IncidentReviews", + principalColumns: new[] { "LeagueId", "ReviewId" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_ReviewPenaltys_ScoredResultRows_LeagueId_ResultRowId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ResultRowId" }, + principalTable: "ScoredResultRows", + principalColumns: new[] { "LeagueId", "ScoredResultRowId" }, + onDelete: ReferentialAction.Cascade); + + migrationBuilder.Sql(@" + -- Post migration + -- Copy data into newly created table after creation of indexes and fk + INSERT INTO ReviewPenaltys + SELECT * FROM TmpReviewPenaltys; + + DROP TABLE TmpReviewPenaltys; + "); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ReviewPenaltys_AcceptedReviewVotes_LeagueId_ReviewVoteId", + table: "ReviewPenaltys"); + + migrationBuilder.DropPrimaryKey( + name: "PK_ReviewPenaltys", + table: "ReviewPenaltys"); + + migrationBuilder.AlterColumn( + name: "ReviewVoteId", + table: "ReviewPenaltys", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AddPrimaryKey( + name: "PK_ReviewPenaltys", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ResultRowId", "ReviewId" }); + + migrationBuilder.AddForeignKey( + name: "FK_ReviewPenaltys_AcceptedReviewVotes_LeagueId_ReviewVoteId", + table: "ReviewPenaltys", + columns: new[] { "LeagueId", "ReviewVoteId" }, + principalTable: "AcceptedReviewVotes", + principalColumns: new[] { "LeagueId", "ReviewVoteId" }); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230604113838_AddPenaltyReason.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230604113838_AddPenaltyReason.Designer.cs new file mode 100644 index 00000000..b0e1e647 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230604113838_AddPenaltyReason.Designer.cs @@ -0,0 +1,3739 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230604113838_AddPenaltyReason")] + partial class AddPenaltyReason + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230604113838_AddPenaltyReason.cs b/src/iRLeagueDatabaseCore/Migrations/20230604113838_AddPenaltyReason.cs new file mode 100644 index 00000000..4923baa4 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230604113838_AddPenaltyReason.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AddPenaltyReason : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Reason", + table: "AddPenaltys", + type: "varchar(2048)", + maxLength: 2048, + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Reason", + table: "AddPenaltys"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230609015208_AddPenaltyLapCorner.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230609015208_AddPenaltyLapCorner.Designer.cs new file mode 100644 index 00000000..b30502dd --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230609015208_AddPenaltyLapCorner.Designer.cs @@ -0,0 +1,3747 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230609015208_AddPenaltyLapCorner")] + partial class AddPenaltyLapCorner + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230609015208_AddPenaltyLapCorner.cs b/src/iRLeagueDatabaseCore/Migrations/20230609015208_AddPenaltyLapCorner.cs new file mode 100644 index 00000000..76404da1 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230609015208_AddPenaltyLapCorner.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AddPenaltyLapCorner : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Corner", + table: "AddPenaltys", + type: "varchar(255)", + maxLength: 255, + nullable: true); + + migrationBuilder.AddColumn( + name: "Lap", + table: "AddPenaltys", + type: "varchar(255)", + maxLength: 255, + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Corner", + table: "AddPenaltys"); + + migrationBuilder.DropColumn( + name: "Lap", + table: "AddPenaltys"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230622051947_LeagueSubscription.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230622051947_LeagueSubscription.Designer.cs new file mode 100644 index 00000000..482203ea --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230622051947_LeagueSubscription.Designer.cs @@ -0,0 +1,3753 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230622051947_LeagueSubscription")] + partial class LeagueSubscription + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230622051947_LeagueSubscription.cs b/src/iRLeagueDatabaseCore/Migrations/20230622051947_LeagueSubscription.cs new file mode 100644 index 00000000..d16dccf1 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230622051947_LeagueSubscription.cs @@ -0,0 +1,37 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class LeagueSubscription : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Expires", + table: "Leagues", + type: "datetime(6)", + nullable: true); + + migrationBuilder.AddColumn( + name: "Subscription", + table: "Leagues", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Expires", + table: "Leagues"); + + migrationBuilder.DropColumn( + name: "Subscription", + table: "Leagues"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230625063051_PaymentEntities.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230625063051_PaymentEntities.Designer.cs new file mode 100644 index 00000000..a701fe0c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230625063051_PaymentEntities.Designer.cs @@ -0,0 +1,3843 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230625063051_PaymentEntities")] + partial class PaymentEntities + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230625063051_PaymentEntities.cs b/src/iRLeagueDatabaseCore/Migrations/20230625063051_PaymentEntities.cs new file mode 100644 index 00000000..76ad5e57 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230625063051_PaymentEntities.cs @@ -0,0 +1,76 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class PaymentEntities : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Subscriptions", + columns: table => new + { + PlanId = table.Column(type: "varchar(255)", nullable: false), + Name = table.Column(type: "varchar(255)", maxLength: 255, nullable: false), + Interval = table.Column(type: "int", nullable: false), + Price = table.Column(type: "double", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Subscriptions", x => x.PlanId); + }); + + migrationBuilder.CreateTable( + name: "Payments", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + PlanId = table.Column(type: "varchar(255)", maxLength: 255, nullable: true), + SubscriptionId = table.Column(type: "varchar(255)", maxLength: 255, nullable: true), + LeagueId = table.Column(type: "bigint", nullable: false), + UserId = table.Column(type: "varchar(255)", maxLength: 255, nullable: false), + Type = table.Column(type: "longtext", nullable: false), + LastPaymentReceived = table.Column(type: "datetime(6)", nullable: false), + NextPaymentDue = table.Column(type: "datetime(6)", nullable: true), + Status = table.Column(type: "longtext", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Payments", x => x.Id); + table.ForeignKey( + name: "FK_Payments_Leagues_LeagueId", + column: x => x.LeagueId, + principalTable: "Leagues", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Payments_Subscriptions_PlanId", + column: x => x.PlanId, + principalTable: "Subscriptions", + principalColumn: "PlanId"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Payments_LeagueId", + table: "Payments", + column: "LeagueId"); + + migrationBuilder.CreateIndex( + name: "IX_Payments_PlanId", + table: "Payments", + column: "PlanId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Payments"); + + migrationBuilder.DropTable( + name: "Subscriptions"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230721102020_AutoPenaltyConfiguration.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230721102020_AutoPenaltyConfiguration.Designer.cs new file mode 100644 index 00000000..d5bd78fb --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230721102020_AutoPenaltyConfiguration.Designer.cs @@ -0,0 +1,3800 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230721102020_AutoPenaltyConfiguration")] + partial class AutoPenaltyConfiguration + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230721102020_AutoPenaltyConfiguration.cs b/src/iRLeagueDatabaseCore/Migrations/20230721102020_AutoPenaltyConfiguration.cs new file mode 100644 index 00000000..364d7b65 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230721102020_AutoPenaltyConfiguration.cs @@ -0,0 +1,52 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using MySql.EntityFrameworkCore.Metadata; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AutoPenaltyConfiguration : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AutoPenaltyConfigs", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + PenaltyConfigId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + PointRuleId = table.Column(type: "bigint", nullable: false), + Description = table.Column(type: "longtext", nullable: true), + Type = table.Column(type: "int", nullable: false), + Points = table.Column(type: "int", nullable: false), + Time = table.Column(type: "time(6)", nullable: false), + Positions = table.Column(type: "int", nullable: false), + Conditions = table.Column(type: "json", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AutoPenaltyConfigs", x => new { x.LeagueId, x.PenaltyConfigId }); + table.UniqueConstraint("AK_AutoPenaltyConfigs_PenaltyConfigId", x => x.PenaltyConfigId); + table.ForeignKey( + name: "FK_AutoPenaltyConfigs_PointRules_LeagueId_PointRuleId", + columns: x => new { x.LeagueId, x.PointRuleId }, + principalTable: "PointRules", + principalColumns: new[] { "LeagueId", "PointRuleId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AutoPenaltyConfigs_LeagueId_PointRuleId", + table: "AutoPenaltyConfigs", + columns: new[] { "LeagueId", "PointRuleId" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AutoPenaltyConfigs"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230814213200_AddIracingTeamIdColumn.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230814213200_AddIracingTeamIdColumn.Designer.cs new file mode 100644 index 00000000..61fdb62a --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230814213200_AddIracingTeamIdColumn.Designer.cs @@ -0,0 +1,3899 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230814213200_AddIracingTeamIdColumn")] + partial class AddIracingTeamIdColumn + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ConditionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ColumnPropertyName") + .HasColumnType("longtext"); + + b.Property("Comparator") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterOptionId") + .HasColumnType("bigint"); + + b.Property("FilterType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FilterValues") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "ConditionId"); + + b.HasAlternateKey("ConditionId"); + + b.HasIndex("LeagueId", "FilterOptionId"); + + b.ToTable("FilterConditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterConditionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.FilterOptionEntity", "FilterOption") + .WithMany("Conditions") + .HasForeignKey("LeagueId", "FilterOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FilterOption"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Navigation("Conditions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230814213200_AddIracingTeamIdColumn.cs b/src/iRLeagueDatabaseCore/Migrations/20230814213200_AddIracingTeamIdColumn.cs new file mode 100644 index 00000000..c42ca14a --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230814213200_AddIracingTeamIdColumn.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AddIracingTeamIdColumn : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IRacingTeamId", + table: "Teams", + type: "bigint", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IRacingTeamId", + table: "Teams"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230822204602_UseJsonFiltersOnResultConfig.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230822204602_UseJsonFiltersOnResultConfig.Designer.cs new file mode 100644 index 00000000..449cb5ce --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230822204602_UseJsonFiltersOnResultConfig.Designer.cs @@ -0,0 +1,3848 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230822204602_UseJsonFiltersOnResultConfig")] + partial class UseJsonFiltersOnResultConfig + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230822204602_UseJsonFiltersOnResultConfig.cs b/src/iRLeagueDatabaseCore/Migrations/20230822204602_UseJsonFiltersOnResultConfig.cs new file mode 100644 index 00000000..17271e5c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230822204602_UseJsonFiltersOnResultConfig.cs @@ -0,0 +1,140 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using MySql.EntityFrameworkCore.Metadata; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class UseJsonFiltersOnResultConfig : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(@" + -- Pre migration + -- Create Temporary table holding the filter conditions before dropping table + CREATE TEMPORARY TABLE TmpFilterConditions ( + LeagueId BIGINT NOT NULL, + ConditionId BIGINT NOT NULL, + FilterOptionId BIGINT NOT NULL, + FilterType LONGTEXT NOT NULL, + ColumnPropertyName LONGTEXT NULL, + Comparator LONGTEXT NOT NULL, + `Action` LONGTEXT NOT NULL, + FilterValues LONGTEXT NULL, + PRIMARY KEY (LeagueId, ConditionId) + ); + + INSERT INTO TmpFilterConditions (LeagueId, ConditionId, FilterOptionId, FilterType, ColumnPropertyName, Comparator, Action, FilterValues) + SELECT LeagueId, ConditionId, FilterOptionId, FilterType, ColumnPropertyName, Comparator, Action, FilterValues + FROM FilterConditions; + "); + + migrationBuilder.DropTable( + name: "FilterConditions"); + + migrationBuilder.AddColumn( + name: "Conditions", + table: "FilterOptions", + type: "json", + nullable: false); + + migrationBuilder.Sql(@" + -- Post migration + -- Create function to convert Filter values from single string into json array + DROP FUNCTION IF EXISTS splitStringToJsonArray; + + CREATE FUNCTION splitStringToJsonArray( + inputString TEXT, + delimiterChar CHAR(1)) + RETURNS TEXT + DETERMINISTIC + BEGIN + DECLARE temp_string TEXT; + SET temp_string = '[""'; + WHILE LOCATE(delimiterChar,inputString) > 1 DO + SET temp_string = CONCAT(temp_string, SUBSTRING_INDEX(inputString,delimiterChar,1), '"",""'); + SET inputString = REGEXP_REPLACE(inputString, ( + SELECT LEFT(inputString, LOCATE(delimiterChar, inputString)) + ),'',1,1); + END WHILE; + SET temp_string = CONCAT(temp_string, inputString, '""]'); + RETURN temp_string; + END; + + -- Populate `Conditions` column with stored values and perform necessary value conversions + UPDATE FilterOptions AS f + JOIN (SELECT FilterOptionId, + CASE FilterType + WHEN 'ColumnProperty' THEN 0 + WHEN 'Member' THEN 1 + WHEN 'Team' THEN 2 + END AS FilterType, + ColumnPropertyName, + CASE Comparator + WHEN 'IsSmaller' THEN 0 + WHEN 'IsSmallerOrEqual' THEN 1 + WHEN 'IsEqual' THEN 2 + WHEN 'IsBiggerOrEqual' THEN 3 + WHEN 'IsBigger' THEN 4 + WHEN 'NotEqual' THEN 5 + WHEN 'InList' THEN 6 + WHEN 'ForEach' THEN 7 + END AS Comparator, + CASE `Action` + WHEN 'Keep' THEN 0 + WHEN 'Remove' THEN 1 + END AS `Action`, + FilterValues + FROM TmpFilterConditions) AS fc + ON fc.FilterOptionId = f.FilterOptionId + SET f.Conditions = CONCAT( + '[{""Action"": ', fc.`Action`, + ', ""Comparator"": ', fc.Comparator, + ', ""FilterType"": ', fc.FilterType, + ', ""FilterValues"": ', splitStringToJsonArray(fc.FilterValues, ';'), + ', ""ColumnPropertyName"": ""', fc.ColumnPropertyName, '""}]'); + + DROP TABLE TmpFilterConditions; + DROP FUNCTION splitStringToJsonArray; + "); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Conditions", + table: "FilterOptions"); + + migrationBuilder.CreateTable( + name: "FilterConditions", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ConditionId = table.Column(type: "bigint", nullable: false) + .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), + FilterOptionId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "longtext", nullable: false), + ColumnPropertyName = table.Column(type: "longtext", nullable: true), + Comparator = table.Column(type: "longtext", nullable: false), + FilterType = table.Column(type: "longtext", nullable: false), + FilterValues = table.Column(type: "longtext", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_FilterConditions", x => new { x.LeagueId, x.ConditionId }); + table.UniqueConstraint("AK_FilterConditions_ConditionId", x => x.ConditionId); + table.ForeignKey( + name: "FK_FilterConditions_FilterOptions_LeagueId_FilterOptionId", + columns: x => new { x.LeagueId, x.FilterOptionId }, + principalTable: "FilterOptions", + principalColumns: new[] { "LeagueId", "FilterOptionId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_FilterConditions_LeagueId_FilterOptionId", + table: "FilterConditions", + columns: new[] { "LeagueId", "FilterOptionId" }); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230825195540_FiltersForChampSeasons.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230825195540_FiltersForChampSeasons.Designer.cs new file mode 100644 index 00000000..82bbb726 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230825195540_FiltersForChampSeasons.Designer.cs @@ -0,0 +1,3862 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230825195540_FiltersForChampSeasons")] + partial class FiltersForChampSeasons + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230825195540_FiltersForChampSeasons.cs b/src/iRLeagueDatabaseCore/Migrations/20230825195540_FiltersForChampSeasons.cs new file mode 100644 index 00000000..67abae8c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230825195540_FiltersForChampSeasons.cs @@ -0,0 +1,57 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class FiltersForChampSeasons : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ChampSeasonId", + table: "FilterOptions", + type: "bigint", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_FilterOptions_LeagueId_ChampSeasonId", + table: "FilterOptions", + columns: new[] { "LeagueId", "ChampSeasonId" }); + + migrationBuilder.AddForeignKey( + name: "FK_FilterOptions_ChampSeasons_LeagueId_ChampSeasonId", + table: "FilterOptions", + columns: new[] { "LeagueId", "ChampSeasonId" }, + principalTable: "ChampSeasons", + principalColumns: new[] { "LeagueId", "ChampSeasonId" }); + + migrationBuilder.Sql(@" + UPDATE FilterOptions AS f + JOIN ResultConfigurations AS rc + ON rc.ResultConfigId=f.ResultFilterResultConfigId + JOIN ChampSeasons AS cs + ON cs.ChampSeasonId=rc.ChampSeasonId + JOIN Seasons AS s + ON cs.SeasonId=s.SeasonId + SET f.ChampSeasonId = rc.ChampSeasonId, f.ResultFilterResultConfigId=NULL + WHERE s.Finished=0 AND cs.IsActive; + "); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_FilterOptions_ChampSeasons_LeagueId_ChampSeasonId", + table: "FilterOptions"); + + migrationBuilder.DropIndex( + name: "IX_FilterOptions_LeagueId_ChampSeasonId", + table: "FilterOptions"); + + migrationBuilder.DropColumn( + name: "ChampSeasonId", + table: "FilterOptions"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230831210711_ChangeBonusPointColumnTypeToJson.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230831210711_ChangeBonusPointColumnTypeToJson.Designer.cs new file mode 100644 index 00000000..02e62b98 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230831210711_ChangeBonusPointColumnTypeToJson.Designer.cs @@ -0,0 +1,3863 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230831210711_ChangeBonusPointColumnTypeToJson")] + partial class ChangeBonusPointColumnTypeToJson + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230831210711_ChangeBonusPointColumnTypeToJson.cs b/src/iRLeagueDatabaseCore/Migrations/20230831210711_ChangeBonusPointColumnTypeToJson.cs new file mode 100644 index 00000000..efac5bbb --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230831210711_ChangeBonusPointColumnTypeToJson.cs @@ -0,0 +1,115 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class ChangeBonusPointColumnTypeToJson : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(@" + -- Create Temporary table holding the bonus points before changing column type + CREATE TEMPORARY TABLE TmpBonusPoints ( + LeagueId BIGINT NOT NULL, + PointRuleId BIGINT NOT NULL PRIMARY KEY, + BonusPoints TEXT + ); + + INSERT INTO TmpBonusPoints (LeagueId, PointRuleId, BonusPoints) + SELECT LeagueId, PointRuleId, BonusPoints + FROM PointRules; + + UPDATE PointRules + SET BonusPoints='[]'; + "); + + migrationBuilder.AlterColumn( + name: "BonusPoints", + table: "PointRules", + type: "json", + nullable: false, + defaultValue: null, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true); + + migrationBuilder.Sql(@" + -- Create function to convert bonus values from single string into json array + DROP FUNCTION IF EXISTS splitStringToBonusPoints; + + CREATE FUNCTION splitStringToBonusPoints(inputString TEXT, + pointDelimiter TEXT) + RETURNS TEXT + DETERMINISTIC + BEGIN + DECLARE bonusType TEXT; + DECLARE bonusValue TEXT; + DECLARE bonusPoints TEXT; + SET bonusType = SUBSTRING_INDEX(inputString,pointDelimiter,1); + SET bonusPoints = SUBSTRING(SUBSTRING_INDEX(inputString,pointDelimiter,2), LENGTH(bonusType)+2, 10); + SET bonusValue = IF(LENGTH(bonusType)>1, SUBSTRING(bonusType, 2, 10), '0'); + SET bonusType = SUBSTRING(bonusType, 1, 1); + SET bonusType = CASE bonusType + WHEN 'p' THEN '0' + WHEN 'q' THEN '1' + WHEN 'f' THEN '2' + WHEN 'a' THEN '3' + WHEN 'c' THEN '4' + WHEN 'n' THEN '5' + WHEN 'g' THEN '6' + WHEN 'd' THEN '7' + WHEN 'l' THEN '8' + WHEN 'm' THEN '9' + END; + RETURN CONCAT('{""Type"":',bonusType,',""Value"":',bonusValue,',""Points"":',bonusPoints,',""Conditions"":[]}'); + END; + + DROP FUNCTION IF EXISTS splitToArray; + + CREATE FUNCTION splitToArray( + inputString TEXT, + arrayDelimiter TEXT, + pointDelimiter TEXT) + RETURNS TEXT + DETERMINISTIC + BEGIN + DECLARE tempString TEXT; + SET tempString = '['; + WHILE LOCATE(arrayDelimiter,inputString) > 1 DO + SET tempString = CONCAT(tempString, splitStringToBonusPoints(SUBSTRING_INDEX(inputString,arrayDelimiter,1), pointDelimiter), ','); + SET inputString = REGEXP_REPLACE(inputString, ( + SELECT LEFT(inputString, LOCATE(arrayDelimiter, inputString)) + ),'',1,1); + END WHILE; + SET tempString = CONCAT(tempString, splitStringToBonusPoints(SUBSTRING_INDEX(inputString,arrayDelimiter,1), pointDelimiter), ']'); + RETURN tempString; + END; + + -- Populate `Conditions` column with stored values and perform necessary value conversions + UPDATE TmpBonusPoints + SET BonusPoints = splitToArray(BonusPoints, ';', ':'); + UPDATE PointRules AS pr + JOIN TmpBonusPoints AS tmp + ON tmp.PointRuleId=pr.PointRuleId + SET pr.BonusPoints = tmp.BonusPoints + WHERE tmp.BonusPoints IS NOT NULL; + + DROP TABLE TmpBonusPoints; + DROP FUNCTION splitToArray; + DROP FUNCTION splitStringToBonusPoints; + "); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "BonusPoints", + table: "PointRules", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "json"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230904070324_AddRacesScored.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230904070324_AddRacesScored.Designer.cs new file mode 100644 index 00000000..51807382 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230904070324_AddRacesScored.Designer.cs @@ -0,0 +1,3868 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230904070324_AddRacesScored")] + partial class AddRacesScored + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("RacesScored") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230904070324_AddRacesScored.cs b/src/iRLeagueDatabaseCore/Migrations/20230904070324_AddRacesScored.cs new file mode 100644 index 00000000..9d3a59dc --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230904070324_AddRacesScored.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AddRacesScored : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "RacesInPoints", + table: "StandingRows", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "RacesScored", + table: "StandingRows", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "RacesInPoints", + table: "StandingRows"); + + migrationBuilder.DropColumn( + name: "RacesScored", + table: "StandingRows"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230910190957_MoveResultKindToChampSeasonTable.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230910190957_MoveResultKindToChampSeasonTable.Designer.cs new file mode 100644 index 00000000..bde61ad1 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230910190957_MoveResultKindToChampSeasonTable.Designer.cs @@ -0,0 +1,3870 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230910190957_MoveResultKindToChampSeasonTable")] + partial class MoveResultKindToChampSeasonTable + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("ResultKind") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("RacesScored") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230910190957_MoveResultKindToChampSeasonTable.cs b/src/iRLeagueDatabaseCore/Migrations/20230910190957_MoveResultKindToChampSeasonTable.cs new file mode 100644 index 00000000..9d923857 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230910190957_MoveResultKindToChampSeasonTable.cs @@ -0,0 +1,63 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class MoveResultKindToChampSeasonTable : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(@" + CREATE TEMPORARY TABLE TmpResultConfigKinds( + LeagueId BIGINT NOT NULL, + ResultConfigId BIGINT NOT NULL, + ChampSeasonId BIGINT NOT NULL, + ResultKind VARCHAR(50) NOT NULL, + PRIMARY KEY(LeagueId, ResultConfigId) + ); + + INSERT INTO TmpResultConfigKinds(LeagueId, ResultConfigId, ChampSeasonId, ResultKind) + SELECT LeagueId, ResultConfigId, ChampSeasonId, ResultKind FROM ResultConfigurations; + "); + + migrationBuilder.DropColumn( + name: "ResultKind", + table: "ResultConfigurations"); + + migrationBuilder.AddColumn( + name: "ResultKind", + table: "ChampSeasons", + type: "varchar(50)", + maxLength: 50, + nullable: false, + defaultValue: ""); + + migrationBuilder.Sql(@" + UPDATE ChampSeasons AS cs + JOIN TmpResultConfigKinds as rc + ON cs.ChampSeasonId=rc.ChampSeasonId + SET cs.ResultKind=rc.ResultKind; + + UPDATE ChampSeasons + SET ResultKind='Member' + WHERE ResultKind=''; + + DROP TABLE TmpResultConfigKinds; + "); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ResultKind", + table: "ChampSeasons"); + + migrationBuilder.AddColumn( + name: "ResultKind", + table: "ResultConfigurations", + type: "longtext", + nullable: false); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230911052834_LiveProtestFormSettings.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230911052834_LiveProtestFormSettings.Designer.cs new file mode 100644 index 00000000..5bffbe5d --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230911052834_LiveProtestFormSettings.Designer.cs @@ -0,0 +1,3876 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230911052834_LiveProtestFormSettings")] + partial class LiveProtestFormSettings + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("ResultKind") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableLiveReviews") + .HasColumnType("tinyint(1)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestFormAccess") + .HasColumnType("int"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("RacesScored") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230911052834_LiveProtestFormSettings.cs b/src/iRLeagueDatabaseCore/Migrations/20230911052834_LiveProtestFormSettings.cs new file mode 100644 index 00000000..63263993 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230911052834_LiveProtestFormSettings.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class LiveProtestFormSettings : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "EnableLiveReviews", + table: "Leagues", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "ProtestFormAccess", + table: "Leagues", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "EnableLiveReviews", + table: "Leagues"); + + migrationBuilder.DropColumn( + name: "ProtestFormAccess", + table: "Leagues"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230919104451_AddStandingSortOptions.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20230919104451_AddStandingSortOptions.Designer.cs new file mode 100644 index 00000000..721c0132 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230919104451_AddStandingSortOptions.Designer.cs @@ -0,0 +1,3879 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20230919104451_AddStandingSortOptions")] + partial class AddStandingSortOptions + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("ResultKind") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableLiveReviews") + .HasColumnType("tinyint(1)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestFormAccess") + .HasColumnType("int"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("SortOptions") + .HasColumnType("longtext"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("RacesScored") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20230919104451_AddStandingSortOptions.cs b/src/iRLeagueDatabaseCore/Migrations/20230919104451_AddStandingSortOptions.cs new file mode 100644 index 00000000..bc44955c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20230919104451_AddStandingSortOptions.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AddStandingSortOptions : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "SortOptions", + table: "StandingConfigurations", + type: "longtext", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "SortOptions", + table: "StandingConfigurations"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20231016191207_ReviewsTeamAtFault.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20231016191207_ReviewsTeamAtFault.Designer.cs new file mode 100644 index 00000000..bcaa193c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20231016191207_ReviewsTeamAtFault.Designer.cs @@ -0,0 +1,3940 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20231016191207_ReviewsTeamAtFault")] + partial class ReviewsTeamAtFault + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("TeamAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "TeamAtFaultId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("ResultKind") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewsInvolvedTeams", b => + { + b.Property("ReviewRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamRefId") + .HasColumnType("bigint"); + + b.HasKey("ReviewRefId", "LeagueId", "TeamRefId"); + + b.HasIndex("LeagueId", "ReviewRefId"); + + b.HasIndex("LeagueId", "TeamRefId"); + + b.ToTable("IncidentReviewsInvolvedTeams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableLiveReviews") + .HasColumnType("tinyint(1)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestFormAccess") + .HasColumnType("int"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("TeamAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "TeamAtFaultId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasColumnType("int"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("SortOptions") + .HasColumnType("longtext"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("RacesScored") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "TeamAtFault") + .WithMany() + .HasForeignKey("LeagueId", "TeamAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("TeamAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewsInvolvedTeams", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany() + .HasForeignKey("LeagueId", "ReviewRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Review"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "TeamAtFault") + .WithMany() + .HasForeignKey("LeagueId", "TeamAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("TeamAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20231016191207_ReviewsTeamAtFault.cs b/src/iRLeagueDatabaseCore/Migrations/20231016191207_ReviewsTeamAtFault.cs new file mode 100644 index 00000000..3d66ac0e --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20231016191207_ReviewsTeamAtFault.cs @@ -0,0 +1,113 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class ReviewsTeamAtFault : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TeamAtFaultId", + table: "ReviewCommentVotes", + type: "bigint", + nullable: true); + + migrationBuilder.AddColumn( + name: "TeamAtFaultId", + table: "AcceptedReviewVotes", + type: "bigint", + nullable: true); + + migrationBuilder.CreateTable( + name: "IncidentReviewsInvolvedTeams", + columns: table => new + { + LeagueId = table.Column(type: "bigint", nullable: false), + ReviewRefId = table.Column(type: "bigint", nullable: false), + TeamRefId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IncidentReviewsInvolvedTeams", x => new { x.ReviewRefId, x.LeagueId, x.TeamRefId }); + table.ForeignKey( + name: "FK_IncidentReviewsInvolvedTeams_IncidentReviews_LeagueId_Review~", + columns: x => new { x.LeagueId, x.ReviewRefId }, + principalTable: "IncidentReviews", + principalColumns: new[] { "LeagueId", "ReviewId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_IncidentReviewsInvolvedTeams_Teams_LeagueId_TeamRefId", + columns: x => new { x.LeagueId, x.TeamRefId }, + principalTable: "Teams", + principalColumns: new[] { "LeagueId", "TeamId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ReviewCommentVotes_LeagueId_TeamAtFaultId", + table: "ReviewCommentVotes", + columns: new[] { "LeagueId", "TeamAtFaultId" }); + + migrationBuilder.CreateIndex( + name: "IX_AcceptedReviewVotes_LeagueId_TeamAtFaultId", + table: "AcceptedReviewVotes", + columns: new[] { "LeagueId", "TeamAtFaultId" }); + + migrationBuilder.CreateIndex( + name: "IX_IncidentReviewsInvolvedTeams_LeagueId_ReviewRefId", + table: "IncidentReviewsInvolvedTeams", + columns: new[] { "LeagueId", "ReviewRefId" }); + + migrationBuilder.CreateIndex( + name: "IX_IncidentReviewsInvolvedTeams_LeagueId_TeamRefId", + table: "IncidentReviewsInvolvedTeams", + columns: new[] { "LeagueId", "TeamRefId" }); + + migrationBuilder.AddForeignKey( + name: "FK_AcceptedReviewVotes_Teams_LeagueId_TeamAtFaultId", + table: "AcceptedReviewVotes", + columns: new[] { "LeagueId", "TeamAtFaultId" }, + principalTable: "Teams", + principalColumns: new[] { "LeagueId", "TeamId" }); + + migrationBuilder.AddForeignKey( + name: "FK_ReviewCommentVotes_Teams_LeagueId_TeamAtFaultId", + table: "ReviewCommentVotes", + columns: new[] { "LeagueId", "TeamAtFaultId" }, + principalTable: "Teams", + principalColumns: new[] { "LeagueId", "TeamId" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AcceptedReviewVotes_Teams_LeagueId_TeamAtFaultId", + table: "AcceptedReviewVotes"); + + migrationBuilder.DropForeignKey( + name: "FK_ReviewCommentVotes_Teams_LeagueId_TeamAtFaultId", + table: "ReviewCommentVotes"); + + migrationBuilder.DropTable( + name: "IncidentReviewsInvolvedTeams"); + + migrationBuilder.DropIndex( + name: "IX_ReviewCommentVotes_LeagueId_TeamAtFaultId", + table: "ReviewCommentVotes"); + + migrationBuilder.DropIndex( + name: "IX_AcceptedReviewVotes_LeagueId_TeamAtFaultId", + table: "AcceptedReviewVotes"); + + migrationBuilder.DropColumn( + name: "TeamAtFaultId", + table: "ReviewCommentVotes"); + + migrationBuilder.DropColumn( + name: "TeamAtFaultId", + table: "AcceptedReviewVotes"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20231025134401_CarNumberAsString.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20231025134401_CarNumberAsString.Designer.cs new file mode 100644 index 00000000..fa5c37c6 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20231025134401_CarNumberAsString.Designer.cs @@ -0,0 +1,3942 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20231025134401_CarNumberAsString")] + partial class CarNumberAsString + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("TeamAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "TeamAtFaultId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("ResultKind") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewsInvolvedTeams", b => + { + b.Property("ReviewRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamRefId") + .HasColumnType("bigint"); + + b.HasKey("ReviewRefId", "LeagueId", "TeamRefId"); + + b.HasIndex("LeagueId", "ReviewRefId"); + + b.HasIndex("LeagueId", "TeamRefId"); + + b.ToTable("IncidentReviewsInvolvedTeams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableLiveReviews") + .HasColumnType("tinyint(1)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestFormAccess") + .HasColumnType("int"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasMaxLength(8) + .HasColumnType("varchar(8)"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("TeamAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "TeamAtFaultId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasMaxLength(8) + .HasColumnType("varchar(8)"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("SortOptions") + .HasColumnType("longtext"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("RacesScored") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "TeamAtFault") + .WithMany() + .HasForeignKey("LeagueId", "TeamAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("TeamAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewsInvolvedTeams", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany() + .HasForeignKey("LeagueId", "ReviewRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Review"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "TeamAtFault") + .WithMany() + .HasForeignKey("LeagueId", "TeamAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("TeamAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20231025134401_CarNumberAsString.cs b/src/iRLeagueDatabaseCore/Migrations/20231025134401_CarNumberAsString.cs new file mode 100644 index 00000000..2d74d0ef --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20231025134401_CarNumberAsString.cs @@ -0,0 +1,96 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class CarNumberAsString : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(""" + -- pre migration + -- safe the CarNumber values as ints + + CREATE TEMPORARY TABLE TmpResultRowsNumbers ( + ResultRowId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + CarNumber INT NOT NULL + ); + + INSERT INTO TmpResultRowsNumbers (ResultRowId, CarNumber) + SELECT ResultRowId, CarNumber + FROM ResultRows; + + CREATE TEMPORARY TABLE TmpScoredResultRowsNumbers ( + ScoredResultRowId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + CarNumber INT NOT NULL + ); + + INSERT INTO TmpScoredResultRowsNumbers (ScoredResultRowId, CarNumber) + SELECT ScoredResultRowId, CarNumber + FROM ScoredResultRows; + """); + + migrationBuilder.AlterColumn( + name: "CarNumber", + table: "ScoredResultRows", + type: "varchar(8)", + maxLength: 8, + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "CarNumber", + table: "ResultRows", + type: "varchar(8)", + maxLength: 8, + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.Sql(""" + -- post migration + -- restore CarNumber values as string + + UPDATE ResultRows `rows` + JOIN TmpResultRowsNumbers `numbers` + ON `numbers`.ResultRowId=`rows`.ResultRowId + SET `rows`.CarNumber = `numbers`.CarNumber; + + UPDATE ScoredResultRows `rows` + JOIN TmpScoredResultRowsNumbers `numbers` + ON `numbers`.ScoredResultRowId=`rows`.ScoredResultRowId + SET `rows`.CarNumber = `numbers`.CarNumber; + + DROP TABLE TmpResultRowsNumbers; + DROP TABLE TmpScoredResultRowsNumbers; + """); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CarNumber", + table: "ScoredResultRows", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(string), + oldType: "varchar(8)", + oldMaxLength: 8, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CarNumber", + table: "ResultRows", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(string), + oldType: "varchar(8)", + oldMaxLength: 8, + oldNullable: true); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20240223233643_AddPointFormula.Designer.cs b/src/iRLeagueDatabaseCore/Migrations/20240223233643_AddPointFormula.Designer.cs new file mode 100644 index 00000000..a5ffb1b4 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20240223233643_AddPointFormula.Designer.cs @@ -0,0 +1,3948 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + [Migration("20240223233643_AddPointFormula")] + partial class AddPointFormula + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("TeamAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "TeamAtFaultId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("ResultKind") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewsInvolvedTeams", b => + { + b.Property("ReviewRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamRefId") + .HasColumnType("bigint"); + + b.HasKey("ReviewRefId", "LeagueId", "TeamRefId"); + + b.HasIndex("LeagueId", "ReviewRefId"); + + b.HasIndex("LeagueId", "TeamRefId"); + + b.ToTable("IncidentReviewsInvolvedTeams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableLiveReviews") + .HasColumnType("tinyint(1)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestFormAccess") + .HasColumnType("int"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("Formula") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("RuleType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasMaxLength(8) + .HasColumnType("varchar(8)"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("TeamAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "TeamAtFaultId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasMaxLength(8) + .HasColumnType("varchar(8)"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("SortOptions") + .HasColumnType("longtext"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("RacesScored") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "TeamAtFault") + .WithMany() + .HasForeignKey("LeagueId", "TeamAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("TeamAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewsInvolvedTeams", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany() + .HasForeignKey("LeagueId", "ReviewRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Review"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "TeamAtFault") + .WithMany() + .HasForeignKey("LeagueId", "TeamAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("TeamAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/20240223233643_AddPointFormula.cs b/src/iRLeagueDatabaseCore/Migrations/20240223233643_AddPointFormula.cs new file mode 100644 index 00000000..d222f34d --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/20240223233643_AddPointFormula.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + public partial class AddPointFormula : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Formula", + table: "PointRules", + type: "longtext", + nullable: true); + + migrationBuilder.AddColumn( + name: "RuleType", + table: "PointRules", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Formula", + table: "PointRules"); + + migrationBuilder.DropColumn( + name: "RuleType", + table: "PointRules"); + } + } +} diff --git a/src/iRLeagueDatabaseCore/Migrations/LeagueDbContextModelSnapshot.cs b/src/iRLeagueDatabaseCore/Migrations/LeagueDbContextModelSnapshot.cs new file mode 100644 index 00000000..936c850c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Migrations/LeagueDbContextModelSnapshot.cs @@ -0,0 +1,3946 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using iRLeagueDatabaseCore.Models; + +#nullable disable + +namespace iRLeagueDatabaseCore.Migrations +{ + [DbContext(typeof(LeagueDbContext))] + partial class LeagueDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.Property("InvolvedMembersId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsLeagueId") + .HasColumnType("bigint"); + + b.Property("InvolvedReviewsReviewId") + .HasColumnType("bigint"); + + b.HasKey("InvolvedMembersId", "InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.HasIndex("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId"); + + b.ToTable("IncidentReviewsInvolvedMembers", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("TeamAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "TeamAtFaultId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("AcceptedReviewVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("AddPenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Corner") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Lap") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Reason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ScoredResultRowId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "AddPenaltyId"); + + b.HasAlternateKey("AddPenaltyId"); + + b.HasIndex("LeagueId", "ScoredResultRowId"); + + b.ToTable("AddPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PenaltyConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("PointRuleId") + .HasColumnType("bigint"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Positions") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("time(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PenaltyConfigId"); + + b.HasAlternateKey("PenaltyConfigId"); + + b.HasIndex("LeagueId", "PointRuleId"); + + b.ToTable("AutoPenaltyConfigs", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampionshipId"); + + b.HasAlternateKey("ChampionshipId"); + + b.ToTable("Championships", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampionshipId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("DefaultResultConfigId") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("ResultKind") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ChampSeasonId"); + + b.HasAlternateKey("ChampSeasonId"); + + b.HasIndex("LeagueId", "ChampionshipId"); + + b.HasIndex("LeagueId", "DefaultResultConfigId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("ChampSeasons", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("IncidentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "IncidentId"); + + b.HasAlternateKey("IncidentId"); + + b.ToTable("CustomIncidents"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StatisticSetId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("AvgFinalPosition") + .HasColumnType("double"); + + b.Property("AvgFinishPosition") + .HasColumnType("double"); + + b.Property("AvgIRating") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerKm") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerLap") + .HasColumnType("double"); + + b.Property("AvgIncidentsPerRace") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerKm") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerLap") + .HasColumnType("double"); + + b.Property("AvgPenaltyPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgPointsPerRace") + .HasColumnType("double"); + + b.Property("AvgSRating") + .HasColumnType("double"); + + b.Property("AvgStartPosition") + .HasColumnType("double"); + + b.Property("BestFinalPosition") + .HasColumnType("int"); + + b.Property("BestFinishPosition") + .HasColumnType("double"); + + b.Property("BestStartPosition") + .HasColumnType("double"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("CleanestDriverAwards") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CurrentSeasonPosition") + .HasColumnType("int"); + + b.Property("DrivenKm") + .HasColumnType("double"); + + b.Property("EndIRating") + .HasColumnType("int"); + + b.Property("EndSRating") + .HasColumnType("double"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FirstRaceDate") + .HasColumnType("datetime"); + + b.Property("FirstRaceFinalPosition") + .HasColumnType("int"); + + b.Property("FirstRaceFinishPosition") + .HasColumnType("double"); + + b.Property("FirstRaceId") + .HasColumnType("bigint"); + + b.Property("FirstRaceStartPosition") + .HasColumnType("double"); + + b.Property("FirstResultRowId") + .HasColumnType("bigint"); + + b.Property("FirstSessionDate") + .HasColumnType("datetime"); + + b.Property("FirstSessionId") + .HasColumnType("bigint"); + + b.Property("HardChargerAwards") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("IncidentsUnderInvestigation") + .HasColumnType("int"); + + b.Property("IncidentsWithPenalty") + .HasColumnType("int"); + + b.Property("LastRaceDate") + .HasColumnType("datetime"); + + b.Property("LastRaceFinalPosition") + .HasColumnType("int"); + + b.Property("LastRaceFinishPosition") + .HasColumnType("double"); + + b.Property("LastRaceId") + .HasColumnType("bigint"); + + b.Property("LastRaceStartPosition") + .HasColumnType("double"); + + b.Property("LastResultRowId") + .HasColumnType("bigint"); + + b.Property("LastSessionDate") + .HasColumnType("datetime"); + + b.Property("LastSessionId") + .HasColumnType("bigint"); + + b.Property("LeadingKm") + .HasColumnType("double"); + + b.Property("LeadingLaps") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("Poles") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCompleted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("StartIRating") + .HasColumnType("int"); + + b.Property("StartSRating") + .HasColumnType("double"); + + b.Property("Titles") + .HasColumnType("int"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top15") + .HasColumnType("int"); + + b.Property("Top20") + .HasColumnType("int"); + + b.Property("Top25") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WorstFinalPosition") + .HasColumnType("int"); + + b.Property("WorstFinishPosition") + .HasColumnType("double"); + + b.Property("WorstStartPosition") + .HasColumnType("double"); + + b.HasKey("LeagueId", "StatisticSetId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("StatisticSetId"); + + b.HasIndex("LeagueId", "FirstRaceId"); + + b.HasIndex("LeagueId", "FirstResultRowId"); + + b.HasIndex("LeagueId", "FirstSessionId"); + + b.HasIndex("LeagueId", "LastRaceId"); + + b.HasIndex("LeagueId", "LastResultRowId"); + + b.HasIndex("LeagueId", "LastSessionId"); + + b.ToTable("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IrResultLink") + .HasColumnType("longtext"); + + b.Property("IrSessionId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("TrackId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasAlternateKey("EventId"); + + b.HasIndex("TrackId"); + + b.HasIndex("LeagueId", "ScheduleId"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.Property("EventRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigRefId") + .HasColumnType("bigint"); + + b.HasKey("EventRefId", "LeagueId", "ResultConfigRefId"); + + b.HasIndex("LeagueId", "EventRefId"); + + b.HasIndex("LeagueId", "ResultConfigRefId"); + + b.ToTable("EventResultConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "EventId"); + + b.HasIndex("EventId"); + + b.ToTable("EventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("FilterOptionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("Conditions") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("PointFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("ResultFilterResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "FilterOptionId"); + + b.HasAlternateKey("FilterOptionId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "PointFilterResultConfigId"); + + b.HasIndex("LeagueId", "ResultFilterResultConfigId"); + + b.ToTable("FilterOptions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IncidentKind") + .HasColumnType("longtext"); + + b.Property("IncidentNr") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("ResultLongText") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("TimeStamp") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ReviewId"); + + b.HasAlternateKey("ReviewId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("IncidentReviews"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewsInvolvedTeams", b => + { + b.Property("ReviewRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamRefId") + .HasColumnType("bigint"); + + b.HasKey("ReviewRefId", "LeagueId", "TeamRefId"); + + b.HasIndex("LeagueId", "ReviewRefId"); + + b.HasIndex("LeagueId", "TeamRefId"); + + b.ToTable("IncidentReviewsInvolvedTeams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionDetailsId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasColumnType("longtext"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("CornersPerLap") + .HasColumnType("int"); + + b.Property("DamageModel") + .HasColumnType("int"); + + b.Property("EndTime") + .HasColumnType("datetime"); + + b.Property("EventAverageLap") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventLapsComplete") + .HasColumnType("int"); + + b.Property("EventStrengthOfField") + .HasColumnType("int"); + + b.Property("Fog") + .HasColumnType("int"); + + b.Property("IRRaceWeek") + .HasColumnType("int"); + + b.Property("IRSeasonId") + .HasColumnType("bigint"); + + b.Property("IRSeasonName") + .HasColumnType("longtext"); + + b.Property("IRSeasonQuarter") + .HasColumnType("int"); + + b.Property("IRSeasonYear") + .HasColumnType("int"); + + b.Property("IRSessionId") + .HasColumnType("bigint"); + + b.Property("IRSubsessionId") + .HasColumnType("bigint"); + + b.Property("IRTrackId") + .HasColumnType("int"); + + b.Property("KmDistPerLap") + .HasColumnType("double"); + + b.Property("LeaveMarbles") + .HasColumnType("tinyint(1)"); + + b.Property("LicenseCategory") + .HasColumnType("int"); + + b.Property("MaxWeeks") + .HasColumnType("int"); + + b.Property("NumCautionLaps") + .HasColumnType("int"); + + b.Property("NumCautions") + .HasColumnType("int"); + + b.Property("NumLeadChanges") + .HasColumnType("int"); + + b.Property("PracticeGripCompound") + .HasColumnType("int"); + + b.Property("PracticeRubber") + .HasColumnType("int"); + + b.Property("QualifyGripCompund") + .HasColumnType("int"); + + b.Property("QualifyRubber") + .HasColumnType("int"); + + b.Property("RaceGripCompound") + .HasColumnType("int"); + + b.Property("RaceRubber") + .HasColumnType("int"); + + b.Property("RelHumidity") + .HasColumnType("int"); + + b.Property("SessionName") + .HasColumnType("longtext"); + + b.Property("SimStartUtcOffset") + .HasColumnType("bigint"); + + b.Property("SimStartUtcTime") + .HasColumnType("datetime"); + + b.Property("Skies") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime"); + + b.Property("TempUnits") + .HasColumnType("int"); + + b.Property("TempValue") + .HasColumnType("int"); + + b.Property("TimeOfDay") + .HasColumnType("int"); + + b.Property("TrackCategoryId") + .HasColumnType("int"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.Property("WarmupGripCompound") + .HasColumnType("int"); + + b.Property("WarmupRubber") + .HasColumnType("int"); + + b.Property("WeatherType") + .HasColumnType("int"); + + b.Property("WeatherVarInitial") + .HasColumnType("int"); + + b.Property("WeatherVarOngoing") + .HasColumnType("int"); + + b.Property("WindDir") + .HasColumnType("int"); + + b.Property("WindUnits") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionDetailsId"); + + b.HasAlternateKey("SessionDetailsId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("IRSimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DescriptionPlain") + .HasColumnType("longtext"); + + b.Property("EnableLiveReviews") + .HasColumnType("tinyint(1)"); + + b.Property("EnableProtests") + .HasColumnType("tinyint(1)"); + + b.Property("Expires") + .HasColumnType("datetime(6)"); + + b.Property("IsInitialized") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("LeaguePublic") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(85) + .HasColumnType("varchar(85)"); + + b.Property("NameFull") + .HasColumnType("longtext"); + + b.Property("ProtestCoolDownPeriod") + .HasColumnType("bigint"); + + b.Property("ProtestFormAccess") + .HasColumnType("int"); + + b.Property("ProtestsClosedAfter") + .HasColumnType("bigint"); + + b.Property("ProtestsPublic") + .HasColumnType("int"); + + b.Property("Subscription") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasAlternateKey("Name"); + + b.ToTable("Leagues"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "MemberId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DanLisaId") + .HasColumnType("longtext"); + + b.Property("DiscordId") + .HasColumnType("longtext"); + + b.Property("Firstname") + .HasColumnType("longtext"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Lastname") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("LastPaymentReceived") + .HasColumnType("datetime(6)"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("NextPaymentDue") + .HasColumnType("datetime(6)"); + + b.Property("PlanId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SubscriptionId") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("LeagueId"); + + b.HasIndex("PlanId"); + + b.ToTable("Payments", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("PointRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .IsRequired() + .HasColumnType("json"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("FinalSortOptions") + .HasColumnType("longtext"); + + b.Property("Formula") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxPoints") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointDropOff") + .HasColumnType("int"); + + b.Property("PointsPerPlace") + .HasColumnType("longtext"); + + b.Property("PointsSortOptions") + .HasColumnType("longtext"); + + b.Property("RuleType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "PointRuleId"); + + b.HasAlternateKey("PointRuleId"); + + b.ToTable("PointRules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorMemberId") + .HasColumnType("bigint"); + + b.Property("Corner") + .HasColumnType("longtext"); + + b.Property("FullDescription") + .HasColumnType("longtext"); + + b.Property("OnLap") + .HasColumnType("longtext"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ProtestId"); + + b.HasAlternateKey("ProtestId"); + + b.HasIndex("LeagueId", "AuthorMemberId"); + + b.HasIndex("LeagueId", "SessionId"); + + b.ToTable("Protests", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ProtestId") + .HasColumnType("bigint"); + + b.HasKey("MemberId", "LeagueId", "ProtestId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "ProtestId"); + + b.ToTable("Protests_LeagueMembers"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("DisplayName") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultsPerTeam") + .HasColumnType("int"); + + b.Property("SourceResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultConfigId"); + + b.HasAlternateKey("ResultConfigId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "SourceResultConfigId"); + + b.ToTable("ResultConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasMaxLength(8) + .HasColumnType("varchar(8)"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubSessionId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ResultRowId"); + + b.HasAlternateKey("ResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "MemberId"); + + b.HasIndex("LeagueId", "SubSessionId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AuthorName") + .HasColumnType("longtext"); + + b.Property("AuthorUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Date") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("ReplyToCommentId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "CommentId"); + + b.HasAlternateKey("CommentId"); + + b.HasIndex("ReplyToCommentId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("LeagueId", "ReplyToCommentId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.ToTable("ReviewComments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("MemberAtFaultId") + .HasColumnType("bigint"); + + b.Property("TeamAtFaultId") + .HasColumnType("bigint"); + + b.Property("VoteCategoryId") + .HasColumnType("bigint"); + + b.HasKey("LeagueId", "ReviewVoteId"); + + b.HasAlternateKey("ReviewVoteId"); + + b.HasIndex("CommentId"); + + b.HasIndex("MemberAtFaultId"); + + b.HasIndex("VoteCategoryId"); + + b.HasIndex("LeagueId", "CommentId"); + + b.HasIndex("LeagueId", "TeamAtFaultId"); + + b.HasIndex("LeagueId", "VoteCategoryId"); + + b.ToTable("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultRowId") + .HasColumnType("bigint"); + + b.Property("ReviewId") + .HasColumnType("bigint"); + + b.Property("ReviewVoteId") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("json"); + + b.HasKey("LeagueId", "ResultRowId", "ReviewId", "ReviewVoteId"); + + b.HasIndex("ReviewId"); + + b.HasIndex("ReviewVoteId"); + + b.HasIndex("LeagueId", "ResultRowId"); + + b.HasIndex("LeagueId", "ReviewId"); + + b.HasIndex("LeagueId", "ReviewVoteId"); + + b.ToTable("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScheduleId"); + + b.HasAlternateKey("ScheduleId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityEventId") + .HasColumnType("bigint"); + + b.Property("EventResultEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ResultId"); + + b.HasAlternateKey("ResultId"); + + b.HasIndex("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.ToTable("ScoredEventResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoredResultRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AvgLapTime") + .HasColumnType("bigint"); + + b.Property("BonusPoints") + .HasColumnType("double"); + + b.Property("Car") + .HasColumnType("longtext"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("CarNumber") + .HasMaxLength(8) + .HasColumnType("varchar(8)"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("ClubId") + .HasColumnType("int"); + + b.Property("ClubName") + .HasColumnType("longtext"); + + b.Property("CompletedLaps") + .HasColumnType("double"); + + b.Property("CompletedPct") + .HasColumnType("double"); + + b.Property("ContactLaps") + .HasColumnType("longtext"); + + b.Property("Division") + .HasColumnType("int"); + + b.Property("FastLapNr") + .HasColumnType("int"); + + b.Property("FastestLapTime") + .HasColumnType("bigint"); + + b.Property("FinalPosition") + .HasColumnType("int"); + + b.Property("FinalPositionChange") + .HasColumnType("double"); + + b.Property("FinishPosition") + .HasColumnType("double"); + + b.Property("IRacingId") + .HasColumnType("longtext"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Incidents") + .HasColumnType("double"); + + b.Property("Interval") + .HasColumnType("bigint"); + + b.Property("LeadLaps") + .HasColumnType("double"); + + b.Property("License") + .HasColumnType("longtext"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("NewCpi") + .HasColumnType("int"); + + b.Property("NewIRating") + .HasColumnType("int"); + + b.Property("NewLicenseLevel") + .HasColumnType("int"); + + b.Property("NewSafetyRating") + .HasColumnType("double"); + + b.Property("NumContactLaps") + .HasColumnType("int"); + + b.Property("NumOfftrackLaps") + .HasColumnType("int"); + + b.Property("NumPitStops") + .HasColumnType("int"); + + b.Property("OfftrackLaps") + .HasColumnType("longtext"); + + b.Property("OldCpi") + .HasColumnType("int"); + + b.Property("OldIRating") + .HasColumnType("int"); + + b.Property("OldLicenseLevel") + .HasColumnType("int"); + + b.Property("OldSafetyRating") + .HasColumnType("double"); + + b.Property("PenaltyPoints") + .HasColumnType("double"); + + b.Property("PittedLaps") + .HasColumnType("longtext"); + + b.Property("PointsEligible") + .HasColumnType("tinyint(1)"); + + b.Property("PositionChange") + .HasColumnType("double"); + + b.Property("QualifyingTime") + .HasColumnType("bigint"); + + b.Property("QualifyingTimeAt") + .HasColumnType("datetime"); + + b.Property("RacePoints") + .HasColumnType("double"); + + b.Property("SeasonStartIRating") + .HasColumnType("int"); + + b.Property("SessionResultId") + .HasColumnType("bigint"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("StartPosition") + .HasColumnType("double"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("TotalPoints") + .HasColumnType("double"); + + b.HasKey("LeagueId", "ScoredResultRowId"); + + b.HasAlternateKey("ScoredResultRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("TeamId"); + + b.HasIndex("LeagueId", "SessionResultId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionResultId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Discriminator") + .HasColumnType("longtext"); + + b.Property("FastestAvgLap") + .HasColumnType("bigint"); + + b.Property("FastestAvgLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestLap") + .HasColumnType("bigint"); + + b.Property("FastestLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("FastestQualyLap") + .HasColumnType("bigint"); + + b.Property("FastestQualyLapDriverMemberId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .HasColumnType("bigint"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionResultId"); + + b.HasAlternateKey("SessionResultId"); + + b.HasIndex("FastestAvgLapDriverMemberId"); + + b.HasIndex("FastestLapDriverMemberId"); + + b.HasIndex("FastestQualyLapDriverMemberId"); + + b.HasIndex("LeagueId", "ResultId"); + + b.HasIndex("LeagueId", "ScoringId"); + + b.ToTable("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.Property("TeamParentRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamResultRowRefId") + .HasColumnType("bigint"); + + b.HasKey("TeamParentRowRefId", "LeagueId", "TeamResultRowRefId"); + + b.HasIndex("LeagueId", "TeamParentRowRefId"); + + b.HasIndex("LeagueId", "TeamResultRowRefId"); + + b.ToTable("ScoredTeamResultRowsResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("ScoringId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("ExtScoringSourceId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("IsCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MaxResultsPerGroup") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("PointsRuleId") + .HasColumnType("bigint"); + + b.Property("ResultConfigId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityLeagueId") + .HasColumnType("bigint"); + + b.Property("ScheduleEntityScheduleId") + .HasColumnType("bigint"); + + b.Property("ShowResults") + .HasColumnType("tinyint(1)"); + + b.Property("UpdateTeamOnRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("UseExternalSourcePoints") + .HasColumnType("tinyint(1)"); + + b.Property("UseResultSetTeam") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "ScoringId"); + + b.HasAlternateKey("ScoringId"); + + b.HasIndex("ExtScoringSourceId"); + + b.HasIndex("LeagueId", "ExtScoringSourceId"); + + b.HasIndex("LeagueId", "PointsRuleId"); + + b.HasIndex("LeagueId", "ResultConfigId"); + + b.HasIndex("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.ToTable("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SeasonId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Finished") + .HasColumnType("tinyint(1)"); + + b.Property("HideCommentsBeforeVoted") + .HasColumnType("tinyint(1)"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("MainScoringLeagueId") + .HasColumnType("bigint"); + + b.Property("MainScoringScoringId") + .HasColumnType("bigint"); + + b.Property("SeasonEnd") + .HasColumnType("datetime"); + + b.Property("SeasonName") + .HasColumnType("longtext"); + + b.Property("SeasonStart") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SeasonId"); + + b.HasAlternateKey("SeasonId"); + + b.HasIndex("MainScoringLeagueId", "MainScoringScoringId"); + + b.ToTable("Seasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("Duration") + .HasColumnType("bigint"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Laps") + .HasColumnType("int"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SessionNr") + .HasColumnType("int"); + + b.Property("SessionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StartOffset") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasAlternateKey("SessionId"); + + b.HasIndex("EventId", "SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("SessionId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("IRSimSessionDetailsId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("SimSessionType") + .HasColumnType("int"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "SessionId"); + + b.HasIndex("SessionId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "IRSimSessionDetailsId"); + + b.ToTable("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("ResultKind") + .HasColumnType("int"); + + b.Property("SortOptions") + .HasColumnType("longtext"); + + b.Property("UseCombinedResult") + .HasColumnType("tinyint(1)"); + + b.Property("Version") + .HasColumnType("int"); + + b.Property("WeeksCounted") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingConfigId"); + + b.HasAlternateKey("StandingConfigId"); + + b.ToTable("StandingConfigurations"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChampSeasonId") + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime(6)"); + + b.Property("EventId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("IsTeamStanding") + .HasColumnType("tinyint(1)"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingConfigId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingId"); + + b.HasAlternateKey("StandingId"); + + b.HasIndex("LeagueId", "ChampSeasonId"); + + b.HasIndex("LeagueId", "EventId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingConfigId"); + + b.ToTable("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CarClass") + .HasColumnType("longtext"); + + b.Property("ClassId") + .HasColumnType("int"); + + b.Property("CompletedLaps") + .HasColumnType("int"); + + b.Property("CompletedLapsChange") + .HasColumnType("int"); + + b.Property("DroppedResultCount") + .HasColumnType("int"); + + b.Property("FastestLaps") + .HasColumnType("int"); + + b.Property("FastestLapsChange") + .HasColumnType("int"); + + b.Property("Incidents") + .HasColumnType("int"); + + b.Property("IncidentsChange") + .HasColumnType("int"); + + b.Property("LastIrating") + .HasColumnType("int"); + + b.Property("LastPosition") + .HasColumnType("int"); + + b.Property("LeadLaps") + .HasColumnType("int"); + + b.Property("LeadLapsChange") + .HasColumnType("int"); + + b.Property("MemberId") + .HasColumnType("bigint"); + + b.Property("PenaltyPoints") + .HasColumnType("int"); + + b.Property("PenaltyPointsChange") + .HasColumnType("int"); + + b.Property("PolePositions") + .HasColumnType("int"); + + b.Property("PolePositionsChange") + .HasColumnType("int"); + + b.Property("Position") + .HasColumnType("int"); + + b.Property("PositionChange") + .HasColumnType("int"); + + b.Property("RacePoints") + .HasColumnType("int"); + + b.Property("RacePointsChange") + .HasColumnType("int"); + + b.Property("Races") + .HasColumnType("int"); + + b.Property("RacesCounted") + .HasColumnType("int"); + + b.Property("RacesInPoints") + .HasColumnType("int"); + + b.Property("RacesScored") + .HasColumnType("int"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("StartIrating") + .HasColumnType("int"); + + b.Property("TeamId") + .HasColumnType("bigint"); + + b.Property("Top10") + .HasColumnType("int"); + + b.Property("Top3") + .HasColumnType("int"); + + b.Property("Top5") + .HasColumnType("int"); + + b.Property("TotalPoints") + .HasColumnType("int"); + + b.Property("TotalPointsChange") + .HasColumnType("int"); + + b.Property("Wins") + .HasColumnType("int"); + + b.Property("WinsChange") + .HasColumnType("int"); + + b.HasKey("LeagueId", "StandingRowId"); + + b.HasAlternateKey("StandingRowId"); + + b.HasIndex("MemberId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.HasIndex("LeagueId", "TeamId"); + + b.ToTable("StandingRows", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.Property("ScoredResultRowRefId") + .HasColumnType("bigint"); + + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("StandingRowRefId") + .HasColumnType("bigint"); + + b.Property("IsScored") + .HasColumnType("tinyint(1)"); + + b.HasKey("ScoredResultRowRefId", "LeagueId", "StandingRowRefId"); + + b.HasIndex("LeagueId", "ScoredResultRowRefId"); + + b.HasIndex("LeagueId", "StandingRowRefId"); + + b.ToTable("StandingRows_ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("CurrentChampId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FinishedRaces") + .HasColumnType("int"); + + b.Property("FirstDate") + .HasColumnType("datetime"); + + b.Property("ImportSource") + .HasColumnType("longtext"); + + b.Property("IsSeasonFinished") + .HasColumnType("tinyint(1)"); + + b.Property("LastDate") + .HasColumnType("datetime"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("RequiresRecalculation") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("bigint"); + + b.Property("StandingId") + .HasColumnType("bigint"); + + b.Property("UpdateInterval") + .HasColumnType("bigint"); + + b.Property("UpdateTime") + .HasColumnType("datetime"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "Id"); + + b.HasAlternateKey("Id"); + + b.HasIndex("CurrentChampId"); + + b.HasIndex("LeagueId", "SeasonId"); + + b.HasIndex("LeagueId", "StandingId"); + + b.ToTable("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Property("PlanId") + .HasColumnType("varchar(255)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Price") + .HasColumnType("double"); + + b.HasKey("PlanId"); + + b.ToTable("Subscriptions", (string)null); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("TeamId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreatedByUserId") + .HasColumnType("longtext"); + + b.Property("CreatedByUserName") + .HasColumnType("longtext"); + + b.Property("CreatedOn") + .HasColumnType("datetime"); + + b.Property("IRacingTeamId") + .HasColumnType("bigint"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("LastModifiedByUserId") + .HasColumnType("longtext"); + + b.Property("LastModifiedByUserName") + .HasColumnType("longtext"); + + b.Property("LastModifiedOn") + .HasColumnType("datetime"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.Property("Profile") + .HasColumnType("longtext"); + + b.Property("TeamColor") + .HasColumnType("longtext"); + + b.Property("TeamHomepage") + .HasColumnType("longtext"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("LeagueId", "TeamId"); + + b.HasAlternateKey("TeamId"); + + b.ToTable("Teams"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.Property("TrackId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConfigName") + .HasColumnType("longtext"); + + b.Property("ConfigType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("HasNightLighting") + .HasColumnType("tinyint(1)"); + + b.Property("LegacyTrackId") + .HasColumnType("longtext"); + + b.Property("LengthKm") + .HasColumnType("double"); + + b.Property("TrackGroupId") + .HasColumnType("bigint"); + + b.Property("Turns") + .HasColumnType("int"); + + b.HasKey("TrackId"); + + b.HasIndex("TrackGroupId"); + + b.ToTable("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Property("TrackGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Location") + .HasColumnType("longtext"); + + b.Property("TrackName") + .HasColumnType("longtext"); + + b.HasKey("TrackGroupId"); + + b.ToTable("TrackGroups"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Property("LeagueId") + .HasColumnType("bigint"); + + b.Property("CatId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DefaultPenalty") + .HasColumnType("int"); + + b.Property("ImportId") + .HasColumnType("bigint"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("longtext"); + + b.HasKey("LeagueId", "CatId"); + + b.HasAlternateKey("CatId"); + + b.ToTable("VoteCategories"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.Property("CleanestDriversId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("CleanestDriverResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("CleanestDriversId", "CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.HasIndex("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId"); + + b.ToTable("ScoredResultsCleanestDrivers", (string)null); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.Property("HardChargersId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsLeagueId") + .HasColumnType("bigint"); + + b.Property("HardChargerResultsSessionResultId") + .HasColumnType("bigint"); + + b.HasKey("HardChargersId", "HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.HasIndex("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId"); + + b.ToTable("ScoredResultsHardChargers", (string)null); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.Property("DependendStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("DependendStatisticSetsId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsLeagueId") + .HasColumnType("bigint"); + + b.Property("LeagueStatisticSetsId") + .HasColumnType("bigint"); + + b.HasKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId", "LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.HasIndex("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId"); + + b.ToTable("LeagueStatisticSetsStatisticSets", (string)null); + }); + + modelBuilder.Entity("IncidentReviewEntityMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("InvolvedMembersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", null) + .WithMany() + .HasForeignKey("InvolvedReviewsLeagueId", "InvolvedReviewsReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "TeamAtFault") + .WithMany() + .HasForeignKey("LeagueId", "TeamAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("AcceptedReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("MemberAtFault"); + + b.Navigation("Review"); + + b.Navigation("TeamAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AddPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("AddPenalties") + .HasForeignKey("LeagueId", "ScoredResultRowId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AutoPenaltyConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointRule") + .WithMany("AutoPenalties") + .HasForeignKey("LeagueId", "PointRuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PointRule"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Championships") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampionshipEntity", "Championship") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "ChampionshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "DefaultResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "DefaultResultConfigId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfiguration") + .WithMany("ChampSeasons") + .HasForeignKey("LeagueId", "StandingConfigId"); + + b.Navigation("Championship"); + + b.Navigation("DefaultResultConfig"); + + b.Navigation("Season"); + + b.Navigation("StandingConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.CustomIncidentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany() + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.DriverStatisticRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("DriverStatisticRows") + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstRace") + .WithMany() + .HasForeignKey("LeagueId", "FirstRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "FirstResultRow") + .WithMany() + .HasForeignKey("LeagueId", "FirstResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "FirstSession") + .WithMany() + .HasForeignKey("LeagueId", "FirstSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastRace") + .WithMany() + .HasForeignKey("LeagueId", "LastRaceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "LastResultRow") + .WithMany() + .HasForeignKey("LeagueId", "LastResultRowId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "LastSession") + .WithMany() + .HasForeignKey("LeagueId", "LastSessionId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", "StatisticSet") + .WithMany("DriverStatisticRows") + .HasForeignKey("LeagueId", "StatisticSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstRace"); + + b.Navigation("FirstResultRow"); + + b.Navigation("FirstSession"); + + b.Navigation("LastRace"); + + b.Navigation("LastResultRow"); + + b.Navigation("LastSession"); + + b.Navigation("Member"); + + b.Navigation("StatisticSet"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackConfigEntity", "Track") + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", "Schedule") + .WithMany("Events") + .HasForeignKey("LeagueId", "ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Track"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultConfigs", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithOne("EventResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.EventResultEntity", "LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.FilterOptionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Filters") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "PointFilterResultConfig") + .WithMany("PointFilters") + .HasForeignKey("LeagueId", "PointFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultFilterResultConfig") + .WithMany("ResultFilters") + .HasForeignKey("LeagueId", "ResultFilterResultConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("PointFilterResultConfig"); + + b.Navigation("ResultFilterResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany("IncidentReviews") + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewsInvolvedTeams", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany() + .HasForeignKey("LeagueId", "ReviewRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Review"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("SimSessionDetails") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueMemberEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("LeagueMembers") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany("Members") + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("League"); + + b.Navigation("Member"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PaymentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Payments") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SubscriptionEntity", "Subscription") + .WithMany("Payments") + .HasForeignKey("PlanId"); + + b.Navigation("League"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("PointRules") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ProtestEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Author") + .WithMany() + .HasForeignKey("LeagueId", "AuthorMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithMany() + .HasForeignKey("LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.Protests_LeagueMembers", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "Member") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ProtestEntity", "Protest") + .WithMany() + .HasForeignKey("LeagueId", "ProtestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Member"); + + b.Navigation("Protest"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("ResultConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("ResultConfigurations") + .HasForeignKey("LeagueId", "ChampSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "SourceResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "SourceResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("League"); + + b.Navigation("SourceResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany("ResultRows") + .HasForeignKey("MemberId") + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.LeagueMemberEntity", "LeagueMember") + .WithMany() + .HasForeignKey("LeagueId", "MemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionResultEntity", "SubResult") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "SubSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("LeagueMember"); + + b.Navigation("Member"); + + b.Navigation("SubResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "ReplyToComment") + .WithMany("Replies") + .HasForeignKey("LeagueId", "ReplyToCommentId"); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("Comments") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("ReplyToComment"); + + b.Navigation("Review"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentVoteEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "MemberAtFault") + .WithMany("CommentReviewVotes") + .HasForeignKey("MemberAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ReviewCommentEntity", "Comment") + .WithMany("ReviewCommentVotes") + .HasForeignKey("LeagueId", "CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "TeamAtFault") + .WithMany() + .HasForeignKey("LeagueId", "TeamAtFaultId"); + + b.HasOne("iRLeagueDatabaseCore.Models.VoteCategoryEntity", "VoteCategory") + .WithMany("CommentReviewVotes") + .HasForeignKey("LeagueId", "VoteCategoryId"); + + b.Navigation("Comment"); + + b.Navigation("MemberAtFault"); + + b.Navigation("TeamAtFault"); + + b.Navigation("VoteCategory"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewPenaltyEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ResultRow") + .WithMany("ReviewPenalties") + .HasForeignKey("LeagueId", "ResultRowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IncidentReviewEntity", "Review") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", "ReviewVote") + .WithMany("ReviewPenaltys") + .HasForeignKey("LeagueId", "ReviewVoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ResultRow"); + + b.Navigation("Review"); + + b.Navigation("ReviewVote"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Schedules") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", null) + .WithMany("ScoredResults") + .HasForeignKey("EventResultEntityLeagueId", "EventResultEntityEventId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("EventResults") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("ScoredEventResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfig") + .WithMany() + .HasForeignKey("LeagueId", "ResultConfigId"); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("ResultConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", "ScoredSessionResult") + .WithMany("ScoredResultRows") + .HasForeignKey("LeagueId", "SessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("ScoredSessionResult"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestAvgLapDriver") + .WithMany("FastestAvgLapResults") + .HasForeignKey("FastestAvgLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestLapDriver") + .WithMany("FastestLapResults") + .HasForeignKey("FastestLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "FastestQualyLapDriver") + .WithMany("FastestQualyLapResults") + .HasForeignKey("FastestQualyLapDriverMemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", "ScoredEventResult") + .WithMany("ScoredSessionResults") + .HasForeignKey("LeagueId", "ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "Scoring") + .WithMany() + .HasForeignKey("LeagueId", "ScoringId"); + + b.Navigation("FastestAvgLapDriver"); + + b.Navigation("FastestLapDriver"); + + b.Navigation("FastestQualyLapDriver"); + + b.Navigation("ScoredEventResult"); + + b.Navigation("Scoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredTeamResultRowsResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamParentRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamParentRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "TeamResultRow") + .WithMany() + .HasForeignKey("LeagueId", "TeamResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ScoredTeamResultRowsResultRows_ScoredResultRows_LeagueId_Te~1"); + + b.Navigation("TeamParentRow"); + + b.Navigation("TeamResultRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", null) + .WithMany("Scorings") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "ExtScoringSource") + .WithMany("DependendScorings") + .HasForeignKey("LeagueId", "ExtScoringSourceId"); + + b.HasOne("iRLeagueDatabaseCore.Models.PointRuleEntity", "PointsRule") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "PointsRuleId"); + + b.HasOne("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", "ResultConfiguration") + .WithMany("Scorings") + .HasForeignKey("LeagueId", "ResultConfigId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScheduleEntity", null) + .WithMany("Scorings") + .HasForeignKey("ScheduleEntityLeagueId", "ScheduleEntityScheduleId"); + + b.Navigation("ExtScoringSource"); + + b.Navigation("PointsRule"); + + b.Navigation("ResultConfiguration"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Seasons") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoringEntity", "MainScoring") + .WithMany() + .HasForeignKey("MainScoringLeagueId", "MainScoringScoringId"); + + b.Navigation("League"); + + b.Navigation("MainScoring"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany("Sessions") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.EventResultEntity", "Result") + .WithMany("SessionResults") + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.IRSimSessionDetailsEntity", "IRSimSessionDetails") + .WithMany() + .HasForeignKey("LeagueId", "IRSimSessionDetailsId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SessionEntity", "Session") + .WithOne("SessionResult") + .HasForeignKey("iRLeagueDatabaseCore.Models.SessionResultEntity", "LeagueId", "SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IRSimSessionDetails"); + + b.Navigation("Result"); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("StandingConfigs") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ChampSeasonEntity", "ChampSeason") + .WithMany("Standings") + .HasForeignKey("LeagueId", "ChampSeasonId"); + + b.HasOne("iRLeagueDatabaseCore.Models.EventEntity", "Event") + .WithMany() + .HasForeignKey("LeagueId", "EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("Standings") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", "StandingConfig") + .WithMany("Standings") + .HasForeignKey("LeagueId", "StandingConfigId") + .OnDelete(DeleteBehavior.ClientCascade); + + b.Navigation("ChampSeason"); + + b.Navigation("Event"); + + b.Navigation("Season"); + + b.Navigation("StandingConfig"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "Member") + .WithMany() + .HasForeignKey("MemberId"); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingEntity", "SeasonStanding") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "StandingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.TeamEntity", "Team") + .WithMany() + .HasForeignKey("LeagueId", "TeamId"); + + b.Navigation("Member"); + + b.Navigation("SeasonStanding"); + + b.Navigation("Team"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRows_ScoredResultRows", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", "ScoredResultRow") + .WithMany("StandingRows") + .HasForeignKey("LeagueId", "ScoredResultRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StandingRowEntity", "StandingRow") + .WithMany("ResultRows") + .HasForeignKey("LeagueId", "StandingRowRefId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoredResultRow"); + + b.Navigation("StandingRow"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", "CurrentChamp") + .WithMany("StatisticSets") + .HasForeignKey("CurrentChampId"); + + b.HasOne("iRLeagueDatabaseCore.Models.SeasonEntity", "Season") + .WithMany("StatisticSets") + .HasForeignKey("LeagueId", "SeasonId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CurrentChamp"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("Teams") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackConfigEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.TrackGroupEntity", "TrackGroup") + .WithMany("TrackConfigs") + .HasForeignKey("TrackGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrackGroup"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.LeagueEntity", "League") + .WithMany("VoteCategories") + .HasForeignKey("LeagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("League"); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("CleanestDriversId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("CleanestDriverResultsLeagueId", "CleanestDriverResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MemberEntityScoredSessionResultEntity1", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.MemberEntity", null) + .WithMany() + .HasForeignKey("HardChargersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", null) + .WithMany() + .HasForeignKey("HardChargerResultsLeagueId", "HardChargerResultsSessionResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("StatisticSetEntityStatisticSetEntity", b => + { + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("DependendStatisticSetsLeagueId", "DependendStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("iRLeagueDatabaseCore.Models.StatisticSetEntity", null) + .WithMany() + .HasForeignKey("LeagueStatisticSetsLeagueId", "LeagueStatisticSetsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.AcceptedReviewVoteEntity", b => + { + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampionshipEntity", b => + { + b.Navigation("ChampSeasons"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ChampSeasonEntity", b => + { + b.Navigation("EventResults"); + + b.Navigation("Filters"); + + b.Navigation("ResultConfigurations"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventEntity", b => + { + b.Navigation("EventResult"); + + b.Navigation("ScoredEventResults"); + + b.Navigation("Sessions"); + + b.Navigation("SimSessionDetails"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.EventResultEntity", b => + { + b.Navigation("ScoredResults"); + + b.Navigation("SessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.IncidentReviewEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("Comments"); + + b.Navigation("ReviewPenaltys"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.LeagueEntity", b => + { + b.Navigation("Championships"); + + b.Navigation("LeagueMembers"); + + b.Navigation("Payments"); + + b.Navigation("PointRules"); + + b.Navigation("ResultConfigs"); + + b.Navigation("Scorings"); + + b.Navigation("Seasons"); + + b.Navigation("StandingConfigs"); + + b.Navigation("Teams"); + + b.Navigation("VoteCategories"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.MemberEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + + b.Navigation("DriverStatisticRows"); + + b.Navigation("FastestAvgLapResults"); + + b.Navigation("FastestLapResults"); + + b.Navigation("FastestQualyLapResults"); + + b.Navigation("ResultRows"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.PointRuleEntity", b => + { + b.Navigation("AutoPenalties"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ResultConfigurationEntity", b => + { + b.Navigation("PointFilters"); + + b.Navigation("ResultFilters"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ReviewCommentEntity", b => + { + b.Navigation("Replies"); + + b.Navigation("ReviewCommentVotes"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScheduleEntity", b => + { + b.Navigation("Events"); + + b.Navigation("Scorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredEventResultEntity", b => + { + b.Navigation("ScoredSessionResults"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredResultRowEntity", b => + { + b.Navigation("AddPenalties"); + + b.Navigation("ReviewPenalties"); + + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoredSessionResultEntity", b => + { + b.Navigation("ScoredResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.ScoringEntity", b => + { + b.Navigation("DependendScorings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SeasonEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Schedules"); + + b.Navigation("Standings"); + + b.Navigation("StatisticSets"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionEntity", b => + { + b.Navigation("IncidentReviews"); + + b.Navigation("SessionResult"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SessionResultEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingConfigurationEntity", b => + { + b.Navigation("ChampSeasons"); + + b.Navigation("Standings"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingEntity", b => + { + b.Navigation("StandingRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StandingRowEntity", b => + { + b.Navigation("ResultRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.StatisticSetEntity", b => + { + b.Navigation("DriverStatisticRows"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.SubscriptionEntity", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TeamEntity", b => + { + b.Navigation("Members"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.TrackGroupEntity", b => + { + b.Navigation("TrackConfigs"); + }); + + modelBuilder.Entity("iRLeagueDatabaseCore.Models.VoteCategoryEntity", b => + { + b.Navigation("AcceptedReviewVotes"); + + b.Navigation("CommentReviewVotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/iRLeagueDatabaseCore/Models/AcceptedReviewVoteEntity.cs b/src/iRLeagueDatabaseCore/Models/AcceptedReviewVoteEntity.cs new file mode 100644 index 00000000..b31a7cad --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/AcceptedReviewVoteEntity.cs @@ -0,0 +1,65 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class AcceptedReviewVoteEntity +{ + public AcceptedReviewVoteEntity() + { + ReviewPenaltys = new HashSet(); + } + + public long ReviewVoteId { get; set; } + public long LeagueId { get; set; } + public long ReviewId { get; set; } + public long? MemberAtFaultId { get; set; } + public long? TeamAtFaultId { get; set; } + public long? VoteCategoryId { get; set; } + public string Description { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public virtual VoteCategoryEntity VoteCategory { get; set; } + public virtual MemberEntity MemberAtFault { get; set; } + public virtual TeamEntity TeamAtFault { get; set; } + public virtual IncidentReviewEntity Review { get; set; } + public virtual ICollection ReviewPenaltys { get; set; } +} + +public class AcceptedReviewVoteEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ReviewVoteId }); + + entity.HasAlternateKey(e => e.ReviewVoteId); + + entity.Property(e => e.ReviewVoteId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => e.VoteCategoryId); + + entity.HasIndex(e => e.MemberAtFaultId); + + entity.HasIndex(e => e.ReviewId); + + entity.HasOne(d => d.VoteCategory) + .WithMany(p => p.AcceptedReviewVotes) + .HasForeignKey(d => new { d.LeagueId, d.VoteCategoryId }); + + entity.HasOne(d => d.MemberAtFault) + .WithMany(p => p.AcceptedReviewVotes) + .HasForeignKey(d => d.MemberAtFaultId); + + entity.HasOne(d => d.TeamAtFault) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.TeamAtFaultId }); + + entity.HasOne(d => d.Review) + .WithMany(p => p.AcceptedReviewVotes) + .HasForeignKey(d => new { d.LeagueId, d.ReviewId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/AddPenaltyEntity.cs b/src/iRLeagueDatabaseCore/Models/AddPenaltyEntity.cs new file mode 100644 index 00000000..2213d7fa --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/AddPenaltyEntity.cs @@ -0,0 +1,52 @@ +using iRLeagueApiCore.Common.Converters; +using System.Text.Json; + +namespace iRLeagueDatabaseCore.Models; + +public partial class AddPenaltyEntity +{ + public long LeagueId { get; set; } + public long AddPenaltyId { get; set; } + public long ScoredResultRowId { get; set; } + public string Lap { get; set; } + public string Corner { get; set; } + public string Reason { get; set; } + public PenaltyValue Value { get; set; } + + public virtual ScoredResultRowEntity ScoredResultRow { get; set; } +} + +public class AddPenaltyEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.AddPenaltyId }); + + entity.HasAlternateKey(e => e.AddPenaltyId); + + entity.Property(e => e.AddPenaltyId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => new { e.LeagueId, e.ScoredResultRowId }); + + entity.Property(e => e.Reason) + .HasMaxLength(2048); + + entity.Property(e => e.Lap) + .HasMaxLength(255); + + entity.Property(e => e.Corner) + .HasMaxLength(255); + + entity.Property(e => e.Value) + .HasColumnType("json") + .HasConversion( + v => JsonSerializer.Serialize(v, default(JsonSerializerOptions)), + v => JsonSerializer.Deserialize(v, default(JsonSerializerOptions))); + + entity.HasOne(d => d.ScoredResultRow) + .WithMany(p => p.AddPenalties) + .HasForeignKey(d => new { d.LeagueId, d.ScoredResultRowId }) + .OnDelete(DeleteBehavior.ClientCascade); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/AutoPenaltyConfigEntity.cs b/src/iRLeagueDatabaseCore/Models/AutoPenaltyConfigEntity.cs new file mode 100644 index 00000000..f5c78286 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/AutoPenaltyConfigEntity.cs @@ -0,0 +1,52 @@ +using iRLeagueApiCore.Common.Models; +using System.Text.Json; + +namespace iRLeagueDatabaseCore.Models; +public partial class AutoPenaltyConfigEntity +{ + public AutoPenaltyConfigEntity() + { + Conditions = new HashSet(); + } + + public long LeagueId { get; set; } + public long PenaltyConfigId { get; set; } + public long PointRuleId { get; set; } + + public string Description { get; set; } + public PenaltyType Type { get; set; } + public int Points { get; set; } + public TimeSpan Time { get; set; } + public int Positions { get; set; } + + public virtual PointRuleEntity PointRule { get; set; } + public virtual ICollection Conditions { get; set; } +} + +public sealed class AutoPenaltyConfigEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.ToTable("AutoPenaltyConfigs"); + + entity.HasKey(e => new { e.LeagueId, e.PenaltyConfigId }); + + entity.HasAlternateKey(e => e.PenaltyConfigId); + + entity.Property(e => e.PenaltyConfigId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.Conditions) + .HasColumnType("json") + .HasConversion( + v => JsonSerializer.Serialize(v, default(JsonSerializerOptions)), + v => JsonSerializer.Deserialize>(v, default(JsonSerializerOptions)), + new ValueComparer>(false)) + .IsRequired(true); + + entity.HasOne(d => d.PointRule) + .WithMany(p => p.AutoPenalties) + .HasForeignKey(d => new { d.LeagueId, d.PointRuleId }) + .OnDelete(DeleteBehavior.Cascade); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ChampSeasonEntity.cs b/src/iRLeagueDatabaseCore/Models/ChampSeasonEntity.cs new file mode 100644 index 00000000..174859c9 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ChampSeasonEntity.cs @@ -0,0 +1,100 @@ +using iRLeagueApiCore.Common.Models.Reviews; + +namespace iRLeagueDatabaseCore.Models; +public partial class ChampSeasonEntity : IVersionEntity +{ + public ChampSeasonEntity() + { + ResultConfigurations = new HashSet(); + EventResults = new HashSet(); + Standings = new HashSet(); + Filters = new HashSet(); + } + + public long LeagueId { get; set; } + public long ChampSeasonId { get; set; } + public long ChampionshipId { get; set; } + public long SeasonId { get; set; } + public long? DefaultResultConfigId { get; set; } + public long? StandingConfigId { get; set; } + public ResultKind ResultKind { get; set; } + public bool IsActive { get; set; } + + public virtual ChampionshipEntity Championship { get; set; } + public virtual SeasonEntity Season { get; set; } + public virtual ResultConfigurationEntity DefaultResultConfig { get; set; } + public virtual ICollection ResultConfigurations { get; set; } + public virtual StandingConfigurationEntity StandingConfiguration { get; set; } + public virtual IEnumerable EventResults { get; set; } + public virtual IEnumerable Standings { get; set; } + public virtual ICollection Filters { get; set; } + + #region version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion +} + +public sealed class ChampSeasonEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.ToTable("ChampSeasons"); + + entity.HasKey(e => new { e.LeagueId, e.ChampSeasonId }); + + entity.HasAlternateKey(e => e.ChampSeasonId); + + entity.Property(e => e.ChampSeasonId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.ResultKind) + .HasConversion>() + .HasMaxLength(50); + + entity.HasOne(d => d.Championship) + .WithMany(p => p.ChampSeasons) + .HasForeignKey(d => new { d.LeagueId, d.ChampionshipId }) + .IsRequired(true) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.Season) + .WithMany(p => p.ChampSeasons) + .HasForeignKey(d => new { d.LeagueId, d.SeasonId }) + .IsRequired(true) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.StandingConfiguration) + .WithMany(p => p.ChampSeasons) + .HasForeignKey(d => new { d.LeagueId, d.StandingConfigId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientSetNull); + + entity.HasMany(d => d.ResultConfigurations) + .WithOne(p => p.ChampSeason) + .HasForeignKey(d => new { d.LeagueId, d.ChampSeasonId }); + + entity.HasMany(p => p.EventResults) + .WithOne(d => d.ChampSeason) + .HasForeignKey(d => new { d.LeagueId, d.ChampSeasonId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientSetNull); + + entity.HasOne(d => d.DefaultResultConfig) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.DefaultResultConfigId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientSetNull); + + entity.HasMany(p => p.Standings) + .WithOne(d => d.ChampSeason) + .HasForeignKey(d => new { d.LeagueId, d.ChampSeasonId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientSetNull); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ChampionshipEntity.cs b/src/iRLeagueDatabaseCore/Models/ChampionshipEntity.cs new file mode 100644 index 00000000..91224f1b --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ChampionshipEntity.cs @@ -0,0 +1,52 @@ +namespace iRLeagueDatabaseCore.Models; +public partial class ChampionshipEntity : IArchivableVersionEntity +{ + public ChampionshipEntity() + { + ChampSeasons = new HashSet(); + } + + public long LeagueId { get; set; } + public long ChampionshipId { get; set; } + public string Name { get; set; } + public string DisplayName { get; set; } + + public virtual LeagueEntity League { get; set; } + public virtual ICollection ChampSeasons { get; set; } + + #region version + public bool IsArchived { get; set; } + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion +} + +public sealed class ChampionshipEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.ToTable("Championships"); + + entity.HasKey(e => new { e.LeagueId, e.ChampionshipId }); + + entity.HasAlternateKey(e => e.ChampionshipId); + + entity.Property(e => e.ChampionshipId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.Name).HasMaxLength(80); + + entity.Property(e => e.DisplayName).HasMaxLength(255); + + entity.HasOne(d => d.League) + .WithMany(p => p.Championships) + .HasForeignKey(d => d.LeagueId) + .IsRequired(true) + .OnDelete(DeleteBehavior.Cascade); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/CustomIncidentEntity.cs b/src/iRLeagueDatabaseCore/Models/CustomIncidentEntity.cs new file mode 100644 index 00000000..0e37968d --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/CustomIncidentEntity.cs @@ -0,0 +1,25 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class CustomIncidentEntity +{ + public long IncidentId { get; set; } + public long LeagueId { get; set; } + public virtual LeagueEntity League { get; set; } + public string Text { get; set; } + public int Index { get; set; } +} + +public class CustomIncidentEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.IncidentId }); + + entity.HasAlternateKey(e => e.IncidentId); + + entity.Property(e => e.IncidentId) + .ValueGeneratedOnAdd(); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/DriverStatisticRowEntity.cs b/src/iRLeagueDatabaseCore/Models/DriverStatisticRowEntity.cs new file mode 100644 index 00000000..40ed1b00 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/DriverStatisticRowEntity.cs @@ -0,0 +1,152 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class DriverStatisticRowEntity +{ + public long StatisticSetId { get; set; } + public long LeagueId { get; set; } + public long MemberId { get; set; } + public long? FirstResultRowId { get; set; } + public long? LastResultRowId { get; set; } + public int StartIRating { get; set; } + public int EndIRating { get; set; } + public double StartSRating { get; set; } + public double EndSRating { get; set; } + public long? FirstSessionId { get; set; } + public DateTime? FirstSessionDate { get; set; } + public long? FirstRaceId { get; set; } + public DateTime? FirstRaceDate { get; set; } + public long? LastSessionId { get; set; } + public DateTime? LastSessionDate { get; set; } + public long? LastRaceId { get; set; } + public DateTime? LastRaceDate { get; set; } + public double RacePoints { get; set; } + public double TotalPoints { get; set; } + public double BonusPoints { get; set; } + public int Races { get; set; } + public int Wins { get; set; } + public int Poles { get; set; } + public int Top3 { get; set; } + public int Top5 { get; set; } + public int Top10 { get; set; } + public int Top15 { get; set; } + public int Top20 { get; set; } + public int Top25 { get; set; } + public int RacesInPoints { get; set; } + public int RacesCompleted { get; set; } + public double Incidents { get; set; } + public double PenaltyPoints { get; set; } + public int FastestLaps { get; set; } + public int IncidentsUnderInvestigation { get; set; } + public int IncidentsWithPenalty { get; set; } + public double LeadingLaps { get; set; } + public double CompletedLaps { get; set; } + public int CurrentSeasonPosition { get; set; } + public double DrivenKm { get; set; } + public double LeadingKm { get; set; } + public double AvgFinishPosition { get; set; } + public double AvgFinalPosition { get; set; } + public double AvgStartPosition { get; set; } + public double AvgPointsPerRace { get; set; } + public double AvgIncidentsPerRace { get; set; } + public double AvgIncidentsPerLap { get; set; } + public double AvgIncidentsPerKm { get; set; } + public double AvgPenaltyPointsPerRace { get; set; } + public double AvgPenaltyPointsPerLap { get; set; } + public double AvgPenaltyPointsPerKm { get; set; } + public double AvgIRating { get; set; } + public double AvgSRating { get; set; } + public double BestFinishPosition { get; set; } + public double WorstFinishPosition { get; set; } + public double FirstRaceFinishPosition { get; set; } + public double LastRaceFinishPosition { get; set; } + public int BestFinalPosition { get; set; } + public int WorstFinalPosition { get; set; } + public int FirstRaceFinalPosition { get; set; } + public int LastRaceFinalPosition { get; set; } + public double BestStartPosition { get; set; } + public double WorstStartPosition { get; set; } + public double FirstRaceStartPosition { get; set; } + public double LastRaceStartPosition { get; set; } + public int Titles { get; set; } + public int HardChargerAwards { get; set; } + public int CleanestDriverAwards { get; set; } + + public virtual SessionEntity FirstRace { get; set; } + public virtual ScoredResultRowEntity FirstResultRow { get; set; } + public virtual SessionEntity FirstSession { get; set; } + public virtual SessionEntity LastRace { get; set; } + public virtual ScoredResultRowEntity LastResultRow { get; set; } + public virtual SessionEntity LastSession { get; set; } + public virtual MemberEntity Member { get; set; } + public virtual StatisticSetEntity StatisticSet { get; set; } +} + +public class DriverStatisticRowEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.StatisticSetId, e.MemberId }); + + entity.HasIndex(e => new { e.LeagueId, e.FirstRaceId }); + + entity.HasIndex(e => new { e.LeagueId, e.FirstResultRowId }); + + entity.HasIndex(e => new { e.LeagueId, e.FirstSessionId }); + + entity.HasIndex(e => new { e.LeagueId, e.LastRaceId }); + + entity.HasIndex(e => new { e.LeagueId, e.LastResultRowId }); + + entity.HasIndex(e => new { e.LeagueId, e.LastSessionId }); + + entity.HasIndex(e => e.MemberId); + + entity.HasIndex(e => e.StatisticSetId); + + entity.Property(e => e.FirstRaceDate) + .HasColumnType("datetime"); + + entity.Property(e => e.FirstSessionDate) + .HasColumnType("datetime"); + + entity.Property(e => e.LastRaceDate) + .HasColumnType("datetime"); + + entity.Property(e => e.LastSessionDate) + .HasColumnType("datetime"); + + entity.HasOne(d => d.FirstRace) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.FirstRaceId }); + + entity.HasOne(d => d.FirstResultRow) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.FirstResultRowId }); + + entity.HasOne(d => d.FirstSession) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.FirstSessionId }); + + entity.HasOne(d => d.LastRace) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.LastRaceId }); + + entity.HasOne(d => d.LastResultRow) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.LastResultRowId }); + + entity.HasOne(d => d.LastSession) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.LastSessionId }); + + entity.HasOne(d => d.Member) + .WithMany(p => p.DriverStatisticRows) + .HasForeignKey(d => d.MemberId); + + entity.HasOne(d => d.StatisticSet) + .WithMany(p => p.DriverStatisticRows) + .HasForeignKey(d => new { d.LeagueId, d.StatisticSetId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/EventEntity.cs b/src/iRLeagueDatabaseCore/Models/EventEntity.cs new file mode 100644 index 00000000..d0397b34 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/EventEntity.cs @@ -0,0 +1,91 @@ +namespace iRLeagueDatabaseCore.Models; + +public class EventEntity : IVersionEntity +{ + public EventEntity() + { + Sessions = new HashSet(); + ScoredEventResults = new HashSet(); + ResultConfigs = new HashSet(); + SimSessionDetails = new HashSet(); + } + + public long EventId { get; set; } + public long LeagueId { get; set; } + public long ScheduleId { get; set; } + public long? TrackId { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public EventType EventType { get; set; } + public DateTime? Date { get; set; } + public TimeSpan Duration { get; set; } + public string Name { get; set; } + public string IrSessionId { get; set; } + public string IrResultLink { get; set; } + + public virtual ScheduleEntity Schedule { get; set; } + public virtual TrackConfigEntity Track { get; set; } + public virtual EventResultEntity EventResult { get; set; } + public virtual ICollection Sessions { get; set; } + public virtual ICollection ScoredEventResults { get; set; } + public virtual ICollection ResultConfigs { get; set; } + public virtual ICollection SimSessionDetails { get; set; } + + #region Version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion +} + +public class EventEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.EventId }); + + entity.HasAlternateKey(e => e.EventId); + + entity.Property(e => e.Date).HasColumnType("datetime"); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.Property(e => e.Duration).HasConversion(); + + entity.Property(e => e.EventType) + .HasConversion(); + + entity.Property(e => e.EventId) + .ValueGeneratedOnAdd(); + + entity.HasOne(e => e.Schedule) + .WithMany(p => p.Events) + .HasForeignKey(e => new { e.LeagueId, e.ScheduleId }); + + entity.HasOne(d => d.Track) + .WithMany() + .HasForeignKey(d => d.TrackId) + .OnDelete(DeleteBehavior.SetNull) + .IsRequired(false); + + entity.HasMany(d => d.ResultConfigs) + .WithMany(p => p.Events) + .UsingEntity( + right => right.HasOne(e => e.ResultConfig) + .WithMany() + .HasForeignKey(e => new { e.LeagueId, e.ResultConfigRefId }), + left => left.HasOne(e => e.Event) + .WithMany() + .HasForeignKey(e => new { e.LeagueId, e.EventRefId })); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/EventResultConfigs.cs b/src/iRLeagueDatabaseCore/Models/EventResultConfigs.cs new file mode 100644 index 00000000..14596ba9 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/EventResultConfigs.cs @@ -0,0 +1,11 @@ +namespace iRLeagueDatabaseCore.Models; + +public class EventResultConfigs +{ + public long LeagueId { get; set; } + public long EventRefId { get; set; } + public long ResultConfigRefId { get; set; } + + public virtual EventEntity Event { get; set; } + public virtual ResultConfigurationEntity ResultConfig { get; set; } +} diff --git a/src/iRLeagueDatabaseCore/Models/EventResultEntity.cs b/src/iRLeagueDatabaseCore/Models/EventResultEntity.cs new file mode 100644 index 00000000..c12b86ed --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/EventResultEntity.cs @@ -0,0 +1,45 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class EventResultEntity : IVersionEntity +{ + public EventResultEntity() + { + SessionResults = new HashSet(); + ScoredResults = new HashSet(); + } + + public long LeagueId { get; set; } + public long EventId { get; set; } + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + public bool RequiresRecalculation { get; set; } + + public virtual EventEntity Event { get; set; } + public virtual ICollection SessionResults { get; set; } + public virtual ICollection ScoredResults { get; set; } +} + +public class EventResultEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.EventId }); + + entity.HasIndex(e => e.EventId); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.HasOne(d => d.Event) + .WithOne(p => p.EventResult) + .HasForeignKey(d => new { d.LeagueId, d.EventId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/FilterCondition.cs b/src/iRLeagueDatabaseCore/Models/FilterCondition.cs new file mode 100644 index 00000000..e4262f00 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/FilterCondition.cs @@ -0,0 +1,11 @@ +using System.Runtime.Serialization; + +namespace iRLeagueDatabaseCore.Models; + +public sealed class FilterCondition +{ + public FilterType FilterType { get; set; } + public string ColumnPropertyName { get; set; } = string.Empty; + public ComparatorType Comparator { get; set; } + public ICollection FilterValues { get; set; } = new List(); +} \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/Models/FilterConditionEntity.cs b/src/iRLeagueDatabaseCore/Models/FilterConditionEntity.cs new file mode 100644 index 00000000..4c1f8309 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/FilterConditionEntity.cs @@ -0,0 +1,47 @@ +//namespace iRLeagueDatabaseCore.Models; + +//public partial class FilterConditionEntity +//{ +// public FilterConditionEntity() +// { +// FilterValues = new HashSet(); +// } + +// public long LeagueId { get; set; } +// public long ConditionId { get; set; } +// public long FilterOptionId { get; set; } + +// public FilterType FilterType { get; set; } +// public string ColumnPropertyName { get; set; } +// public ComparatorType Comparator { get; set; } +// public MatchedValueAction Action { get; set; } + +// public virtual FilterOptionEntity FilterOption { get; set; } +// public virtual ICollection FilterValues { get; set; } +//} + +//public sealed class FilterConditionEntityConfiguration : IEntityTypeConfiguration +//{ +// public void Configure(EntityTypeBuilder entity) +// { +// entity.HasKey(e => new { e.LeagueId, e.ConditionId }); + +// entity.HasAlternateKey(e => e.ConditionId); + +// entity.Property(e => e.ConditionId) +// .ValueGeneratedOnAdd(); + +// entity.Property(e => e.FilterValues) +// .HasConversion(new CollectionToStringConverter(), new ValueComparer>(true)); + +// entity.Property(e => e.FilterType).HasConversion>(); + +// entity.Property(e => e.Comparator).HasConversion>(); + +// entity.Property(e => e.Action).HasConversion>(); + +// entity.HasOne(d => d.FilterOption) +// .WithMany(p => p.Conditions) +// .HasForeignKey(d => new { d.LeagueId, d.FilterOptionId }); +// } +//} diff --git a/src/iRLeagueDatabaseCore/Models/FilterOptionEntity.cs b/src/iRLeagueDatabaseCore/Models/FilterOptionEntity.cs new file mode 100644 index 00000000..5253fc5c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/FilterOptionEntity.cs @@ -0,0 +1,75 @@ +using iRLeagueApiCore.Common.Models; +using System.Text.Json; + +namespace iRLeagueDatabaseCore.Models; + +public partial class FilterOptionEntity : IVersionEntity +{ + public FilterOptionEntity() + { + Conditions = new HashSet(); + } + + public long LeagueId { get; set; } + public long FilterOptionId { get; set; } + public long? PointFilterResultConfigId { get; set; } + public long? ResultFilterResultConfigId { get; set; } + public long? ChampSeasonId { get; set; } + + #region version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion + public virtual ResultConfigurationEntity PointFilterResultConfig { get; set; } + public virtual ResultConfigurationEntity ResultFilterResultConfig { get; set; } + public virtual ChampSeasonEntity ChampSeason { get; set; } + public virtual ICollection Conditions { get; set; } +} + +public sealed class FilterOptionEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.FilterOptionId }); + + entity.HasAlternateKey(e => e.FilterOptionId); + + entity.Property(e => e.FilterOptionId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.Property(e => e.Conditions) + .HasColumnType("json") + .HasConversion( + v => JsonSerializer.Serialize(v, default(JsonSerializerOptions)), + v => JsonSerializer.Deserialize>(v, default(JsonSerializerOptions)), + new ValueComparer>(false)) + .IsRequired(true); + + entity.HasOne(d => d.PointFilterResultConfig) + .WithMany(p => p.PointFilters) + .HasForeignKey(d => new { d.LeagueId, d.PointFilterResultConfigId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientCascade); + + entity.HasOne(d => d.ResultFilterResultConfig) + .WithMany(p => p.ResultFilters) + .HasForeignKey(d => new { d.LeagueId, d.ResultFilterResultConfigId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientCascade); + + entity.HasOne(d => d.ChampSeason) + .WithMany(p => p.Filters) + .HasForeignKey(d => new { d.LeagueId, d.ChampSeasonId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientCascade); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/IArchivableVersionEntity.cs b/src/iRLeagueDatabaseCore/Models/IArchivableVersionEntity.cs new file mode 100644 index 00000000..d695925d --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/IArchivableVersionEntity.cs @@ -0,0 +1,5 @@ +namespace iRLeagueDatabaseCore.Models; +public interface IArchivableVersionEntity : IVersionEntity +{ + public bool IsArchived { get; set; } +} diff --git a/src/iRLeagueDatabaseCore/Models/IRSimSessionDetailsEntity.cs b/src/iRLeagueDatabaseCore/Models/IRSimSessionDetailsEntity.cs new file mode 100644 index 00000000..95b23756 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/IRSimSessionDetailsEntity.cs @@ -0,0 +1,92 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class IRSimSessionDetailsEntity +{ + public long LeagueId { get; set; } + public long EventId { get; set; } + public long SessionDetailsId { get; set; } + public long IRSubsessionId { get; set; } + public long IRSeasonId { get; set; } + public string IRSeasonName { get; set; } + public int IRSeasonYear { get; set; } + public int IRSeasonQuarter { get; set; } + public int IRRaceWeek { get; set; } + public long IRSessionId { get; set; } + public int LicenseCategory { get; set; } + public string SessionName { get; set; } + public DateTime? StartTime { get; set; } + public DateTime? EndTime { get; set; } + public int CornersPerLap { get; set; } + public double KmDistPerLap { get; set; } + public int MaxWeeks { get; set; } + public int EventStrengthOfField { get; set; } + public TimeSpan EventAverageLap { get; set; } + public int EventLapsComplete { get; set; } + public int NumCautions { get; set; } + public int NumCautionLaps { get; set; } + public int NumLeadChanges { get; set; } + public int TimeOfDay { get; set; } + public int DamageModel { get; set; } + public int IRTrackId { get; set; } + public string TrackName { get; set; } + public string ConfigName { get; set; } + public int TrackCategoryId { get; set; } + public string Category { get; set; } + public int WeatherType { get; set; } + public int TempUnits { get; set; } + public int TempValue { get; set; } + public int RelHumidity { get; set; } + public int Fog { get; set; } + public int WindDir { get; set; } + public int WindUnits { get; set; } + public int Skies { get; set; } + public int WeatherVarInitial { get; set; } + public int WeatherVarOngoing { get; set; } + public DateTime? SimStartUtcTime { get; set; } + public TimeSpan SimStartUtcOffset { get; set; } + public bool LeaveMarbles { get; set; } + public int PracticeRubber { get; set; } + public int QualifyRubber { get; set; } + public int WarmupRubber { get; set; } + public int RaceRubber { get; set; } + public int PracticeGripCompound { get; set; } + public int QualifyGripCompund { get; set; } + public int WarmupGripCompound { get; set; } + public int RaceGripCompound { get; set; } + + public virtual EventEntity Event { get; set; } +} + +public class IRSimSessionDetailsEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.SessionDetailsId }); + + entity.HasAlternateKey(e => e.SessionDetailsId); + + entity.Property(e => e.SessionDetailsId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.EventAverageLap) + .HasConversion(); + + entity.Property(e => e.EndTime) + .HasColumnType("datetime"); + + entity.Property(e => e.SimStartUtcOffset) + .HasConversion(); + + entity.Property(e => e.SimStartUtcTime) + .HasColumnType("datetime"); + + entity.Property(e => e.StartTime) + .HasColumnType("datetime"); + + entity.HasOne(d => d.Event) + .WithMany(p => p.SimSessionDetails) + .HasForeignKey(d => new { d.LeagueId, d.EventId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/IVersionEntity.cs b/src/iRLeagueDatabaseCore/Models/IVersionEntity.cs new file mode 100644 index 00000000..bd3252d5 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/IVersionEntity.cs @@ -0,0 +1,12 @@ +namespace iRLeagueDatabaseCore.Models; + +public interface IVersionEntity +{ + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } +} diff --git a/src/iRLeagueDatabaseCore/Models/IncidentReviewEntity.cs b/src/iRLeagueDatabaseCore/Models/IncidentReviewEntity.cs new file mode 100644 index 00000000..b5d27231 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/IncidentReviewEntity.cs @@ -0,0 +1,86 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class IncidentReviewEntity : IVersionEntity +{ + public IncidentReviewEntity() + { + AcceptedReviewVotes = new HashSet(); + Comments = new HashSet(); + InvolvedMembers = new HashSet(); + InvolvedTeams = new HashSet(); + ReviewPenaltys = new HashSet(); + } + + public long ReviewId { get; set; } + public long LeagueId { get; set; } + public long SessionId { get; set; } + + public string AuthorUserId { get; set; } + public string AuthorName { get; set; } + public string IncidentKind { get; set; } + public string FullDescription { get; set; } + public string OnLap { get; set; } + public string Corner { get; set; } + public TimeSpan TimeStamp { get; set; } + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + public string ResultLongText { get; set; } + public string IncidentNr { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public virtual SessionEntity Session { get; set; } + public virtual ICollection AcceptedReviewVotes { get; set; } + public virtual ICollection Comments { get; set; } + public virtual ICollection InvolvedMembers { get; set; } + public virtual ICollection InvolvedTeams { get; set; } + public virtual ICollection ReviewPenaltys { get; set; } +} + +public class IncidentReviewEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ReviewId }); + + entity.HasAlternateKey(e => e.ReviewId); + + entity.Property(e => e.ReviewId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => e.SessionId); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.Property(e => e.TimeStamp).HasConversion(new TimeSpanToTicksConverter()); + + entity.HasOne(d => d.Session) + .WithMany(p => p.IncidentReviews) + .HasForeignKey(d => new { d.LeagueId, d.SessionId }) + .IsRequired() + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(d => d.InvolvedMembers) + .WithMany(p => p.InvolvedReviews) + .UsingEntity(e => e.ToTable("IncidentReviewsInvolvedMembers")); + + entity.HasMany(d => d.InvolvedTeams) + .WithMany(p => p.InvolvedReviews) + .UsingEntity( + right => right.HasOne(x => x.Team).WithMany().HasForeignKey(x => new { x.LeagueId, x.TeamRefId }), + left => left.HasOne(x => x.Review).WithMany().HasForeignKey(x => new { x.LeagueId, x.ReviewRefId }) + ); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/IncidentReviewsInvolvedTeams.cs b/src/iRLeagueDatabaseCore/Models/IncidentReviewsInvolvedTeams.cs new file mode 100644 index 00000000..5944f280 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/IncidentReviewsInvolvedTeams.cs @@ -0,0 +1,11 @@ + +namespace iRLeagueDatabaseCore.Models; +public partial class IncidentReviewsInvolvedTeams +{ + public long LeagueId { get; set; } + public long ReviewRefId { get; set; } + public long TeamRefId { get; set; } + + public virtual IncidentReviewEntity Review { get; set; } + public virtual TeamEntity Team { get; set; } +} diff --git a/src/iRLeagueDatabaseCore/Models/LeagueEntity.cs b/src/iRLeagueDatabaseCore/Models/LeagueEntity.cs new file mode 100644 index 00000000..10ab490f --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/LeagueEntity.cs @@ -0,0 +1,74 @@ +namespace iRLeagueDatabaseCore.Models; + +public class LeagueEntity : Revision, IVersionEntity +{ + public LeagueEntity() + { + Seasons = new HashSet(); + ResultConfigs = new HashSet(); + PointRules = new HashSet(); + LeagueMembers = new HashSet(); + Teams = new HashSet(); + VoteCategories = new HashSet(); + Championships = new HashSet(); + StandingConfigs = new HashSet(); + } + public long Id { get; set; } + public string Name { get; set; } + public string NameFull { get; set; } + public string Description { get; set; } + public string DescriptionPlain { get; set; } + public bool IsInitialized { get; set; } + public bool EnableProtests { get; set; } + /// + /// Time span after a race has finished (according to event duration) after which a protest can be filed + /// + public TimeSpan ProtestCoolDownPeriod { get; set; } + /// + /// Time span after a race has finished (according to event duration) until a protest can be filed + /// + public TimeSpan ProtestsClosedAfter { get; set; } + /// + /// Set public visibility of protests + /// + public ProtestPublicSetting ProtestsPublic { get; set; } + public ProtestFormAccess ProtestFormAccess { get; set; } + public LeaguePublicSetting LeaguePublic { get; set; } + public bool EnableLiveReviews { get; set; } + public SubscriptionStatus Subscription { get; set; } + public DateTime? Expires { get; set; } + + public virtual ICollection Seasons { get; set; } + public virtual ICollection ResultConfigs { get; set; } + public virtual ICollection PointRules { get; set; } + public virtual IEnumerable Scorings { get; set; } + public virtual ICollection LeagueMembers { get; set; } + public virtual ICollection Teams { get; set; } + public virtual ICollection VoteCategories { get; set; } + public virtual ICollection Championships { get; set; } + public virtual ICollection StandingConfigs { get; set; } + public virtual IEnumerable Payments { get; set; } +} + +public class LeagueEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => e.Id); + + entity.HasAlternateKey(e => e.Name); + + entity.Property(e => e.Name) + .HasMaxLength(85); + + entity.Property(e => e.ProtestCoolDownPeriod) + .HasConversion(); + + entity.Property(e => e.ProtestsClosedAfter) + .HasConversion(); + + entity.HasMany(d => d.Scorings) + .WithOne() + .HasForeignKey(p => p.LeagueId); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/LeagueMemberEntity.cs b/src/iRLeagueDatabaseCore/Models/LeagueMemberEntity.cs new file mode 100644 index 00000000..f64b9f9d --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/LeagueMemberEntity.cs @@ -0,0 +1,37 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class LeagueMemberEntity +{ + public LeagueMemberEntity() + { + } + + public long MemberId { get; set; } + public long LeagueId { get; set; } + public long? TeamId { get; set; } + + public virtual MemberEntity Member { get; set; } + public virtual LeagueEntity League { get; set; } + public virtual TeamEntity Team { get; set; } + public virtual IEnumerable ProtestsInvolved { get; set; } +} + +public class LeagueMemberEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.MemberId }); + + entity.HasIndex(e => e.MemberId); + + entity.HasOne(e => e.League) + .WithMany(e => e.LeagueMembers) + .HasForeignKey(e => e.LeagueId); + + entity.HasOne(e => e.Team) + .WithMany(e => e.Members) + .HasForeignKey(e => new { e.LeagueId, e.TeamId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/MemberEntity.cs b/src/iRLeagueDatabaseCore/Models/MemberEntity.cs new file mode 100644 index 00000000..611ecab4 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/MemberEntity.cs @@ -0,0 +1,56 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class MemberEntity +{ + public MemberEntity() + { + AcceptedReviewVotes = new HashSet(); + CommentReviewVotes = new HashSet(); + DriverStatisticRows = new HashSet(); + InvolvedReviews = new HashSet(); + ResultRows = new HashSet(); + CleanestDriverResults = new HashSet(); + FastestAvgLapResults = new HashSet(); + FastestLapResults = new HashSet(); + FastestQualyLapResults = new HashSet(); + HardChargerResults = new HashSet(); + StatisticSets = new HashSet(); + } + + public long Id { get; set; } + public string Firstname { get; set; } + public string Lastname { get; set; } + public string IRacingId { get; set; } + public string DanLisaId { get; set; } + public string DiscordId { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public virtual ICollection AcceptedReviewVotes { get; set; } + public virtual ICollection CommentReviewVotes { get; set; } + public virtual ICollection DriverStatisticRows { get; set; } + public virtual ICollection InvolvedReviews { get; set; } + public virtual ICollection ResultRows { get; set; } + public virtual ICollection CleanestDriverResults { get; set; } + public virtual ICollection FastestAvgLapResults { get; set; } + public virtual ICollection FastestLapResults { get; set; } + public virtual ICollection FastestQualyLapResults { get; set; } + public virtual ICollection HardChargerResults { get; set; } + public virtual ICollection StatisticSets { get; set; } +} + +public class MemberEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => e.Id); + + //entity.HasIndex(e => e.IRacingId) + // .IsUnique(); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/PaymentEntity.cs b/src/iRLeagueDatabaseCore/Models/PaymentEntity.cs new file mode 100644 index 00000000..bb8818a0 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/PaymentEntity.cs @@ -0,0 +1,64 @@ +using System.Diagnostics.CodeAnalysis; + +namespace iRLeagueDatabaseCore.Models; + +#nullable enable +public class PaymentEntity +{ + public Guid Id { get; set; } + public string? PlanId { get; set; } + public string? SubscriptionId { get; set; } + public long LeagueId { get; set; } + public string UserId { get; set; } = default!; + public PaymentType Type { get; set; } + public DateTime LastPaymentReceived { get; set; } + public DateTime? NextPaymentDue { get; set; } + public PaymentStatus Status { get; set; } + + [MaybeNull] + public virtual LeagueEntity League { get; set; } + public virtual SubscriptionEntity? Subscription { get; set; } +} + +public enum PaymentType +{ + Subscription, +} + +public enum PaymentStatus +{ + Inactive, + Active, +} + +public class PaymentEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.ToTable("Payments"); + + entity.HasKey(e => e.Id); + + entity.Property(e => e.PlanId) + .HasMaxLength(255); + + entity.Property(e => e.SubscriptionId) + .HasMaxLength(255); + + entity.Property(e => e.UserId) + .HasMaxLength(255); + + entity.Property(e => e.UserId) + .IsRequired(); + + entity.Property(e => e.Type) + .HasConversion(); + + entity.Property(e => e.Status) + .HasConversion(); + + entity.HasOne(d => d.Subscription) + .WithMany(p => p.Payments) + .HasForeignKey(d => d.PlanId); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/PenaltyValue.cs b/src/iRLeagueDatabaseCore/Models/PenaltyValue.cs new file mode 100644 index 00000000..d6c66cc9 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/PenaltyValue.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; + +namespace iRLeagueDatabaseCore.Models; + +public sealed class PenaltyValue +{ + public PenaltyType Type { get; set; } + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public double Points { get; set; } + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public TimeSpan Time { get; set; } + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public int Positions { get; set; } +} diff --git a/src/iRLeagueDatabaseCore/Models/PointRuleEntity.cs b/src/iRLeagueDatabaseCore/Models/PointRuleEntity.cs new file mode 100644 index 00000000..e82b7031 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/PointRuleEntity.cs @@ -0,0 +1,81 @@ +using iRLeagueApiCore.Common.Models; +using System.Text.Json; + +namespace iRLeagueDatabaseCore.Models; + +public class PointRuleEntity : IVersionEntity +{ + public PointRuleEntity() + { + Scorings = new HashSet(); + AutoPenalties = new HashSet(); + BonusPoints = new List(); + } + + public long LeagueId { get; set; } + public long PointRuleId { get; set; } + + public string Name { get; set; } + public PointRuleType RuleType { get; set; } + public ICollection PointsPerPlace { get; set; } + public ICollection BonusPoints { get; set; } + public string Formula { get; set; } + public int MaxPoints { get; set; } + public int PointDropOff { get; set; } + public ICollection PointsSortOptions { get; set; } + public ICollection FinalSortOptions { get; set; } + + public virtual LeagueEntity League { get; set; } + public virtual IEnumerable Scorings { get; set; } + public virtual ICollection AutoPenalties { get; set; } + + #region version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion +} + +public class PointsRuleEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.PointRuleId }); + + entity.HasAlternateKey(e => e.PointRuleId); + + entity.Property(e => e.PointRuleId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.CreatedOn) + .HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn) + .HasColumnType("datetime"); + + entity.Property(e => e.PointsPerPlace) + .HasConversion(new CollectionToStringConverter(), new ValueComparer>(true)); + + entity.Property(e => e.BonusPoints) + .HasColumnType("json") + .HasConversion( + v => JsonSerializer.Serialize(v, default(JsonSerializerOptions)), + v => JsonSerializer.Deserialize>(v, default(JsonSerializerOptions)), + new ValueComparer>(false)) + .IsRequired(true); + + entity.Property(e => e.PointsSortOptions) + .HasConversion(new CollectionToStringConverter(), new ValueComparer>(true)); + + entity.Property(e => e.FinalSortOptions) + .HasConversion(new CollectionToStringConverter(), new ValueComparer>(true)); + + entity.HasOne(d => d.League) + .WithMany(p => p.PointRules) + .HasForeignKey(d => d.LeagueId); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ProtestEntity.cs b/src/iRLeagueDatabaseCore/Models/ProtestEntity.cs new file mode 100644 index 00000000..6d051c0e --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ProtestEntity.cs @@ -0,0 +1,55 @@ +namespace iRLeagueDatabaseCore.Models; + +public partial class ProtestEntity +{ + public ProtestEntity() + { + InvolvedMembers = new HashSet(); + } + + public long LeagueId { get; set; } + public long ProtestId { get; set; } + public long SessionId { get; set; } + public long AuthorMemberId { get; set; } + + public string FullDescription { get; set; } + public string OnLap { get; set; } + public string Corner { get; set; } + + public virtual LeagueMemberEntity Author { get; set; } + public virtual SessionEntity Session { get; set; } + public virtual ICollection InvolvedMembers { get; set; } +} + +public sealed class ProtestEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.ToTable("Protests"); + + entity.HasKey(e => new { e.LeagueId, e.ProtestId }); + + entity.HasAlternateKey(e => e.ProtestId); + + entity.Property(e => e.ProtestId) + .ValueGeneratedOnAdd(); + + entity.HasOne(p => p.Author) + .WithMany() + .HasForeignKey(p => new { p.LeagueId, p.AuthorMemberId }); + + entity.HasOne(p => p.Session) + .WithMany() + .HasForeignKey(p => new { p.LeagueId, p.SessionId }); + + entity.HasMany(p => p.InvolvedMembers) + .WithMany(d => d.ProtestsInvolved) + .UsingEntity( + right => right.HasOne(e => e.Member) + .WithMany() + .HasForeignKey(e => new { e.LeagueId, e.MemberId }), + left => left.HasOne(e => e.Protest) + .WithMany() + .HasForeignKey(e => new { e.LeagueId, e.ProtestId })); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ProtestSettingsEntity.cs b/src/iRLeagueDatabaseCore/Models/ProtestSettingsEntity.cs new file mode 100644 index 00000000..19e27639 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ProtestSettingsEntity.cs @@ -0,0 +1,5 @@ +namespace iRLeagueDatabaseCore.Models; + +public partial class ProtestSettingsEntity +{ +} diff --git a/src/iRLeagueDatabaseCore/Models/Protests_LeagueMembers.cs b/src/iRLeagueDatabaseCore/Models/Protests_LeagueMembers.cs new file mode 100644 index 00000000..daad5fc3 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/Protests_LeagueMembers.cs @@ -0,0 +1,11 @@ +namespace iRLeagueDatabaseCore.Models; + +public partial class Protests_LeagueMembers +{ + public long LeagueId { get; set; } + public long ProtestId { get; set; } + public long MemberId { get; set; } + + public virtual ProtestEntity Protest { get; set; } + public virtual LeagueMemberEntity Member { get; set; } +} diff --git a/src/iRLeagueDatabaseCore/Models/ResultConfigurationEntity.cs b/src/iRLeagueDatabaseCore/Models/ResultConfigurationEntity.cs new file mode 100644 index 00000000..da3075e1 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ResultConfigurationEntity.cs @@ -0,0 +1,66 @@ +namespace iRLeagueDatabaseCore.Models; + +public class ResultConfigurationEntity : IVersionEntity +{ + public ResultConfigurationEntity() + { + Scorings = new HashSet(); + Events = new HashSet(); + PointFilters = new HashSet(); + ResultFilters = new HashSet(); + } + + public long LeagueId { get; set; } + public long ResultConfigId { get; set; } + public long ChampSeasonId { get; set; } + public long? SourceResultConfigId { get; set; } + + public string Name { get; set; } + public string DisplayName { get; set; } + public int ResultsPerTeam { get; set; } + + public virtual LeagueEntity League { get; set; } + public virtual ResultConfigurationEntity SourceResultConfig { get; set; } + public virtual ChampSeasonEntity ChampSeason { get; set; } + public virtual ICollection Scorings { get; set; } + public virtual IEnumerable Events { get; set; } + public virtual ICollection PointFilters { get; set; } + public virtual ICollection ResultFilters { get; set; } + #region version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion + +} + +public sealed class ResultConfigurationEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ResultConfigId }); + + entity.HasAlternateKey(e => e.ResultConfigId); + + entity.Property(e => e.ResultConfigId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.HasOne(d => d.League) + .WithMany(p => p.ResultConfigs) + .HasForeignKey(d => d.LeagueId); + + entity.HasOne(d => d.SourceResultConfig) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.SourceResultConfigId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientSetNull); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ResultRowBase.cs b/src/iRLeagueDatabaseCore/Models/ResultRowBase.cs new file mode 100644 index 00000000..474151e2 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ResultRowBase.cs @@ -0,0 +1,46 @@ +namespace iRLeagueDatabaseCore.Models; + +public class ResultRowBase +{ + public double StartPosition { get; set; } + public double FinishPosition { get; set; } + public string CarNumber { get; set; } + public int ClassId { get; set; } + public string Car { get; set; } + public string CarClass { get; set; } + public double CompletedLaps { get; set; } + public double LeadLaps { get; set; } + public int FastLapNr { get; set; } + public double Incidents { get; set; } + public int Status { get; set; } + public TimeSpan QualifyingTime { get; set; } + public TimeSpan Interval { get; set; } + public TimeSpan AvgLapTime { get; set; } + public TimeSpan FastestLapTime { get; set; } + public double PositionChange { get; set; } + public string IRacingId { get; set; } + public int SimSessionType { get; set; } + public int OldIRating { get; set; } + public int NewIRating { get; set; } + public int SeasonStartIRating { get; set; } + public string License { get; set; } + public double OldSafetyRating { get; set; } + public double NewSafetyRating { get; set; } + public int OldCpi { get; set; } + public int NewCpi { get; set; } + public int ClubId { get; set; } + public string ClubName { get; set; } + public int CarId { get; set; } + public double CompletedPct { get; set; } + public DateTime? QualifyingTimeAt { get; set; } + public int Division { get; set; } + public int OldLicenseLevel { get; set; } + public int NewLicenseLevel { get; set; } + public int NumPitStops { get; set; } + public string PittedLaps { get; set; } + public int NumOfftrackLaps { get; set; } + public string OfftrackLaps { get; set; } + public int NumContactLaps { get; set; } + public string ContactLaps { get; set; } + public double RacePoints { get; set; } +} diff --git a/src/iRLeagueDatabaseCore/Models/ResultRowEntity.cs b/src/iRLeagueDatabaseCore/Models/ResultRowEntity.cs new file mode 100644 index 00000000..c073a887 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ResultRowEntity.cs @@ -0,0 +1,66 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class ResultRowEntity : ResultRowBase +{ + public ResultRowEntity() + { + } + + public long LeagueId { get; set; } + public long ResultRowId { get; set; } + public long SubSessionId { get; set; } + public long MemberId { get; set; } + public long? TeamId { get; set; } + public bool PointsEligible { get; set; } + + + public virtual MemberEntity Member { get; set; } + public virtual LeagueMemberEntity LeagueMember { get; set; } + public virtual SessionResultEntity SubResult { get; set; } + public virtual TeamEntity Team { get; set; } +} + +public class ResultRowEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ResultRowId }); + entity.HasAlternateKey(e => e.ResultRowId); + + entity.Property(e => e.ResultRowId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.CarNumber).HasMaxLength(8); + + entity.Property(e => e.QualifyingTimeAt).HasColumnType("datetime"); + + entity.Property(e => e.AvgLapTime).HasConversion(); + + entity.Property(e => e.FastestLapTime).HasConversion(); + + entity.Property(e => e.QualifyingTime).HasConversion(); + + entity.Property(e => e.Interval).HasConversion(); + + entity.HasOne(d => d.Member) + .WithMany(p => p.ResultRows) + .HasForeignKey(d => d.MemberId) + .OnDelete(DeleteBehavior.ClientSetNull); + + entity.HasOne(d => d.LeagueMember) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.MemberId }); + + entity.HasOne(d => d.SubResult) + .WithMany(p => p.ResultRows) + .HasForeignKey(d => new { d.LeagueId, d.SubSessionId }) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.Team) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.TeamId }) + .OnDelete(DeleteBehavior.ClientSetNull); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ReviewCommentEntity.cs b/src/iRLeagueDatabaseCore/Models/ReviewCommentEntity.cs new file mode 100644 index 00000000..74af34b4 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ReviewCommentEntity.cs @@ -0,0 +1,71 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class ReviewCommentEntity : IVersionEntity +{ + public ReviewCommentEntity() + { + ReviewCommentVotes = new HashSet(); + Replies = new HashSet(); + } + + public long LeagueId { get; set; } + public long CommentId { get; set; } + public long? ReviewId { get; set; } + public long? ReplyToCommentId { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public DateTime? Date { get; set; } + public string AuthorUserId { get; set; } + public string AuthorName { get; set; } + public string Text { get; set; } + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + + public virtual ReviewCommentEntity ReplyToComment { get; set; } + public virtual IncidentReviewEntity Review { get; set; } + public virtual ICollection ReviewCommentVotes { get; set; } + public virtual ICollection Replies { get; set; } +} + +public class CommentBaseEntityConfiguation : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.CommentId }); + + entity.HasAlternateKey(e => e.CommentId); + + entity.Property(e => e.CommentId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => e.ReplyToCommentId); + + entity.HasIndex(e => e.ReviewId); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.Date).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.HasOne(d => d.ReplyToComment) + .WithMany(p => p.Replies) + .HasForeignKey(d => new { d.LeagueId, d.ReplyToCommentId }); + + entity.HasOne(d => d.Review) + .WithMany(p => p.Comments) + .HasForeignKey(d => new { d.LeagueId, d.ReviewId }) + .OnDelete(DeleteBehavior.Cascade); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ReviewCommentVoteEntity.cs b/src/iRLeagueDatabaseCore/Models/ReviewCommentVoteEntity.cs new file mode 100644 index 00000000..3a97fc77 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ReviewCommentVoteEntity.cs @@ -0,0 +1,59 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class ReviewCommentVoteEntity +{ + public long LeagueId { get; set; } + public long ReviewVoteId { get; set; } + public long CommentId { get; set; } + public long? MemberAtFaultId { get; set; } + public long? TeamAtFaultId { get; set; } + public long? VoteCategoryId { get; set; } + public string Description { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public virtual ReviewCommentEntity Comment { get; set; } + public virtual VoteCategoryEntity VoteCategory { get; set; } + public virtual MemberEntity MemberAtFault { get; set; } + public virtual TeamEntity TeamAtFault { get; set;} +} + +public class CommentReviewVoteEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ReviewVoteId }); + + entity.HasAlternateKey(e => e.ReviewVoteId); + + entity.Property(e => e.ReviewVoteId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => e.CommentId); + + entity.HasIndex(e => e.VoteCategoryId); + + entity.HasIndex(e => e.MemberAtFaultId); + + entity.HasOne(d => d.Comment) + .WithMany(p => p.ReviewCommentVotes) + .HasForeignKey(d => new { d.LeagueId, d.CommentId }); + + entity.HasOne(d => d.VoteCategory) + .WithMany(p => p.CommentReviewVotes) + .HasForeignKey(d => new { d.LeagueId, d.VoteCategoryId }); + + entity.HasOne(d => d.MemberAtFault) + .WithMany(p => p.CommentReviewVotes) + .HasForeignKey(d => d.MemberAtFaultId); + + entity.HasOne(d => d.TeamAtFault) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.TeamAtFaultId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ReviewPenaltyEntity.cs b/src/iRLeagueDatabaseCore/Models/ReviewPenaltyEntity.cs new file mode 100644 index 00000000..6413833f --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ReviewPenaltyEntity.cs @@ -0,0 +1,50 @@ +using iRLeagueApiCore.Common.Converters; +using System.Text.Json; + +namespace iRLeagueDatabaseCore.Models; + +public partial class ReviewPenaltyEntity +{ + public long LeagueId { get; set; } + public long ResultRowId { get; set; } + public long ReviewId { get; set; } + public PenaltyValue Value { get; set; } + public long ReviewVoteId { get; set; } + + public virtual ScoredResultRowEntity ResultRow { get; set; } + public virtual IncidentReviewEntity Review { get; set; } + public virtual AcceptedReviewVoteEntity ReviewVote { get; set; } +} + +public class ReviewPenaltyEntityConfiguration : IEntityTypeConfiguration +{ public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ResultRowId, e.ReviewId, e.ReviewVoteId }); + + entity.HasIndex(e => new { e.LeagueId, e.ResultRowId }); + + entity.HasIndex(e => e.ReviewId); + + entity.HasIndex(e => e.ReviewVoteId); + + entity.Property(e => e.Value) + .HasColumnType("json") + .HasConversion( + v => JsonSerializer.Serialize(v, default(JsonSerializerOptions)), + v => JsonSerializer.Deserialize(v, default(JsonSerializerOptions))); + + entity.HasOne(d => d.ResultRow) + .WithMany(p => p.ReviewPenalties) + .HasForeignKey(d => new { d.LeagueId, d.ResultRowId }); + + entity.HasOne(d => d.Review) + .WithMany(p => p.ReviewPenaltys) + .HasForeignKey(d => new { d.LeagueId, d.ReviewId }) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.ReviewVote) + .WithMany(p => p.ReviewPenaltys) + .HasForeignKey(d => new { d.LeagueId, d.ReviewVoteId }) + .OnDelete(DeleteBehavior.Cascade); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/Revision.cs b/src/iRLeagueDatabaseCore/Models/Revision.cs new file mode 100644 index 00000000..f459a913 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/Revision.cs @@ -0,0 +1,14 @@ +namespace iRLeagueDatabaseCore.Models; + +public abstract class Revision +{ + public DateTime? CreatedOn { get; set; } = null; + public DateTime? LastModifiedOn { get; set; } = null; + + public int Version { get; set; } + + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } +} diff --git a/src/iRLeagueDatabaseCore/Models/ScheduleEntity.cs b/src/iRLeagueDatabaseCore/Models/ScheduleEntity.cs new file mode 100644 index 00000000..7ef20d5b --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ScheduleEntity.cs @@ -0,0 +1,56 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class ScheduleEntity : IVersionEntity +{ + public ScheduleEntity() + { + Scorings = new HashSet(); + Events = new HashSet(); + } + + public long ScheduleId { get; set; } + public long LeagueId { get; set; } + public string Name { get; set; } + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + public long SeasonId { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public virtual SeasonEntity Season { get; set; } + public virtual ICollection Scorings { get; set; } + public virtual ICollection Events { get; set; } +} + +public class ScheduleEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ScheduleId }); + + entity.HasAlternateKey(e => e.ScheduleId); + + entity.Property(e => e.ScheduleId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => new { e.LeagueId, e.SeasonId }); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.HasOne(d => d.Season) + .WithMany(p => p.Schedules) + .HasForeignKey(d => new { d.LeagueId, d.SeasonId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ScoredEventResultEntity.cs b/src/iRLeagueDatabaseCore/Models/ScoredEventResultEntity.cs new file mode 100644 index 00000000..725c095b --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ScoredEventResultEntity.cs @@ -0,0 +1,66 @@ +namespace iRLeagueDatabaseCore.Models; + +public class ScoredEventResultEntity : IVersionEntity +{ + public ScoredEventResultEntity() + { + ScoredSessionResults = new HashSet(); + } + + public long LeagueId { get; set; } + public long ResultId { get; set; } + public long EventId { get; set; } + public long? ChampSeasonId { get; set; } + public long? ResultConfigId { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public string Name { get; set; } + + public virtual EventEntity Event { get; set; } + public virtual ChampSeasonEntity ChampSeason { get; set; } + public virtual ICollection ScoredSessionResults { get; set; } + public virtual ResultConfigurationEntity ResultConfig { get; set; } + + #region version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion + +} + +public class ScoredEventResultEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ResultId }); + + entity.HasAlternateKey(e => new { e.ResultId }); + + entity.Property(e => e.ResultId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.HasOne(d => d.Event) + .WithMany(p => p.ScoredEventResults) + .HasForeignKey(d => new { d.LeagueId, d.EventId }) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.ResultConfig) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.ResultConfigId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientSetNull); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ScoredResultRowEntity.cs b/src/iRLeagueDatabaseCore/Models/ScoredResultRowEntity.cs new file mode 100644 index 00000000..c0536c7c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ScoredResultRowEntity.cs @@ -0,0 +1,144 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class ScoredResultRowEntity : ResultRowBase +{ + public ScoredResultRowEntity() + { + ReviewPenalties = new HashSet(); + TeamParentRows = new HashSet(); + TeamResultRows = new HashSet(); + StandingRows = new HashSet(); + } + + public ScoredResultRowEntity(ResultRowEntity resultRow) + : this() + { + Member = resultRow.Member; + Team = resultRow.Team; + StartPosition = resultRow.StartPosition; + FinishPosition = resultRow.FinishPosition; + CarNumber = resultRow.CarNumber; + ClassId = resultRow.ClassId; + Car = resultRow.Car; + CarClass = resultRow.CarClass; + CompletedLaps = resultRow.CompletedLaps; + LeadLaps = resultRow.LeadLaps; + FastLapNr = resultRow.FastLapNr; + Incidents = resultRow.Incidents; + Status = resultRow.Status; + QualifyingTime = resultRow.QualifyingTime; + Interval = resultRow.Interval; + AvgLapTime = resultRow.AvgLapTime; + FastestLapTime = resultRow.FastestLapTime; + PositionChange = resultRow.PositionChange; + IRacingId = resultRow.IRacingId; + SimSessionType = resultRow.SimSessionType; + OldIRating = resultRow.OldIRating; + NewIRating = resultRow.NewIRating; + SeasonStartIRating = resultRow.SeasonStartIRating; + License = resultRow.License; + OldSafetyRating = resultRow.OldSafetyRating; + NewSafetyRating = resultRow.NewSafetyRating; + OldCpi = resultRow.OldCpi; + NewCpi = resultRow.NewCpi; + ClubId = resultRow.ClubId; + ClubName = resultRow.ClubName; + CarId = resultRow.CarId; + CompletedPct = resultRow.CompletedPct; + QualifyingTimeAt = resultRow.QualifyingTimeAt; + Division = resultRow.Division; + OldLicenseLevel = resultRow.OldLicenseLevel; + NewLicenseLevel = resultRow.NewLicenseLevel; + NumPitStops = resultRow.NumPitStops; + PittedLaps = resultRow.PittedLaps; + NumOfftrackLaps = resultRow.NumOfftrackLaps; + OfftrackLaps = resultRow.OfftrackLaps; + NumContactLaps = resultRow.NumContactLaps; + ContactLaps = resultRow.ContactLaps; + } + + public long LeagueId { get; set; } + public long ScoredResultRowId { get; set; } + public long SessionResultId { get; set; } + public long? MemberId { get; set; } + public long? TeamId { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public double BonusPoints { get; set; } + public double PenaltyPoints { get; set; } + public int FinalPosition { get; set; } + public double FinalPositionChange { get; set; } + public double TotalPoints { get; set; } + public bool PointsEligible { get; set; } + + public virtual MemberEntity Member { get; set; } + public virtual TeamEntity Team { get; set; } + public virtual ScoredSessionResultEntity ScoredSessionResult { get; set; } + public virtual ICollection AddPenalties { get; set; } + public virtual IEnumerable TeamParentRows { get; set; } + public virtual ICollection ReviewPenalties { get; set; } + public virtual ICollection TeamResultRows { get; set; } + public virtual IEnumerable StandingRows { get; set; } +} + +public class ScoredResultRowEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ScoredResultRowId }); + + entity.HasAlternateKey(e => e.ScoredResultRowId); + + entity.Property(e => e.ScoredResultRowId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => e.MemberId); + + entity.HasIndex(e => e.TeamId); + + entity.Property(e => e.CarNumber).HasMaxLength(8); + + entity.Property(e => e.QualifyingTimeAt).HasColumnType("datetime"); + + entity.Property(e => e.AvgLapTime).HasConversion(); + + entity.Property(e => e.FastestLapTime).HasConversion(); + + entity.Property(e => e.QualifyingTime).HasConversion(); + + entity.Property(e => e.Interval).HasConversion(); + + entity.HasOne(d => d.Team) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.TeamId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientSetNull); + + entity.HasOne(d => d.ScoredSessionResult) + .WithMany(p => p.ScoredResultRows) + .HasForeignKey(d => new { d.LeagueId, d.SessionResultId }); + + entity.HasOne(d => d.Member) + .WithMany() + .HasForeignKey(d => d.MemberId) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientSetNull); + + entity.HasMany(d => d.TeamResultRows) + .WithMany(p => p.TeamParentRows) + .UsingEntity( + left => left.HasOne(e => e.TeamResultRow) + .WithMany() + .HasForeignKey(e => new { e.LeagueId, e.TeamResultRowRefId }), + right => right.HasOne(e => e.TeamParentRow) + .WithMany() + .HasForeignKey(e => new { e.LeagueId, e.TeamParentRowRefId })); + + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ScoredSessionResultEntity.cs b/src/iRLeagueDatabaseCore/Models/ScoredSessionResultEntity.cs new file mode 100644 index 00000000..207a2141 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ScoredSessionResultEntity.cs @@ -0,0 +1,111 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class ScoredSessionResultEntity : IVersionEntity +{ + public ScoredSessionResultEntity() + { + CleanestDrivers = new HashSet(); + HardChargers = new HashSet(); + ScoredResultRows = new HashSet(); + } + + public long LeagueId { get; set; } + public long ResultId { get; set; } + public long SessionResultId { get; set; } + public long? ScoringId { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + /// + /// Number that decides order of subsessions + /// + public int SessionNr { get; set; } + public string Name { get; set; } + public TimeSpan FastestLap { get; set; } + public TimeSpan FastestQualyLap { get; set; } + public TimeSpan FastestAvgLap { get; set; } + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + public string Discriminator { get; set; } + public long? FastestAvgLapDriverMemberId { get; set; } + public long? FastestLapDriverMemberId { get; set; } + public long? FastestQualyLapDriverMemberId { get; set; } + + public virtual MemberEntity FastestAvgLapDriver { get; set; } + public virtual MemberEntity FastestLapDriver { get; set; } + public virtual MemberEntity FastestQualyLapDriver { get; set; } + public virtual ScoredEventResultEntity ScoredEventResult { get; set; } + public virtual ScoringEntity Scoring { get; set; } + public virtual ICollection CleanestDrivers { get; set; } + public virtual ICollection HardChargers { get; set; } + public virtual ICollection ScoredResultRows { get; set; } +} + +public class ScoredSessionResultEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.SessionResultId }); + + entity.HasAlternateKey(e => e.SessionResultId); + + entity.Property(e => e.SessionResultId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => e.FastestAvgLapDriverMemberId); + + entity.HasIndex(e => e.FastestLapDriverMemberId); + + entity.HasIndex(e => e.FastestQualyLapDriverMemberId); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.Property(e => e.FastestAvgLap).HasConversion(); + + entity.Property(e => e.FastestLap).HasConversion(); + + entity.Property(e => e.FastestQualyLap).HasConversion(); + + entity.HasOne(d => d.FastestAvgLapDriver) + .WithMany(p => p.FastestAvgLapResults) + .HasForeignKey(d => d.FastestAvgLapDriverMemberId); + + entity.HasOne(d => d.FastestLapDriver) + .WithMany(p => p.FastestLapResults) + .HasForeignKey(d => d.FastestLapDriverMemberId); + + entity.HasOne(d => d.FastestQualyLapDriver) + .WithMany(p => p.FastestQualyLapResults) + .HasForeignKey(d => d.FastestQualyLapDriverMemberId); + + entity.HasOne(d => d.ScoredEventResult) + .WithMany(p => p.ScoredSessionResults) + .HasForeignKey(d => new { d.LeagueId, d.ResultId }) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(d => d.CleanestDrivers) + .WithMany(p => p.CleanestDriverResults) + .UsingEntity(e => e.ToTable("ScoredResultsCleanestDrivers")); + + entity.HasMany(d => d.HardChargers) + .WithMany(p => p.HardChargerResults) + .UsingEntity(e => e.ToTable("ScoredResultsHardChargers")); + + entity.HasOne(d => d.Scoring) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.ScoringId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientSetNull); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/ScoredTeamResultRowsResultRows.cs b/src/iRLeagueDatabaseCore/Models/ScoredTeamResultRowsResultRows.cs new file mode 100644 index 00000000..cd45182f --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ScoredTeamResultRowsResultRows.cs @@ -0,0 +1,11 @@ +namespace iRLeagueDatabaseCore.Models; + +public class ScoredTeamResultRowsResultRows +{ + public long LeagueId { get; set; } + public long TeamResultRowRefId { get; set; } + public long TeamParentRowRefId { get; set; } + + public virtual ScoredResultRowEntity TeamResultRow { get; set; } + public virtual ScoredResultRowEntity TeamParentRow { get; set; } +} diff --git a/src/iRLeagueDatabaseCore/Models/ScoringEntity.cs b/src/iRLeagueDatabaseCore/Models/ScoringEntity.cs new file mode 100644 index 00000000..9f938d53 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/ScoringEntity.cs @@ -0,0 +1,71 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class ScoringEntity : IVersionEntity +{ + public ScoringEntity() + { + DependendScorings = new HashSet(); + } + + public long LeagueId { get; set; } + public long ScoringId { get; set; } + public long ResultConfigId { get; set; } + public long? PointsRuleId { get; set; } + + public int Index { get; set; } + public string Name { get; set; } + public int MaxResultsPerGroup { get; set; } + public long? ExtScoringSourceId { get; set; } + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + public bool UseResultSetTeam { get; set; } + public bool UpdateTeamOnRecalculation { get; set; } + public bool ShowResults { get; set; } = true; + public bool IsCombinedResult { get; set; } = false; + public bool UseExternalSourcePoints { get; set; } = false; + + public virtual ScoringEntity ExtScoringSource { get; set; } + public virtual ResultConfigurationEntity ResultConfiguration { get; set; } + public virtual PointRuleEntity PointsRule { get; set; } + public virtual ICollection DependendScorings { get; set; } +} + +public class ScoringEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.ScoringId }); + + entity.HasAlternateKey(e => e.ScoringId); + + entity.Property(e => e.ScoringId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => e.ExtScoringSourceId); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.Property(e => e.ShowResults); + + entity.HasOne(d => d.ExtScoringSource) + .WithMany(p => p.DependendScorings) + .HasForeignKey(d => new { d.LeagueId, d.ExtScoringSourceId }); + + entity.HasOne(d => d.ResultConfiguration) + .WithMany(p => p.Scorings) + .HasForeignKey(d => new { d.LeagueId, d.ResultConfigId }); + + entity.HasOne(d => d.PointsRule) + .WithMany(p => p.Scorings) + .HasForeignKey(d => new { d.LeagueId, d.PointsRuleId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/SeasonEntity.cs b/src/iRLeagueDatabaseCore/Models/SeasonEntity.cs new file mode 100644 index 00000000..ce3c0d68 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/SeasonEntity.cs @@ -0,0 +1,59 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class SeasonEntity : Revision, IVersionEntity +{ + public SeasonEntity() + { + Schedules = new HashSet(); + Standings = new HashSet(); + StatisticSets = new HashSet(); + ChampSeasons = new HashSet(); + } + + public long SeasonId { get; set; } + public long LeagueId { get; set; } + public string SeasonName { get; set; } + public bool HideCommentsBeforeVoted { get; set; } + public bool Finished { get; set; } + public DateTime? SeasonStart { get; set; } + public DateTime? SeasonEnd { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public virtual LeagueEntity League { get; set; } + public virtual ScoringEntity MainScoring { get; set; } + public virtual ICollection Schedules { get; set; } + public virtual ICollection Standings { get; set; } + public virtual ICollection StatisticSets { get; set; } + public virtual ICollection ChampSeasons { get; set; } +} + +public class SeasonEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.SeasonId }); + + entity.HasAlternateKey(e => e.SeasonId); + + entity.Property(e => e.SeasonId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.Property(e => e.SeasonEnd).HasColumnType("datetime"); + + entity.Property(e => e.SeasonStart).HasColumnType("datetime"); + + entity.HasOne(e => e.League) + .WithMany(p => p.Seasons) + .HasForeignKey(e => e.LeagueId); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/SessionEntity.cs b/src/iRLeagueDatabaseCore/Models/SessionEntity.cs new file mode 100644 index 00000000..003fe9ef --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/SessionEntity.cs @@ -0,0 +1,71 @@ +namespace iRLeagueDatabaseCore.Models; + +public partial class SessionEntity : IVersionEntity +{ + public SessionEntity() + { + IncidentReviews = new HashSet(); + } + public long LeagueId { get; set; } + public long SessionId { get; set; } + public long EventId { get; set; } + /// + /// Number that decides order of subsessions + /// + public int SessionNr { get; set; } + public string Name { get; set; } + public SessionType SessionType { get; set; } + public TimeSpan StartOffset { get; set; } + public TimeSpan Duration { get; set; } + public int Laps { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + #region version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion + + public virtual EventEntity Event { get; set; } + public virtual SessionResultEntity SessionResult { get; set; } + public virtual ICollection IncidentReviews { get; set; } +} + +public class SubSessionEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.SessionId }); + + entity.HasAlternateKey(e => e.SessionId); + + entity.Property(e => e.SessionId) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => new { e.EventId, e.SessionId }); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.Property(e => e.StartOffset).HasConversion(); + + entity.Property(e => e.Duration).HasConversion(); + + entity.Property(e => e.SessionType) + .HasConversion(); + + entity.HasOne(d => d.Event) + .WithMany(p => p.Sessions) + .HasForeignKey(d => new { d.LeagueId, d.EventId }) + .OnDelete(DeleteBehavior.Cascade); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/SessionResultEntity.cs b/src/iRLeagueDatabaseCore/Models/SessionResultEntity.cs new file mode 100644 index 00000000..ba0acb4c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/SessionResultEntity.cs @@ -0,0 +1,55 @@ +namespace iRLeagueDatabaseCore.Models; + +public partial class SessionResultEntity : IVersionEntity +{ + public SessionResultEntity() + { + ResultRows = new HashSet(); + } + + public long LeagueId { get; set; } + public long EventId { get; set; } + public long SessionId { get; set; } + public long? IRSimSessionDetailsId { get; set; } + + public SimSessionType SimSessionType { get; set; } + + #region version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion + + public virtual EventResultEntity Result { get; set; } + public virtual SessionEntity Session { get; set; } + public virtual ICollection ResultRows { get; set; } + public virtual IRSimSessionDetailsEntity IRSimSessionDetails { get; set; } +} + +public class SessionResultEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.SessionId }); + + entity.HasIndex(e => e.SessionId); + + entity.HasOne(d => d.Result) + .WithMany(p => p.SessionResults) + .HasForeignKey(d => new { d.LeagueId, d.EventId }); + + entity.HasOne(d => d.Session) + .WithOne(p => p.SessionResult) + .HasForeignKey(d => new { d.LeagueId, d.SessionId }) + .IsRequired(true) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.IRSimSessionDetails) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.IRSimSessionDetailsId }); + } +} \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/Models/StandingConfigurationEntity.cs b/src/iRLeagueDatabaseCore/Models/StandingConfigurationEntity.cs new file mode 100644 index 00000000..2ad1627f --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/StandingConfigurationEntity.cs @@ -0,0 +1,53 @@ +namespace iRLeagueDatabaseCore.Models; + +public partial class StandingConfigurationEntity : IVersionEntity +{ + public StandingConfigurationEntity() + { + ChampSeasons = new HashSet(); + Standings = new HashSet(); + } + + public long LeagueId { get; set; } + public long StandingConfigId { get; set; } + + public string Name { get; set; } + public ResultKind ResultKind { get; set; } + public bool UseCombinedResult { get; set; } + public int WeeksCounted { get; set; } + public ICollection SortOptions { get; set; } + + public virtual LeagueEntity League { get; set; } + public virtual IEnumerable ChampSeasons { get; set; } + public virtual IEnumerable Standings { get; set; } + + #region version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion +} + +public sealed class StandingConfigurationEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.StandingConfigId }); + + entity.HasAlternateKey(e => e.StandingConfigId); + + entity.Property(e => e.StandingConfigId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.SortOptions) + .HasConversion(new CollectionToStringConverter(), new ValueComparer>(true)); + + entity.HasOne(d => d.League) + .WithMany(p => p.StandingConfigs) + .HasForeignKey(d => d.LeagueId); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/StandingEntity.cs b/src/iRLeagueDatabaseCore/Models/StandingEntity.cs new file mode 100644 index 00000000..1e71183c --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/StandingEntity.cs @@ -0,0 +1,63 @@ +namespace iRLeagueDatabaseCore.Models; + +public partial class StandingEntity : IVersionEntity +{ + public StandingEntity() + { + StandingRows = new HashSet(); + } + + public long LeagueId { get; set; } + public long StandingId { get; set; } + public long SeasonId { get; set; } + public long? ChampSeasonId { get; set; } + public long? StandingConfigId { get; set; } + public long EventId { get; set; } + + public string Name { get; set; } + public bool IsTeamStanding { get; set; } + public long? ImportId { get; set; } + + public virtual SeasonEntity Season { get; set; } + public virtual EventEntity Event { get; set; } + public virtual ChampSeasonEntity ChampSeason { get; set; } + public virtual StandingConfigurationEntity StandingConfig { get; set; } + public virtual ICollection StandingRows { get; set; } + + #region version + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + #endregion +} + +public class SeasonStandingEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.StandingId }); + + entity.HasAlternateKey(e => e.StandingId); + + entity.Property(e => e.StandingId) + .ValueGeneratedOnAdd(); + + entity.HasOne(d => d.Season) + .WithMany(p => p.Standings) + .HasForeignKey(d => new { d.LeagueId, d.SeasonId }); + + entity.HasOne(d => d.Event) + .WithMany() + .HasForeignKey(d => new { d.LeagueId, d.EventId }); + + entity.HasOne(d => d.StandingConfig) + .WithMany(p => p.Standings) + .HasForeignKey(d => new { d.LeagueId, d.StandingConfigId }) + .IsRequired(false) + .OnDelete(DeleteBehavior.ClientCascade); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/StandingRowEntity.cs b/src/iRLeagueDatabaseCore/Models/StandingRowEntity.cs new file mode 100644 index 00000000..7ccc0267 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/StandingRowEntity.cs @@ -0,0 +1,89 @@ +namespace iRLeagueDatabaseCore.Models; + +public class StandingRowEntity +{ + public StandingRowEntity() + { + ResultRows = new HashSet(); + } + + public long LeagueId { get; set; } + public long StandingRowId { get; set; } + public long StandingId { get; set; } + public long? MemberId { get; set; } + public long? TeamId { get; set; } + + public int Position { get; set; } + public int LastPosition { get; set; } + public int ClassId { get; set; } + public string CarClass { get; set; } + public int RacePoints { get; set; } + public int RacePointsChange { get; set; } + public int PenaltyPoints { get; set; } + public int PenaltyPointsChange { get; set; } + public int TotalPoints { get; set; } + public int TotalPointsChange { get; set; } + public int Races { get; set; } + public int RacesCounted { get; set; } + public int RacesScored { get; set; } + public int RacesInPoints { get; set; } + public int DroppedResultCount { get; set; } + public int CompletedLaps { get; set; } + public int CompletedLapsChange { get; set; } + public int LeadLaps { get; set; } + public int LeadLapsChange { get; set; } + public int FastestLaps { get; set; } + public int FastestLapsChange { get; set; } + public int PolePositions { get; set; } + public int PolePositionsChange { get; set; } + public int Wins { get; set; } + public int WinsChange { get; set; } + public int Top3 { get; set; } + public int Top5 { get; set; } + public int Top10 { get; set; } + public int Incidents { get; set; } + public int IncidentsChange { get; set; } + public int PositionChange { get; set; } + public int StartIrating { get; set; } + public int LastIrating { get; set; } + + public virtual StandingEntity SeasonStanding { get; set; } + public virtual MemberEntity Member { get; set; } + public virtual TeamEntity Team { get; set; } + public virtual ICollection ResultRows { get; set; } +} + +public class StandingRowEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.StandingRowId }); + + entity.ToTable("StandingRows"); + + entity.HasAlternateKey(e => e.StandingRowId); + + entity.Property(e => e.StandingRowId) + .ValueGeneratedOnAdd(); + + entity.HasOne(p => p.SeasonStanding) + .WithMany(d => d.StandingRows) + .HasForeignKey(p => new { p.LeagueId, p.StandingId }); + + entity.HasOne(p => p.Member) + .WithMany() + .HasForeignKey(p => p.MemberId) + .OnDelete(DeleteBehavior.ClientSetNull) + .IsRequired(false); + + entity.HasOne(p => p.Team) + .WithMany() + .HasForeignKey(p => new { p.LeagueId, p.TeamId }) + .OnDelete(DeleteBehavior.ClientSetNull) + .IsRequired(false); + + entity.HasMany(p => p.ResultRows) + .WithOne(d => d.StandingRow) + .HasForeignKey(d => new { d.LeagueId, d.StandingRowRefId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/StandingRows_ScoredResultRows.cs b/src/iRLeagueDatabaseCore/Models/StandingRows_ScoredResultRows.cs new file mode 100644 index 00000000..0bc91c25 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/StandingRows_ScoredResultRows.cs @@ -0,0 +1,24 @@ +namespace iRLeagueDatabaseCore.Models; + +public class StandingRows_ScoredResultRows +{ + public long LeagueId { get; set; } + public long StandingRowRefId { get; set; } + public long ScoredResultRowRefId { get; set; } + public bool IsScored { get; set; } + + public virtual StandingRowEntity StandingRow { get; set; } + public virtual ScoredResultRowEntity ScoredResultRow { get; set; } +} + +public sealed class StandingRows_ScoredResultRowsConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.ScoredResultRowRefId, e.LeagueId, e.StandingRowRefId }); + + entity.HasOne(p => p.ScoredResultRow) + .WithMany(d => d.StandingRows) + .HasForeignKey(p => new { p.LeagueId, p.ScoredResultRowRefId }); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/StatisticSetEntity.cs b/src/iRLeagueDatabaseCore/Models/StatisticSetEntity.cs new file mode 100644 index 00000000..03c4cb77 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/StatisticSetEntity.cs @@ -0,0 +1,84 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class StatisticSetEntity : IVersionEntity +{ + public StatisticSetEntity() + { + DriverStatisticRows = new HashSet(); + LeagueStatisticSets = new HashSet(); + DependendStatisticSets = new HashSet(); + } + + public long LeagueId { get; set; } + public long Id { get; set; } + public string Name { get; set; } + public long UpdateInterval { get; set; } + public DateTime? UpdateTime { get; set; } + public bool RequiresRecalculation { get; set; } + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + public long? CurrentChampId { get; set; } + public long? SeasonId { get; set; } + public long? StandingId { get; set; } + public int? FinishedRaces { get; set; } + public bool? IsSeasonFinished { get; set; } + public string ImportSource { get; set; } + public string Description { get; set; } + public DateTime? FirstDate { get; set; } + public DateTime? LastDate { get; set; } + + public virtual MemberEntity CurrentChamp { get; set; } + public virtual SeasonEntity Season { get; set; } + public virtual ICollection DriverStatisticRows { get; set; } + public virtual ICollection LeagueStatisticSets { get; set; } + public virtual ICollection DependendStatisticSets { get; set; } +} + +public class StatisticSetEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.Id }); + + entity.HasAlternateKey(e => e.Id); + + entity.Property(e => e.Id) + .ValueGeneratedOnAdd(); + + entity.HasIndex(e => e.CurrentChampId); + + entity.HasIndex(e => new { e.LeagueId, e.StandingId }); + + entity.HasIndex(e => new { e.LeagueId, e.SeasonId }); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.FirstDate).HasColumnType("datetime"); + + entity.Property(e => e.LastDate).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + + entity.Property(e => e.UpdateTime).HasColumnType("datetime"); + + entity.HasOne(d => d.CurrentChamp) + .WithMany(p => p.StatisticSets) + .HasForeignKey(d => d.CurrentChampId); + + entity.HasOne(d => d.Season) + .WithMany(p => p.StatisticSets) + .HasForeignKey(d => new { d.LeagueId, d.SeasonId }) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasMany(d => d.DependendStatisticSets) + .WithMany(p => p.LeagueStatisticSets) + .UsingEntity(e => e.ToTable("LeagueStatisticSetsStatisticSets")); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/SubscriptionEntity.cs b/src/iRLeagueDatabaseCore/Models/SubscriptionEntity.cs new file mode 100644 index 00000000..aa265257 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/SubscriptionEntity.cs @@ -0,0 +1,35 @@ +using System.Diagnostics.CodeAnalysis; + +namespace iRLeagueDatabaseCore.Models; + +#nullable enable +public class SubscriptionEntity +{ + public string PlanId { get; set; } = default!; + public string Name { get; set; } = default!; + public SubscriptionInterval Interval { get; set; } + public double Price { get; set; } + + [MaybeNull] + public virtual IEnumerable Payments { get; set; } +} + +public enum SubscriptionInterval +{ + Monthly, + Yearly, +} + +public class SubscriptionEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.ToTable("Subscriptions"); + + entity.HasKey(e => e.PlanId); + + entity.Property(e => e.Name) + .HasMaxLength(255) + .IsRequired(); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/TeamEntity.cs b/src/iRLeagueDatabaseCore/Models/TeamEntity.cs new file mode 100644 index 00000000..4d3762d5 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/TeamEntity.cs @@ -0,0 +1,52 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class TeamEntity : IVersionEntity +{ + public TeamEntity() + { + Members = new HashSet(); + } + + public long LeagueId { get; set; } + public long TeamId { get; set; } + public long? IRacingTeamId { get; set; } + public string Name { get; set; } + public string Profile { get; set; } + public string TeamColor { get; set; } + public string TeamHomepage { get; set; } + public DateTime? CreatedOn { get; set; } + public DateTime? LastModifiedOn { get; set; } + public int Version { get; set; } + public string CreatedByUserId { get; set; } + public string CreatedByUserName { get; set; } + public string LastModifiedByUserId { get; set; } + public string LastModifiedByUserName { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public virtual ICollection Members { get; set; } + public virtual LeagueEntity League { get; set; } + public virtual IEnumerable InvolvedReviews { get; set; } +} + +public class TeamEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.TeamId }); + + entity.HasAlternateKey(e => e.TeamId); + + entity.Property(e => e.TeamId) + .ValueGeneratedOnAdd(); + + entity.Property(e => e.CreatedOn).HasColumnType("datetime"); + + entity.Property(e => e.LastModifiedOn).HasColumnType("datetime"); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/TrackConfigEntity.cs b/src/iRLeagueDatabaseCore/Models/TrackConfigEntity.cs new file mode 100644 index 00000000..27b4d875 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/TrackConfigEntity.cs @@ -0,0 +1,25 @@ +namespace iRLeagueDatabaseCore.Models; + +public class TrackConfigEntity +{ + public long TrackId { get; set; } + public long TrackGroupId { get; set; } + public virtual TrackGroupEntity TrackGroup { get; set; } + public string ConfigName { get; set; } + public double LengthKm { get; set; } + public int Turns { get; set; } + public ConfigType ConfigType { get; set; } + public bool HasNightLighting { get; set; } + public string LegacyTrackId { get; set; } +} + +public class TrackConfigEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => e.TrackId); + + entity.Property(e => e.ConfigType) + .HasConversion(); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/TrackGroupEntity.cs b/src/iRLeagueDatabaseCore/Models/TrackGroupEntity.cs new file mode 100644 index 00000000..6808a654 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/TrackGroupEntity.cs @@ -0,0 +1,31 @@ +namespace iRLeagueDatabaseCore.Models; + +public class TrackGroupEntity +{ + public TrackGroupEntity() + { + TrackConfigs = new HashSet(); + } + + public long TrackGroupId { get; set; } + public string TrackName { get; set; } + public string Location { get; set; } + + public virtual ICollection TrackConfigs { get; set; } +} + +public class TrackGroupEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => e.TrackGroupId); + + entity.Property(e => e.TrackGroupId) + .ValueGeneratedOnAdd(); + + entity.HasMany(d => d.TrackConfigs) + .WithOne(p => p.TrackGroup) + .HasForeignKey(d => d.TrackGroupId) + .OnDelete(DeleteBehavior.Cascade); + } +} diff --git a/src/iRLeagueDatabaseCore/Models/VoteCategoryEntity.cs b/src/iRLeagueDatabaseCore/Models/VoteCategoryEntity.cs new file mode 100644 index 00000000..64af63a0 --- /dev/null +++ b/src/iRLeagueDatabaseCore/Models/VoteCategoryEntity.cs @@ -0,0 +1,44 @@ +#nullable disable + +namespace iRLeagueDatabaseCore.Models; + +public partial class VoteCategoryEntity +{ + public VoteCategoryEntity() + { + AcceptedReviewVotes = new HashSet(); + CommentReviewVotes = new HashSet(); + } + + public long LeagueId { get; set; } + public long CatId { get; set; } + public string Text { get; set; } + public int Index { get; set; } + public int DefaultPenalty { get; set; } + /// + /// Imported Id from old database + /// Will be deleted after imports have finished + /// + public long? ImportId { get; set; } + + public virtual LeagueEntity League { get; set; } + public virtual ICollection AcceptedReviewVotes { get; set; } + public virtual ICollection CommentReviewVotes { get; set; } +} + +public class VoteCategoryEntityConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.HasKey(e => new { e.LeagueId, e.CatId }); + + entity.HasAlternateKey(e => e.CatId); + + entity.Property(e => e.CatId) + .ValueGeneratedOnAdd(); + + entity.HasOne(e => e.League) + .WithMany(p => p.VoteCategories) + .HasForeignKey(e => e.LeagueId); + } +} diff --git a/src/iRLeagueDatabaseCore/MysqlEntityFrameworkDesignTimeServices.cs b/src/iRLeagueDatabaseCore/MysqlEntityFrameworkDesignTimeServices.cs new file mode 100644 index 00000000..16db28dc --- /dev/null +++ b/src/iRLeagueDatabaseCore/MysqlEntityFrameworkDesignTimeServices.cs @@ -0,0 +1,15 @@ +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.DependencyInjection; +using MySql.EntityFrameworkCore.Extensions; + +namespace iRLeagueDatabaseCore; + +internal class MysqlEntityFrameworkDesignTimeServices : IDesignTimeServices +{ + public void ConfigureDesignTimeServices(IServiceCollection serviceCollection) + { + serviceCollection.AddEntityFrameworkMySQL(); + new EntityFrameworkRelationalDesignServicesBuilder(serviceCollection) + .TryAddCoreServices(); + } +} diff --git a/src/iRLeagueDatabaseCore/PopulateTestDatabase.cs b/src/iRLeagueDatabaseCore/PopulateTestDatabase.cs new file mode 100644 index 00000000..7ebeff68 --- /dev/null +++ b/src/iRLeagueDatabaseCore/PopulateTestDatabase.cs @@ -0,0 +1,457 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore.Models; + +namespace DbIntegrationTests; + +public static class PopulateTestDatabase +{ + public static string ClientUserName => "TestClient"; + public static string ClientGuid => "6a6a6e09-f4b7-4ccb-a8ae-f2fc85d897dd"; + + public static void Populate(LeagueDbContext context, Random random) + { + // Populate Tracks + for (int i = 0; i < 2; i++) + { + var group = new TrackGroupEntity() + { + TrackName = $"Group{i}", + Location = "Testlocation" + }; + for (int j = 0; j < 3; j++) + { + var config = new TrackConfigEntity() + { + ConfigName = $"Config{i}", + ConfigType = ConfigType.Road, + Turns = j * 3, + LengthKm = j * 1.0, + HasNightLighting = false + }; + group.TrackConfigs.Add(config); + } + context.TrackGroups.Add(group); + } + + // create models + var league1 = new LeagueEntity() + { + Name = "TestLeague", + NameFull = "League for unit testing" + }; + var season1 = new SeasonEntity() + { + SeasonName = "Season One", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + League = league1 + }; + var season2 = new SeasonEntity() + { + SeasonName = "Season Two", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + League = league1 + }; + var schedule1 = new ScheduleEntity() + { + Name = "S1 Schedule", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + var schedule2 = new ScheduleEntity() + { + Name = "S2 Schedule 1", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + var schedule3 = new ScheduleEntity() + { + Name = "S2 Schedule 2", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + // Create events on schedule1 + for (int i = 0; i < 5; i++) + { + var @event = new EventEntity() + { + Name = $"S1 Event {i + 1}", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + Track = context.TrackGroups + .SelectMany(x => x.TrackConfigs) + .Skip(i) + .FirstOrDefault(), + EventType = EventType.SingleRace + }; + var subSession = new SessionEntity() + { + Name = "Race", + SessionType = SessionType.Race, + }; + @event.Sessions.Add(subSession); + schedule1.Events.Add(@event); + } + for (int i = 0; i < 2; i++) + { + var @event = new EventEntity() + { + Name = $"S2 Event {i + 1}", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + Track = context.TrackGroups + .SelectMany(x => x.TrackConfigs) + .Skip(i) + .FirstOrDefault(), + EventType = EventType.SingleRace + }; + var session = new SessionEntity() + { + Name = "Race", + SessionType = SessionType.Race, + }; + @event.Sessions.Add(session); + schedule2.Events.Add(@event); + } + context.Leagues.Add(league1); + league1.Seasons.Add(season1); + league1.Seasons.Add(season2); + season1.Schedules.Add(schedule1); + season2.Schedules.Add(schedule2); + season2.Schedules.Add(schedule3); + + // create league2 + var league2 = new LeagueEntity() + { + Name = "TestLeague2", + NameFull = "Second League for unit testing" + }; + var l2season1 = new SeasonEntity() + { + SeasonName = "L2 Season One", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + League = league1 + }; + var l2schedule1 = new ScheduleEntity() + { + Name = "L2S1 Schedule 1", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + + context.Leagues.Add(league2); + league2.Seasons.Add(l2season1); + l2season1.Schedules.Add(l2schedule1); + + GenerateMembers(context, random); + + var members = context.Members + .Local + .ToList(); + var leagues = context.Leagues + .Local + .ToList(); + // assign members to league + foreach (var member in members) + { + foreach (var league in leagues) + { + var leagueMember = new LeagueMemberEntity() + { + Member = member, + }; + league.LeagueMembers.Add(leagueMember); + } + } + + var pointsRule = new PointRuleEntity() + { + Name = "Points Rule", + PointsPerPlace = new List() { 5, 4, 3, 2, 1 }, + BonusPoints = new List() + { + new() { Type = BonusPointType.Position, Value = 1, Points = 3 }, + new() { Type = BonusPointType.Position, Value = 2, Points = 2 }, + new() { Type = BonusPointType.Position, Value = 3, Points = 1 }, + }, + PointsSortOptions = new List() { + SortOptions.PosAsc, + SortOptions.FinPosAsc, + }, + FinalSortOptions = new List() + { + SortOptions.PosDesc, + SortOptions.FinPosDesc, + }, + }; + league1.PointRules.Add(pointsRule); + + var championship = new ChampionshipEntity() + { + League = league1, + Name = "Championship" + }; + league1.Championships.Add(championship); + foreach(var season in league1.Seasons) + { + var champSeason = new ChampSeasonEntity() + { + Championship = championship, + Season = season, + }; + championship.ChampSeasons.Add(champSeason); + var resultFilter = new FilterOptionEntity() + { + Conditions = new[] { new FilterConditionModel() + { + Action = MatchedValueAction.Remove, + ColumnPropertyName = "Shame", + Comparator = ComparatorType.ForEach, + FilterType = FilterType.Member, + FilterValues = new[] { "Eins", "Zwei", "Drei" }, + }}, + }; + var resultConfig = new ResultConfigurationEntity() + { + League = league1, + ChampSeason = champSeason, + ResultFilters = new[] { resultFilter }, + }; + league1.ResultConfigs.Add(resultConfig); + for (int i = 0; i < 2; i++) + { + var scoring = new ScoringEntity() + { + Name = $"Scoring {i + 1}", + PointsRule = pointsRule, + }; + resultConfig.Scorings.Add(scoring); + } + } + + foreach ((var season, var index) in league1.Seasons.Select((x, i) => (x, i))) + { + foreach (var @event in season.Schedules.SelectMany(x => x.Events)) + { + var result = new EventResultEntity(); + @event.EventResult = result; + var scoredResult = new ScoredEventResultEntity(); + @event.ScoredEventResults.Add(scoredResult); + foreach (var session in @event.Sessions) + { + var sessionResult = new SessionResultEntity(); + session.SessionResult = sessionResult; + result.SessionResults.Add(sessionResult); + var scoredSessionResult = new ScoredSessionResultEntity(); + scoredResult.ScoredSessionResults.Add(scoredSessionResult); + var resultMembers = members.ToList(); + for (int i = 0; i < 10; i++) + { + var member = resultMembers.PopRandom(); + var resultRow = new ResultRowEntity() + { + Member = member, + StartPosition = i + 1, + FinishPosition = i + 1, + QualifyingTime = GetTimeSpan(random), + FastestLapTime = GetTimeSpan(random), + AvgLapTime = GetTimeSpan(random), + Interval = GetTimeSpan(random) + }; + sessionResult.ResultRows.Add(resultRow); + var scoredResultRow = new ScoredResultRowEntity(resultRow) + { + FinalPosition = i + 1, + RacePoints = 10 - i, + TotalPoints = 10 - i + }; + scoredSessionResult.ScoredResultRows.Add(scoredResultRow); + } + } + } + } + + // Create reviews + for (int i = 0; i < 5; i++) + { + var voteCategory = new VoteCategoryEntity() + { + Text = $"Category {i + 1}", + DefaultPenalty = i + 1, + }; + league1.VoteCategories.Add(voteCategory); + } + foreach (var session in season1.Schedules + .SelectMany(x => x.Events) + .SelectMany(x => x.Sessions)) + { + for (int i = 0; i < 5; i++) + { + var review = new IncidentReviewEntity() + { + Corner = (i + 1).ToString(), + OnLap = (i + 1).ToString(), + FullDescription = $"Incident review #{i + 1} Event {session.Event.Name} - {session.Name}", + IncidentKind = "Contact", + IncidentNr = (i + 1).ToString(), + }; + for (int j = 0; j < 3; j++) + { + review.InvolvedMembers.Add(GetRandomMember(random, members)); + } + for (int j = 0; j < 5; j++) + { + var comment = new ReviewCommentEntity() + { + Date = DateTime.Now, + AuthorName = GetRandomMember(random, members).Firstname, + Text = $"Comment #{j + 1} ", + ReviewCommentVotes = new List() + { + new ReviewCommentVoteEntity() + { + MemberAtFault = GetRandomMember(random, review.InvolvedMembers), + Description = "Vote", + VoteCategory = league1.VoteCategories.GetRandom(random), + } + }, + }; + review.Comments.Add(comment); + } + var acceptedCommentVote = review.Comments.First().ReviewCommentVotes.First(); + var acceptedVote = new AcceptedReviewVoteEntity() + { + MemberAtFault = acceptedCommentVote.MemberAtFault, + Description = acceptedCommentVote.Description, + VoteCategory = acceptedCommentVote.VoteCategory, + }; + session.IncidentReviews.Add(review); + } + } + } + + private static MemberEntity GetRandomMember(Random random, IEnumerable memberList) + { + var memberCount = memberList.Count(); + if (memberCount == 0) + { + return null; + } + return memberList.ElementAt(random.Next(memberCount)); + } + + private static TimeSpan GetTimeSpan(Random random) + { + return new TimeSpan(0, 1, 2, 34, 567); + } + + private static void GenerateMembers(LeagueDbContext context, Random random) + { + var minMemberCount = 50; + var maxMemberCount = 100; + + var memberCount = random.Next(maxMemberCount - minMemberCount + 1) + minMemberCount; + var members = context.Set(); + + for (int i = 0; i < memberCount; i++) + { + var member = new MemberEntity() + { + Firstname = GetRandomName(random), + Lastname = GetRandomName(random), + IRacingId = GetRandomIracingId(random) + }; + members.Add(member); + } + } + + private static string GetRandomName(Random random) + { + var minLen = 3; + var len = random.Next(10) + minLen; + char[] name = new char[len]; + char[] characters = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ßÄÜÖäüö".ToCharArray(); + + for (int i = 0; i < len; i++) + { + var offset = random.Next(characters.Length); + name[i] = characters[offset]; + } + return new string(name); + } + + private static string GetRandomIracingId(Random random) + { + var len = 6; + char[] id = new char[len]; + for (int i = 0; i < len; i++) + { + id[i] = (char)('0' + random.Next(10)); + } + return new string(id); + } +} + +public static class PopulateDatabaseExtensions +{ + /// + /// Returns a random entry from the list and removes it from the list at the same time + /// + /// + /// List to pop item from + /// Initialized random number generator + /// + public static T PopRandom(this ICollection collection, Random random = null) + { + random ??= new Random(); + var randomIndex = random.Next(collection.Count()); + var pop = collection.ElementAt(randomIndex); + collection.Remove(pop); + return pop; + } + + public static T GetRandom(this ICollection collection, Random random = null) + { + random ??= new(); + return collection.ElementAt(random.Next(collection.Count())); + } +} \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/_GlobalUsings.cs b/src/iRLeagueDatabaseCore/_GlobalUsings.cs new file mode 100644 index 00000000..1caebb45 --- /dev/null +++ b/src/iRLeagueDatabaseCore/_GlobalUsings.cs @@ -0,0 +1,6 @@ +global using iRLeagueApiCore.Common.Enums; +global using iRLeagueDatabaseCore.Converters; +global using Microsoft.EntityFrameworkCore; +global using Microsoft.EntityFrameworkCore.ChangeTracking; +global using Microsoft.EntityFrameworkCore.Metadata.Builders; +global using Microsoft.EntityFrameworkCore.Storage.ValueConversion; \ No newline at end of file diff --git a/src/iRLeagueDatabaseCore/iRLeagueDatabaseCore.csproj b/src/iRLeagueDatabaseCore/iRLeagueDatabaseCore.csproj new file mode 100644 index 00000000..ec3c2a4f --- /dev/null +++ b/src/iRLeagueDatabaseCore/iRLeagueDatabaseCore.csproj @@ -0,0 +1,40 @@ + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + Library + net6.0 + 11 + iRLeagueDatabaseCore + 0.11.1 + Simon Schulze + Simon Schulze + This package contains the Entityframework configuration for a Code first project + https://github.com/SSchulze1989/iRLeagueDatabaseCore + true + enable + + + diff --git a/src/iRLeagueManager.Web/Components/InputMarkdown.razor b/src/iRLeagueManager.Web/Components/InputMarkdown.razor index ebe1c5eb..ccbd37e4 100644 --- a/src/iRLeagueManager.Web/Components/InputMarkdown.razor +++ b/src/iRLeagueManager.Web/Components/InputMarkdown.razor @@ -21,8 +21,6 @@ @code { - private string uuid = "1"; - protected override bool TryParseValueFromString(string? value, [MaybeNullWhen(false)] out string result, [NotNullWhen(false)] out string? validationErrorMessage) { validationErrorMessage = null; diff --git a/src/iRLeagueManager.Web/Components/Settings/Dialogs/PointSettingsDialog.razor b/src/iRLeagueManager.Web/Components/Settings/Dialogs/PointSettingsDialog.razor index 51672489..ddc21e81 100644 --- a/src/iRLeagueManager.Web/Components/Settings/Dialogs/PointSettingsDialog.razor +++ b/src/iRLeagueManager.Web/Components/Settings/Dialogs/PointSettingsDialog.razor @@ -142,8 +142,6 @@ } } - private bool formulaHelpOpen = false; - protected override void OnParametersSet() { base.OnParametersSet(); diff --git a/src/iRLeagueManager.Web/Shared/ProfileHandler.cs b/src/iRLeagueManager.Web/Shared/ProfileHandler.cs index 8f79e3df..0ffd71e8 100644 --- a/src/iRLeagueManager.Web/Shared/ProfileHandler.cs +++ b/src/iRLeagueManager.Web/Shared/ProfileHandler.cs @@ -1,6 +1,4 @@ -using Humanizer; -using Microsoft.AspNetCore.Authorization; -using static Humanizer.In; +using Microsoft.AspNetCore.Authorization; using System.Security.Claims; using iRLeagueManager.Web.Extensions; diff --git a/src/iRLeagueManager.Web/iRLeagueManager.Web.csproj b/src/iRLeagueManager.Web/iRLeagueManager.Web.csproj index a4754073..3ab334ba 100644 --- a/src/iRLeagueManager.Web/iRLeagueManager.Web.csproj +++ b/src/iRLeagueManager.Web/iRLeagueManager.Web.csproj @@ -31,18 +31,24 @@ - + - - - + - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + diff --git a/test/DbIntegrationTests/DatabaseTestBase.cs b/test/DbIntegrationTests/DatabaseTestBase.cs new file mode 100644 index 00000000..47f12ca5 --- /dev/null +++ b/test/DbIntegrationTests/DatabaseTestBase.cs @@ -0,0 +1,58 @@ +using iRLeagueDatabaseCore.Models; +using iRLeagueDatabaseCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Moq; +using System; +using AutoFixture; +using System.Linq; + +namespace DbIntegrationTests; +public class DatabaseTestBase +{ + static IConfiguration _config; + protected static readonly int Seed = 12345; + protected long CurrentLeagueId { get; set; } + protected readonly Mock mockLeagueProvider = new(); + protected Fixture Fixture { get; } = new Fixture(); + protected LeagueDbContext DbContext { get; } + + static DatabaseTestBase() + { + var random = new Random(Seed); + _config = new ConfigurationBuilder() + .AddUserSecrets() + .Build(); + + // Setup database + var leagueProvider = Mock.Of(); + using var dbContext = GetStaticTestDatabaseContext(leagueProvider); + dbContext.Database.EnsureDeleted(); + dbContext.Database.Migrate(); + + PopulateTestDatabase.Populate(dbContext, random); + dbContext.SaveChanges(); + } + + public DatabaseTestBase() + { + mockLeagueProvider.Setup(x => x.LeagueId).Returns(() => CurrentLeagueId); + DbContext = GetTestDatabaseContext(); + CurrentLeagueId = DbContext.Leagues.First().Id; + } + + protected static LeagueDbContext GetStaticTestDatabaseContext(ILeagueProvider leagueProvider) + { + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseMySQL(_config.GetConnectionString("ModelDb")) + .UseLazyLoadingProxies(); + optionsBuilder.EnableSensitiveDataLogging(); + var dbContext = new LeagueDbContext(optionsBuilder.Options, leagueProvider); + return dbContext; + } + + protected LeagueDbContext GetTestDatabaseContext() + { + return GetStaticTestDatabaseContext(mockLeagueProvider.Object); + } +} diff --git a/test/DbIntegrationTests/DbIntegrationTests.cs b/test/DbIntegrationTests/DbIntegrationTests.cs new file mode 100644 index 00000000..42917305 --- /dev/null +++ b/test/DbIntegrationTests/DbIntegrationTests.cs @@ -0,0 +1,325 @@ +using FluentAssertions; +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Transactions; +using Xunit; +using Xunit.Abstractions; + +namespace DbIntegrationTests; + +[Collection("DbIntegration")] +public class DbIntegrationTests : DatabaseTestBase +{ + public DbIntegrationTests(ITestOutputHelper output) + { + output.WriteLine($"Randomizer seed: {Seed}"); + } + + [Fact] + public void ShouldPopulate() + { + using (var dbContext = GetTestDatabaseContext()) + { + var league = dbContext.Leagues.FirstOrDefault(); + SetCurrentLeague(league); + Assert.NotNull(league); + Assert.Equal("TestLeague", league.Name); + Assert.Equal(2, league.Seasons.Count()); + + // validate structure + foreach (var season in league.Seasons) + { + Assert.Equal(league, season.League); + Assert.Equal(league.Id, season.LeagueId); + } + + var seasonSchedules = league.Seasons.SelectMany(x => x.Schedules.Select(y => (x, y))); + foreach ((var season, var schedule) in seasonSchedules) + { + Assert.Equal(season, schedule.Season); + Assert.Equal(league.Id, schedule.LeagueId); + } + } + } + + [Fact] + public async Task ShouldDeleteLeage() + { + using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + using var dbContext = GetTestDatabaseContext(); + + var league = await dbContext.Leagues + .FirstAsync(); + dbContext.Leagues.Remove(league); + } + + [Fact] + public void CreateLeague() + { + using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + const string leagueName = "TestCreateLeague"; + using (var dbContext = GetTestDatabaseContext()) + { + var league = new LeagueEntity() + { + Name = leagueName, + NameFull = "2nd League for unit testing" + }; + dbContext.Leagues.Add(league); + var season = new SeasonEntity() + { + SeasonName = "TestSeason", + CreatedOn = DateTime.Now, + CreatedByUserName = "TestUser", + CreatedByUserId = "1" + }; + league.Seasons.Add(season); + + dbContext.SaveChanges(); + } + + using (var dbContext = GetTestDatabaseContext()) + { + var league = dbContext.Leagues.OrderBy(x => x.Id).Last(); + CurrentLeagueId = league.Id; + Assert.Equal(leagueName, league.Name); + Assert.Equal(1, league.Seasons.Count); + Assert.Equal(league, league.Seasons.First().League); + } + } + } + + [Fact] + public void ShouldUseLazyLoading() + { + using (var dbContext = GetTestDatabaseContext()) + { + var league = dbContext.Leagues.First(); + SetCurrentLeague(league); + Assert.NotNull(league); + Assert.Equal(2, league.Seasons.Count); + } + } + + [Fact] + public void ShouldNotUseLazyLoading_WhenDisabled() + { + using (var dbContext = GetTestDatabaseContext()) + { + dbContext.ChangeTracker.LazyLoadingEnabled = false; + var league = dbContext.Leagues.First(); + CurrentLeagueId = league.Id; + Assert.NotNull(league); + Assert.Equal(0, league.Seasons.Count); + } + } + + [Fact] + public void ShouldUseEagerLoading_WhenLazyLoadingDisabled() + { + using (var dbContext = GetTestDatabaseContext()) + { + dbContext.ChangeTracker.LazyLoadingEnabled = false; + SetCurrentLeague(dbContext.Leagues.First()); + var league = dbContext.Leagues + .Include(e => e.Seasons) + .First(); + Assert.NotNull(league); + Assert.Equal(2, league.Seasons.Count); + } + + using (var dbContext = GetTestDatabaseContext()) + { + dbContext.ChangeTracker.LazyLoadingEnabled = false; + var league = dbContext.Leagues.First(); + dbContext.Seasons.Load(); + + Assert.NotNull(league); + Assert.Equal(2, league.Seasons.Count); + } + } + + [Fact] + public async Task ShouldConvertTimeSpanPrecision() + { + TimeSpan testTimeSpan = TimeSpan.FromMinutes(1.23); + + using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + + using (var context = GetTestDatabaseContext()) + { + CurrentLeagueId = (await context.Leagues.FirstAsync()).Id; + var session = await context.Sessions.FirstAsync(); + session.Duration = testTimeSpan; + context.SaveChanges(); + } + + using (var context = GetTestDatabaseContext()) + { + var session = await context.Sessions.FirstAsync(); + Assert.Equal(testTimeSpan, session.Duration); + } + } + + [Fact] + public async Task LeagueShouldHaveScorings() + { + using var context = GetTestDatabaseContext(); + SetCurrentLeague(await context.Leagues.FirstAsync()); + var league = await context.Leagues + .Include(x => x.Scorings) + .FirstAsync(); + Assert.NotEmpty(league.Scorings); + } + + [Fact] + public async Task ShouldAddFilterToConfiguration() + { + using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + using (var context = GetTestDatabaseContext()) + { + SetCurrentLeague(await context.Leagues.FirstAsync()); + var filterOption = new FilterOptionEntity(); + var config = await context.ResultConfigurations.FirstAsync(); + config.PointFilters.Add(filterOption); + await context.SaveChangesAsync(); + } + + using (var context = GetTestDatabaseContext()) + { + var config = await context.ResultConfigurations.FirstAsync(); + Assert.NotEmpty(config.PointFilters); + } + } + + [Fact] + public async Task ShouldCascadeDeleteFilter() + { + using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + using var context = GetTestDatabaseContext(); + + SetCurrentLeague(await context.Leagues.FirstAsync()); + var filterOption = new FilterOptionEntity(); + var config = await context.ResultConfigurations.FirstAsync(); + config.PointFilters.Add(filterOption); + await context.SaveChangesAsync(); + + config.PointFilters.Remove(filterOption); + var filterOptionEntry = context.Entry(filterOption); + await context.SaveChangesAsync(); + + Assert.Equal(EntityState.Detached, filterOptionEntry.State); + } + + [Fact] + public async Task ShouldSetFilterValues() + { + using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + using var context = GetTestDatabaseContext(); + + SetCurrentLeague(await context.Leagues.FirstAsync()); + var filterOption = new FilterOptionEntity() + { + Conditions = new[] { + new FilterConditionModel() { FilterValues = new[] { "Value1", "Value2" } }, + }, + }; + var config = await context.ResultConfigurations.FirstAsync(); + config.PointFilters.Add(filterOption); + await context.SaveChangesAsync(); + var testFilterOption = await context.FilterOptions + .SingleAsync(x => x.FilterOptionId == filterOption.FilterOptionId); + + testFilterOption.Conditions.First().FilterValues.Should().BeEquivalentTo(filterOption.Conditions.First().FilterValues); + } + + [Fact] + public async Task ShouldConsiderMultiTenancyWithCorrectTenant() + { + using var context = GetTestDatabaseContext(); + var league = await context.Leagues.FirstAsync(); + var trueSeasonCount = await context.Seasons + .IgnoreQueryFilters() + .Where(x => x.LeagueId == league.Id) + .CountAsync(); + SetCurrentLeague(league); + + var seasons = await context.Seasons.ToListAsync(); + + seasons.Should().HaveCount(trueSeasonCount); + } + + [Fact] + public async Task ShouldConsiderMultiTenancyWithDifferentTenant() + { + using var context = GetTestDatabaseContext(); + CurrentLeagueId = 0; + var league = await context.Leagues.FirstAsync(); + + var seasons = await context.Seasons.ToListAsync(); + + seasons.Should().BeEmpty(); + } + + [Fact] + public async Task ShouldAddAutoPenalty() + { + //using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + using (var context = GetTestDatabaseContext()) + { + SetCurrentLeague(await context.Leagues.FirstAsync()); + var autoPenalty = new AutoPenaltyConfigEntity() + { + Conditions = + { + new() { + FilterType = iRLeagueApiCore.Common.Enums.FilterType.ColumnProperty, + FilterValues = { "4" }, + ColumnPropertyName = "Incidents", + Comparator = iRLeagueApiCore.Common.Enums.ComparatorType.ForEach, + Action = iRLeagueApiCore.Common.Enums.MatchedValueAction.Remove, + }, + }, + Description = "Test Penalty", + Points = 1, + Time = new TimeSpan(1, 2, 3), + Positions = 2, + Type = iRLeagueApiCore.Common.Enums.PenaltyType.Time, + }; + var pointRule = await context.PointRules.FirstAsync(); + pointRule.AutoPenalties.Add(autoPenalty); + await context.SaveChangesAsync(); + } + + using (var context = GetTestDatabaseContext()) + { + SetCurrentLeague(await context.Leagues.FirstAsync()); + var autoPenalty = context.AutoPenaltyConfigs.First(); + autoPenalty.Description.Should().Be("Test Penalty"); + autoPenalty.Points.Should().Be(1); + autoPenalty.Positions.Should().Be(2); + autoPenalty.Time.Should().Be(new TimeSpan(1, 2, 3)); + autoPenalty.Type.Should().Be(iRLeagueApiCore.Common.Enums.PenaltyType.Time); + autoPenalty.Conditions.Should().HaveCount(1); + autoPenalty.Conditions.First().FilterType.Should().Be(iRLeagueApiCore.Common.Enums.FilterType.ColumnProperty); + autoPenalty.Conditions.First().Comparator.Should().Be(iRLeagueApiCore.Common.Enums.ComparatorType.ForEach); + autoPenalty.Conditions.First().ColumnPropertyName.Should().Be("Incidents"); + autoPenalty.Conditions.First().FilterValues.Should().BeEquivalentTo(new[] { "4" }); + autoPenalty.Conditions.First().Action.Should().Be(iRLeagueApiCore.Common.Enums.MatchedValueAction.Remove); + } + } + + /// + /// Set the current league id for multi tenancy - must be called before any league specific entity is queried + /// + /// + private void SetCurrentLeague(LeagueEntity league) + { + CurrentLeagueId = league.Id; + } +} \ No newline at end of file diff --git a/test/DbIntegrationTests/DbIntegrationTests.csproj b/test/DbIntegrationTests/DbIntegrationTests.csproj new file mode 100644 index 00000000..7fc65fe6 --- /dev/null +++ b/test/DbIntegrationTests/DbIntegrationTests.csproj @@ -0,0 +1,29 @@ + + + + net6.0 + + false + 1bfa022b-b6c1-4b78-b148-9bee98acb5e8 + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/test/DbIntegrationTests/PenaltyValueTests.cs b/test/DbIntegrationTests/PenaltyValueTests.cs new file mode 100644 index 00000000..f901a431 --- /dev/null +++ b/test/DbIntegrationTests/PenaltyValueTests.cs @@ -0,0 +1,96 @@ +using FluentAssertions; +using iRLeagueApiCore.Common.Enums; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Transactions; +using Xunit; + +namespace DbIntegrationTests; +public sealed class PenaltyValueTests : DatabaseTestBase +{ + [Fact] + public async Task ShouldStorePointsPenaltyData() + { + //using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + var resultRow = await DbContext.ScoredResultRows.FirstAsync(); + var addPenalty = new AddPenaltyEntity() + { + LeagueId = resultRow.LeagueId, + ScoredResultRow = resultRow, + Value = new() { Type = PenaltyType.Points, Points = 10 } + }; + resultRow.AddPenalties.Add(addPenalty); + await DbContext.SaveChangesAsync(); + + var test = await DbContext.AddPenaltys.FirstAsync(x => x.AddPenaltyId == addPenalty.AddPenaltyId); + test.Value.Type.Should().Be(addPenalty.Value.Type); + test.Value.Points.Should().Be(addPenalty.Value.Points); + } + + [Fact] + public async Task ShouldStorePositionsPenaltyData() + { + //using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + var resultRow = await DbContext.ScoredResultRows.FirstAsync(); + var addPenalty = new AddPenaltyEntity() + { + LeagueId = resultRow.LeagueId, + ScoredResultRow = resultRow, + Value = new() { Type = PenaltyType.Position, Positions = 1 } + }; + resultRow.AddPenalties.Add(addPenalty); + await DbContext.SaveChangesAsync(); + + var test = await DbContext.AddPenaltys.FirstAsync(x => x.AddPenaltyId == addPenalty.AddPenaltyId); + test.Value.Type.Should().Be(addPenalty.Value.Type); + test.Value.Positions.Should().Be(addPenalty.Value.Positions); + } + + [Fact] + public async Task ShouldStoreTimePenaltyData() + { + //using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); + AddPenaltyEntity addPenalty; + using (var dbContext = GetTestDatabaseContext()) + { + var resultRow = await dbContext.ScoredResultRows.FirstAsync(); + addPenalty = new AddPenaltyEntity() + { + LeagueId = resultRow.LeagueId, + ScoredResultRow = resultRow, + Value = new() { Type = PenaltyType.Time, Time = TimeSpan.FromSeconds(10) } + }; + resultRow.AddPenalties.Add(addPenalty); + await dbContext.SaveChangesAsync(); + } + + using (var dbContext = GetTestDatabaseContext()) + { + var test = await dbContext.AddPenaltys.FirstAsync(x => x.AddPenaltyId == addPenalty.AddPenaltyId); + test.Value.Type.Should().Be(addPenalty.Value.Type); + test.Value.Time.Should().Be(addPenalty.Value.Time); + } + } + + [Fact] + public async Task ShouldBeAbleToHaveMultipleReviewPenalties() + { + var resultRow = await DbContext.ScoredResultRows.FirstAsync(); + var review = await DbContext.IncidentReviews.FirstAsync(); + var vote1 = new AcceptedReviewVoteEntity() { LeagueId = review.LeagueId, Review = review }; + var vote2 = new AcceptedReviewVoteEntity() { LeagueId = review.LeagueId, Review = review }; + var penalty1 = new ReviewPenaltyEntity() { LeagueId = review.LeagueId, Review = review, ResultRow = resultRow, ReviewVote = vote1 }; + var penalty2 = new ReviewPenaltyEntity() { LeagueId = review.LeagueId, Review = review, ResultRow = resultRow, ReviewVote = vote2 }; + DbContext.ReviewPenaltys.Add(penalty1); + DbContext.ReviewPenaltys.Add(penalty2); + await DbContext.SaveChangesAsync(); + + var test = await DbContext.ReviewPenaltys + .Where(x => x.ResultRowId == resultRow.ScoredResultRowId && x.ReviewId == review.ReviewId) + .ToListAsync(); + test.Should().Satisfy(x => x.ReviewVoteId == vote1.ReviewVoteId, x => x.ReviewVoteId == vote2.ReviewVoteId); + } +} diff --git a/test/UnitTests/Converters/TestCollectionToStringConverter.cs b/test/UnitTests/Converters/TestCollectionToStringConverter.cs new file mode 100644 index 00000000..4c74bd97 --- /dev/null +++ b/test/UnitTests/Converters/TestCollectionToStringConverter.cs @@ -0,0 +1,73 @@ +using iRLeagueDatabaseCore.Converters; +using System; +using System.Collections.Generic; +using System.Globalization; +using Xunit; + +namespace UnitTests.Converters; + +public class TestCollectionToStringConverter +{ + private const char delimiter = ';'; + + [Theory] + [InlineData(new int[] { 1, 3, 5, 8, 7 }, "1;3;5;8;7")] + [InlineData(new int[] { 0, 4, 42, 3 }, "0,4,42,3", ',')] + [InlineData(new int[] { 1, 0, 52345 }, "1;0;52345")] + public void ShouldConvertIntToString(IEnumerable intCollection, string arrayStr, char delimiter = delimiter) + { + var converter = new CollectionToStringConverter(delimiter); + var testStr = (string)converter.ConvertToProvider(intCollection); + Assert.Equal(arrayStr, testStr); + } + + [Theory] + [InlineData(new double[] { 1.2, 2.4 }, "1.2;2.4")] + public void ShouldConvertToDoubleString(IEnumerable doubleCollection, string arrayStr) + { + var converter = new CollectionToStringConverter(); + var testStr = (string)converter.ConvertToProvider(doubleCollection); + Assert.Equal(arrayStr, testStr); + } + + [Theory] + [InlineData(new double[] { 1.2, 2.4 }, "1,2;2,4")] + public void ShouldConvertToDoubleStringWithDifferentCulture(IEnumerable doubleCollection, string arrayStr) + { + var converter = new CollectionToStringConverter(CultureInfo.GetCultureInfo("de-DE")); + var testStr = (string)converter.ConvertToProvider(doubleCollection); + Assert.Equal(arrayStr, testStr); + } + + [Theory] + [InlineData("1;3;5;8;7", new int[] { 1, 3, 5, 8, 7 })] + [InlineData("0,4,42,3", new int[] { 0, 4, 42, 3 }, ',')] + [InlineData("0.1.2.3", new int[] { 0, 1, 2, 3 }, '.')] + [InlineData("1;;52345;", new int[] { 1, 52345 })] + public void ShouldConvertToIntCollection(string arrayStr, IEnumerable intCollection, char delimiter = delimiter) + { + var converter = new CollectionToStringConverter(delimiter); + var testCollection = (ICollection)converter.ConvertFromProvider(arrayStr); + Assert.Equal(intCollection, testCollection); + } + + [Theory] + [InlineData("1.2;2.4", new double[] { 1.2, 2.4 })] + public void ShouldConvertToDoubleCollection(string arrayStr, IEnumerable doubleCollection) + { + var converter = new CollectionToStringConverter(); + var testCollection = (ICollection)converter.ConvertFromProvider(arrayStr); + Assert.Equal(doubleCollection, testCollection); + } + + [Theory] + [InlineData("1;2;3", ',')] + [InlineData("1,2.3", ',')] + [InlineData("1,2.3", '.')] + [InlineData("1;2;a")] + public void ShouldThrowOnInvalidFormat(string arrayStr, char delimiter = delimiter) + { + var converter = new CollectionToStringConverter(delimiter); + Assert.Throws(() => (ICollection)converter.ConvertFromProvider(arrayStr)); + } +} diff --git a/test/UnitTests/Converters/TestDictionaryToStringConverter.cs b/test/UnitTests/Converters/TestDictionaryToStringConverter.cs new file mode 100644 index 00000000..17ccc5b5 --- /dev/null +++ b/test/UnitTests/Converters/TestDictionaryToStringConverter.cs @@ -0,0 +1,45 @@ +using iRLeagueDatabaseCore.Converters; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace UnitTests.Converters; + +public class TestDictionaryToStringConverter +{ + private const char pairDelimiter = ';'; + private const char valueDelimiter = ':'; + private static Dictionary testDict = new Dictionary() { { "val1", 1 }, { "val2", 2 } }; + private static string testString = "val1:1;val2:2"; + + [Fact] + public void ShouldConvertIntToString() + { + AssertConvertToString(testDict, testString); + } + + private static void AssertConvertToString(IDictionary dict, string expected) + { + var converter = new DictionaryToStringConverter(); + var result = (string)converter.ConvertToProvider(dict); + Assert.Equal(expected, result); + } + + [Fact] + public void ShouldConvertToDictionary() + { + AssertConvertToDict(testString, testDict); + } + + private static void AssertConvertToDict(string str, IDictionary expected) + { + var converter = new DictionaryToStringConverter(); + var result = (IDictionary)converter.ConvertFromProvider(str); + Assert.Equal(expected.Count, result.Count); + for (int i = 0; i < result.Count; i++) + { + Assert.Equal(expected.ElementAt(i).Key, result.ElementAt(i).Key); + Assert.Equal(expected.ElementAt(i).Value, result.ElementAt(i).Value); + } + } +} diff --git a/test/UnitTests/EntityFramework/TestCreateDatabase.cs b/test/UnitTests/EntityFramework/TestCreateDatabase.cs new file mode 100644 index 00000000..c512e174 --- /dev/null +++ b/test/UnitTests/EntityFramework/TestCreateDatabase.cs @@ -0,0 +1,365 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueDatabaseCore; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; +using Moq; +using System; +using System.Linq; +using Xunit; +using Xunit.Abstractions; + +namespace UnitTests.EntityFramework; + +public class TestCreateDatabase : IDisposable +{ + static string ClientUserName => "TestClient"; + static string ClientGuid => "6a6a6e09-f4b7-4ccb-a8ae-f2fc85d897dd"; + + private static readonly int Seed = 12345; + + private long CurrentLeagueId { get; set; } + private readonly Mock mockLeagueProvider = new(); + + public TestCreateDatabase(ITestOutputHelper output) + { + output.WriteLine($"Randomizer seed: {Seed}"); + mockLeagueProvider.Setup(x => x.LeagueId).Returns(() => CurrentLeagueId); + } + + static TestCreateDatabase() + { + var random = new Random(Seed); + + // Setup database + var mockLeagueProvider = new Mock(); + using (var dbContext = GetStaticTestDatabaseContext(mockLeagueProvider.Object)) + { + Populate(dbContext, random); + dbContext.SaveChanges(); + } + } + + private static LeagueDbContext GetStaticTestDatabaseContext(ILeagueProvider leagueProvider) + { + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseInMemoryDatabase(databaseName: "TestDatabase") + .UseLazyLoadingProxies(); + var dbContext = new LeagueDbContext(optionsBuilder.Options, leagueProvider); + dbContext.Database.EnsureCreated(); + + return dbContext; + } + + private LeagueDbContext GetTestDatabaseContext() + { + return GetStaticTestDatabaseContext(mockLeagueProvider.Object); + } + + public void Dispose() + { + + } + + [Fact] + public void TestPopulate() + { + using (var dbContext = GetTestDatabaseContext()) + { + var league = dbContext.Leagues.FirstOrDefault(); + SetCurrentLeague(league); + Assert.NotNull(league); + Assert.Equal("TestLeague", league.Name); + Assert.Equal(2, league.Seasons.Count()); + + // validate structure + foreach (var season in league.Seasons) + { + Assert.Equal(league, season.League); + Assert.Equal(league.Id, season.LeagueId); + } + + var seasonSchedules = league.Seasons.SelectMany(x => x.Schedules.Select(y => (x, y))); + foreach ((var season, var schedule) in seasonSchedules) + { + Assert.Equal(season, schedule.Season); + Assert.Equal(league.Id, schedule.LeagueId); + } + } + } + + [Fact] + public void TestCreateLeague() + { + using (var dbContext = GetTestDatabaseContext()) + { + var league = new LeagueEntity() + { + Name = "TestLeague2", + NameFull = "2nd League for unit testing" + }; + dbContext.Leagues.Add(league); + var season = new SeasonEntity() + { + SeasonName = "TestSeason", + CreatedOn = DateTime.Now, + CreatedByUserName = "TestUser", + CreatedByUserId = "1" + }; + league.Seasons.Add(season); + + dbContext.SaveChanges(); + } + + using (var dbContext = GetTestDatabaseContext()) + { + Assert.Equal(2, dbContext.Leagues.Count()); + var league = dbContext.Leagues.OrderBy(x => x.Id).Last(); + SetCurrentLeague(league); + Assert.Equal("TestLeague2", league.Name); + Assert.Equal(1, league.Seasons.Count); + Assert.Equal(league, league.Seasons.First().League); + } + + // clean up after testing + + using (var dbContext = GetTestDatabaseContext()) + { + var league = dbContext.Leagues.OrderBy(x => x.Id).Last(); + dbContext.Leagues.Remove(league); + dbContext.SaveChanges(); + } + } + + [Fact] + public void TestLazyLoading() + { + using (var dbContext = GetTestDatabaseContext()) + { + var league = dbContext.Leagues.First(); + SetCurrentLeague(league); + Assert.NotNull(league); + Assert.Equal(2, league.Seasons.Count); + } + } + + [Fact] + public void TestLazyLoadingDisabled() + { + using (var dbContext = GetTestDatabaseContext()) + { + dbContext.ChangeTracker.LazyLoadingEnabled = false; + var league = dbContext.Leagues.First(); + Assert.NotNull(league); + Assert.Equal(0, league.Seasons.Count); + } + } + + [Fact] + public void TestEagerLoading() + { + using (var dbContext = GetTestDatabaseContext()) + { + dbContext.ChangeTracker.LazyLoadingEnabled = false; + SetCurrentLeague(dbContext.Leagues.First()); + var league = dbContext.Leagues + .Include(e => e.Seasons) + .First(); + Assert.NotNull(league); + Assert.Equal(2, league.Seasons.Count); + } + + using (var dbContext = GetTestDatabaseContext()) + { + dbContext.ChangeTracker.LazyLoadingEnabled = false; + var league = dbContext.Leagues.First(); + SetCurrentLeague(league); + dbContext.Seasons.Load(); + + Assert.NotNull(league); + Assert.Equal(2, league.Seasons.Count); + } + } + + private static void Populate(LeagueDbContext context, Random random) + { + // Populate Tracks + for (int i = 0; i < 2; i++) + { + var group = new TrackGroupEntity() + { + TrackName = $"Group{i}", + Location = "Testlocation" + }; + for (int j = 0; j < 3; j++) + { + var config = new TrackConfigEntity() + { + ConfigName = $"Config{i}", + ConfigType = ConfigType.Road, + Turns = j * 3, + LengthKm = j * 1.0, + HasNightLighting = false + }; + group.TrackConfigs.Add(config); + } + context.TrackGroups.Add(group); + } + + // create models + var league = new LeagueEntity() + { + Name = "TestLeague", + NameFull = "League for unit testing" + }; + var season1 = new SeasonEntity() + { + SeasonName = "Season One", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + var season2 = new SeasonEntity() + { + SeasonName = "Season Two", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + var schedule1 = new ScheduleEntity() + { + Name = "S1 Schedule", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + var schedule2 = new ScheduleEntity() + { + Name = "S2 Schedule 1", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + var schedule3 = new ScheduleEntity() + { + Name = "S2 Schedule 2", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + // Create sessions on schedule1 + for (int i = 0; i < 5; i++) + { + var session = new EventEntity() + { + Name = $"S1 Session {i}", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + Track = context.TrackGroups + .SelectMany(x => x.TrackConfigs) + .Skip(i) + .FirstOrDefault(), + }; + schedule1.Events.Add(session); + } + league.Seasons.Add(season1); + league.Seasons.Add(season2); + season1.Schedules.Add(schedule1); + season2.Schedules.Add(schedule2); + season2.Schedules.Add(schedule3); + context.Leagues.Add(league); + + GenerateMembers(context, random); + + // assign members to league + foreach (var member in context.Members) + { + var leagueMember = new LeagueMemberEntity() + { + Member = member, + League = league + }; + context.Set().Add(leagueMember); + } + } + + private static void GenerateMembers(LeagueDbContext context, Random random) + { + var minMemberCount = 50; + var maxMemberCount = 100; + + var memberCount = random.Next(maxMemberCount - minMemberCount + 1) + minMemberCount; + var members = context.Set(); + + for (int i = 0; i < memberCount; i++) + { + var member = new MemberEntity() + { + Firstname = GetRandomName(random), + Lastname = GetRandomName(random), + IRacingId = GetRandomIracingId(random) + }; + members.Add(member); + } + } + + private static string GetRandomName(Random random) + { + var minLen = 3; + var len = random.Next(10) + minLen; + char[] name = new char[len]; + char[] characters = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ßÄÜÖäüö".ToCharArray(); + + for (int i = 0; i < len; i++) + { + var offset = random.Next(characters.Length); + name[i] = characters[offset]; + } + return new string(name); + } + + private static string GetRandomIracingId(Random random) + { + var len = 6; + char[] id = new char[len]; + for (int i = 0; i < len; i++) + { + id[i] = (char)('0' + random.Next(10)); + } + return new string(id); + } + + [Fact] + public void TestJustThisOneThing() + { + Assert.True(true); + } + + /// + /// Set the current league id for multi tenancy - must be called before any league specific entity is queried + /// + /// + private void SetCurrentLeague(LeagueEntity league) + { + CurrentLeagueId = league.Id; + } +} diff --git a/test/UnitTests/UnitTests.csproj b/test/UnitTests/UnitTests.csproj new file mode 100644 index 00000000..c627dc88 --- /dev/null +++ b/test/UnitTests/UnitTests.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + + false + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/test/iRLeagueApiCore.Common.Tests/IntervalTests.cs b/test/iRLeagueApiCore.Common.Tests/IntervalTests.cs new file mode 100644 index 00000000..59387680 --- /dev/null +++ b/test/iRLeagueApiCore.Common.Tests/IntervalTests.cs @@ -0,0 +1,55 @@ +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Common.Tests; + +public sealed class IntervalTests +{ + public static IEnumerable ConstructorTestData => new[] { + new object[] { new TimeSpan(0, 0, 2, 3), new Interval() { Time = new TimeSpan(0, 2, 3), Laps = 0 } }, + new object[] { new TimeSpan(1, 0, 0, 0), new Interval() { Time = new TimeSpan(0, 0, 0), Laps = 1 } }, + new object[] { new TimeSpan(2, 0, 2, 3), new Interval() { Time = new TimeSpan(0, 2, 3), Laps = 2 } }, + }; + + public static IEnumerable CompareTestData => new[] + { + new object[] { new Interval(new TimeSpan(1, 2, 3)), new Interval(new TimeSpan(3, 2, 1)), -1 }, + new object[] { new Interval(new TimeSpan(3, 2, 1)), new Interval(new TimeSpan(3, 2, 1)), 0 }, + new object[] { new Interval(new TimeSpan(3, 2, 1)), new Interval(new TimeSpan(1, 2, 3)), 1 }, + new object[] { new Interval(new TimeSpan(1, 0, 0, 0)), new Interval(new TimeSpan(2, 0, 0, 0)), -1 }, + new object[] { new Interval(new TimeSpan(2, 0, 0, 0)), new Interval(new TimeSpan(2, 0, 0, 0)), 0 }, + new object[] { new Interval(new TimeSpan(2, 0, 0, 0)), new Interval(new TimeSpan(1, 0, 0, 0)), 1 }, + new object[] { new Interval(new TimeSpan(1, 0, 2, 3)), new Interval(new TimeSpan(2, 0, 2, 3)), -1 }, + new object[] { new Interval(new TimeSpan(2, 0, 2, 3)), new Interval(new TimeSpan(2, 0, 2, 3)), 0 }, + new object[] { new Interval(new TimeSpan(2, 0, 2, 3)), new Interval(new TimeSpan(1, 0, 2, 3)), 1 }, + new object[] { new Interval(new TimeSpan(1, 0, 2, 3)), new Interval(new TimeSpan(1, 0, 3, 2)), -1 }, + new object[] { new Interval(new TimeSpan(1, 0, 3, 2)), new Interval(new TimeSpan(1, 0, 3, 2)), 0 }, + new object[] { new Interval(new TimeSpan(1, 0, 3, 2)), new Interval(new TimeSpan(1, 0, 2, 3)), 1 }, + }; + + [Theory] + [MemberData(nameof(ConstructorTestData))] + public void Interval_ShouldConstructFromTimeSpan(TimeSpan time, Interval expected) + { + var test = new Interval(time); + + test.Should().BeEquivalentTo(expected); + } + + [Theory] + [MemberData(nameof(CompareTestData))] + public void Interval_ShouldCompareToOtherInterval(Interval left, Interval right, int expected) + { + switch (expected) + { + case -1: + left.Should().BeLessThan(right); + break; + case 0: + left.Should().BeEquivalentTo(right); + break; + case 1: + left.Should().BeGreaterThan(right); + break; + } + } +} diff --git a/test/iRLeagueApiCore.Common.Tests/LeagueRolesTests.cs b/test/iRLeagueApiCore.Common.Tests/LeagueRolesTests.cs new file mode 100644 index 00000000..552e6d72 --- /dev/null +++ b/test/iRLeagueApiCore.Common.Tests/LeagueRolesTests.cs @@ -0,0 +1,58 @@ +namespace iRLeagueApiCore.Common.Tests; + +public class LeagueRolesTests +{ + [Theory] + [InlineData(LeagueRoles.Owner, true, true, true, true, true)] + [InlineData(LeagueRoles.Admin, false, true, true, true, true)] + [InlineData(LeagueRoles.Organizer, false, false, true, false, true)] + [InlineData(LeagueRoles.Steward, false, false, false, true, true)] + [InlineData(LeagueRoles.Member, false, false, false, false, true)] + public void ShouldHaveRoles(string roleName, + bool owner, + bool admin, + bool organizer, + bool steward, + bool member) + { + // Setup + var role = LeagueRoles.GetRoleValue(roleName); + var roles = new[] { role }; + + LeagueRoles.CheckRole(LeagueRoles.OwnerValue, roles).Should().Be(owner); + LeagueRoles.CheckRole(LeagueRoles.AdminValue, roles).Should().Be(admin); + LeagueRoles.CheckRole(LeagueRoles.OrganizerValue, roles).Should().Be(organizer); + LeagueRoles.CheckRole(LeagueRoles.StewardValue, roles).Should().Be(steward); + LeagueRoles.CheckRole(LeagueRoles.MemberValue, roles).Should().Be(member); + } + + [Theory] + [InlineData(LeagueRoles.Owner, new string[0])] + [InlineData(LeagueRoles.Admin, new[] { LeagueRoles.Owner })] + [InlineData(LeagueRoles.Organizer, new[] { LeagueRoles.Owner, LeagueRoles.Admin })] + [InlineData(LeagueRoles.Steward, new[] { LeagueRoles.Owner, LeagueRoles.Admin })] + [InlineData(LeagueRoles.Member, new[] { LeagueRoles.Owner, LeagueRoles.Admin, LeagueRoles.Organizer, LeagueRoles.Steward })] + public void ShouldBeImplicitOf(string roleName, string[] implicitOfRoleNames) + { + // Setup + var role = LeagueRoles.GetRoleValue(roleName); + var implicitOfRoles = implicitOfRoleNames.Select(x => LeagueRoles.GetRoleValue(x)).ToArray(); + + // Test + var testImplicitOfRoles = LeagueRoles.ImplicitRoleOf(role); + testImplicitOfRoles.Should().HaveSameCount(implicitOfRoles); + if (implicitOfRoles.Length != 0) + { + testImplicitOfRoles.Should().Contain(implicitOfRoles); + } + } + + [Fact] + public void ShouldConvertImplicitToString() + { + var role = LeagueRoles.GetRoleValue("Admin"); + string roleString = role; + + role.Equals(roleString).Should().BeTrue(); + } +} diff --git a/test/iRLeagueApiCore.Common.Tests/TimeSpanConverterTests.cs b/test/iRLeagueApiCore.Common.Tests/TimeSpanConverterTests.cs new file mode 100644 index 00000000..83d62f26 --- /dev/null +++ b/test/iRLeagueApiCore.Common.Tests/TimeSpanConverterTests.cs @@ -0,0 +1,50 @@ +using iRLeagueApiCore.Common.Converters; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace iRLeagueApiCore.Common.Tests; + +public sealed class TimeSpanConverterTests +{ + [Fact] + public void Read_ShouldReadTimeSpan_WithoutDays() + { + var json = @"{""TestTime"": ""01:02:03.45600""}"; + var test = JsonSerializer.Deserialize(json); + test.Should().NotBeNull(); + test!.TestTime.Should().Be(new TimeSpan(0, 1, 2, 3, 456)); + } + + [Fact] + public void Read_ShouldReadTimeSpan_WithDays() + { + var json = @"{""TestTime"": ""01.01:02:03.45600""}"; + var test = JsonSerializer.Deserialize(json); + test.Should().NotBeNull(); + test!.TestTime.Should().Be(new TimeSpan(1, 1, 2, 3, 456)); + } + + [Fact] + public void Write_ShouldWriteTimeSpan_WithoutDays() + { + var time = new TimeSpan(0, 1, 2, 3, 456); + var test = JsonSerializer.Serialize(new TestClass() { TestTime = time }); + test.Should().NotBeNull(); + test.Should().Contain("\"01:02:03.45600\""); + } + + [Fact] + public void Write_ShouldWriteTimeSpan_WithDays() + { + var time = new TimeSpan(1, 1, 2, 3, 456); + var test = JsonSerializer.Serialize(new TestClass() { TestTime = time }); + test.Should().NotBeNull(); + test.Should().Contain("\"01.01:02:03.45600\""); + } + + sealed class TestClass + { + [JsonConverter(typeof(JsonTimeSpanConverter))] + public TimeSpan TestTime { get; set; } + } +} diff --git a/test/iRLeagueApiCore.Common.Tests/_GlobalUsings.cs b/test/iRLeagueApiCore.Common.Tests/_GlobalUsings.cs new file mode 100644 index 00000000..321a8bad --- /dev/null +++ b/test/iRLeagueApiCore.Common.Tests/_GlobalUsings.cs @@ -0,0 +1,3 @@ +global using FluentAssertions; +global using System.Linq; +global using Xunit; \ No newline at end of file diff --git a/test/iRLeagueApiCore.Common.Tests/iRLeagueApiCore.Common.Tests.csproj b/test/iRLeagueApiCore.Common.Tests/iRLeagueApiCore.Common.Tests.csproj new file mode 100644 index 00000000..ecacb573 --- /dev/null +++ b/test/iRLeagueApiCore.Common.Tests/iRLeagueApiCore.Common.Tests.csproj @@ -0,0 +1,24 @@ + + + + net6.0 + enable + enable + false + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/test/iRLeagueApiCore.Mocking/DataAccess/DataAccessMockHelper.cs b/test/iRLeagueApiCore.Mocking/DataAccess/DataAccessMockHelper.cs new file mode 100644 index 00000000..bf64394d --- /dev/null +++ b/test/iRLeagueApiCore.Mocking/DataAccess/DataAccessMockHelper.cs @@ -0,0 +1,469 @@ +using AutoFixture.Dsl; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Mocking.Extensions; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueDatabaseCore; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Mocking.DataAccess; + +public sealed class DataAccessMockHelper +{ + private readonly Fixture fixture = new(); + private readonly Mock mockLeagueProvider = new(); + private long CurrentLeagueId { get; set; } = 0; + + public ILeagueProvider LeagueProvider => mockLeagueProvider.Object; + + public DataAccessMockHelper() + { + mockLeagueProvider.Setup(x => x.LeagueId).Returns(() => CurrentLeagueId); + } + + public LeagueDbContext CreateMockDbContext(string dbName) + { + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseInMemoryDatabase(databaseName: dbName) + .UseLazyLoadingProxies(); + var dbContext = new LeagueDbContext(optionsBuilder.Options, mockLeagueProvider.Object); + + return dbContext; + } + + public async Task PopulateBasicTestSet(LeagueDbContext dbContext) + { + var members = CreateMembers(); + dbContext.Members.AddRange(members); + + var league = CreateLeague(); + dbContext.Leagues.Add(league); + + var season = CreateSeason(league); + league.Seasons.Add(season); + + var leagueMembers = CreateLeagueMembers(league, members); + league.LeagueMembers = leagueMembers.ToList(); + + var teams = CreateTeams(league, leagueMembers); + league.Teams = teams.ToList(); + + var schedule = CreateSchedule(season); + season.Schedules.Add(schedule); + + var events = CreateEvents(schedule); + schedule.Events = events.ToList(); + + var championships = CreateChampionships(league); + league.Championships = championships.ToList(); + + foreach (var @event in events) + { + var result = CreateResult(@event, leagueMembers); + dbContext.EventResults.Add(result); + + var reviews = CreateReviews(@event); + dbContext.IncidentReviews.AddRange(reviews); + } + + var voteCategories = CreateVoteCategories(league); + league.VoteCategories = voteCategories.ToList(); + + dbContext.Leagues.Add(CreateLeague()); + + await dbContext.SaveChangesAsync(); + } + + public LeagueEntity CreateLeague() + { + return fixture.Build() + .With(x => x.LeaguePublic, LeaguePublicSetting.PublicListed) + .Without(x => x.VoteCategories) + .Without(x => x.LeagueMembers) + .Without(x => x.PointRules) + .Without(x => x.ResultConfigs) + .Without(x => x.Scorings) + .Without(x => x.Seasons) + .Without(x => x.Teams) + .Without(x => x.Championships) + .Without(x => x.StandingConfigs) + .Without(x => x.Payments) + .Create(); + } + + public SeasonEntity CreateSeason(LeagueEntity league) + { + return fixture.Build() + .With(x => x.League, league) + .With(x => x.LeagueId, league.Id) + .With(x => x.Finished, false) + .Without(x => x.MainScoring) + .Without(x => x.Schedules) + .Without(x => x.Standings) + .Without(x => x.StatisticSets) + .Without(x => x.ChampSeasons) + .Create(); + } + + public IEnumerable CreateMembers(int count = 10) + { + return fixture.Build() + .With(x => x.IRacingId, () => fixture.Create().ToString()) + .Without(x => x.AcceptedReviewVotes) + .Without(x => x.CleanestDriverResults) + .Without(x => x.CommentReviewVotes) + .Without(x => x.DriverStatisticRows) + .Without(x => x.FastestAvgLapResults) + .Without(x => x.FastestLapResults) + .Without(x => x.FastestQualyLapResults) + .Without(x => x.HardChargerResults) + .Without(x => x.InvolvedReviews) + .Without(x => x.ResultRows) + .Without(x => x.StatisticSets) + .CreateMany(count) + .ToList(); + } + + public IEnumerable CreateLeagueMembers(LeagueEntity league, IEnumerable members) + { + return members.Select(member => fixture.Build() + .With(x => x.League, league) + .With(x => x.LeagueId, league.Id) + .With(x => x.Member, member) + .Without(x => x.Team) + .Without(x => x.TeamId) + .Without(x => x.ProtestsInvolved) + .Create()) + .ToList(); + } + + public IEnumerable CreateTeams(LeagueEntity league, IEnumerable leagueMembers) + { + var memberChunks = leagueMembers.Chunk(3); + var teams = memberChunks + .Select(members => fixture.Build() + .With(x => x.League, league) + .With(x => x.LeagueId, league.Id) + .With(x => x.Members, members.Take(2).ToList()) + .Without(x => x.InvolvedReviews) + .Create()) + .ToList(); + + return teams; + } + + public ScheduleEntity CreateSchedule(SeasonEntity season) + { + return fixture.Build() + .With(x => x.LeagueId, season.LeagueId) + .With(x => x.Season, season) + .Without(x => x.Events) + .Without(x => x.Scorings) + .Create(); + } + + public SessionEntity CreateSession(EventEntity @event, SessionType sessionType = SessionType.Race) + { + return fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Event, @event) + .With(x => x.EventId, @event.EventId) + .With(x => x.SessionType, sessionType) + .Without(x => x.IncidentReviews) + .Without(x => x.SessionResult) + .Create(); + } + + public IPostprocessComposer EventBuilder(ScheduleEntity schedule) + { + var sessions = () => fixture.Build() + .With(x => x.LeagueId, schedule.LeagueId) + .With(x => x.SessionType, SessionType.Race) + .Without(x => x.Event) + .Without(x => x.EventId) + .Without(x => x.IncidentReviews) + .Without(x => x.SessionResult) + .CreateMany(); + return fixture.Build() + .With(x => x.LeagueId, schedule.LeagueId) + .With(x => x.Schedule, schedule) + .With(x => x.Sessions, () => sessions().ToList()) + .Without(x => x.EventResult) + .Without(x => x.ResultConfigs) + .Without(x => x.ScoredEventResults) + .Without(x => x.Track) + .Without(x => x.SimSessionDetails); + } + + public IEnumerable CreateEvents(ScheduleEntity schedule) + { + return EventBuilder(schedule) + .CreateMany() + .ToList(); + } + + public EventResultEntity CreateResult( + EventEntity @event, + IEnumerable members) + { + return fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Event, @event) + .With(x => x.EventId, @event.EventId) + .With(x => x.SessionResults, CreateSessionResults(@event, members).ToList()) + .Without(x => x.ScoredResults) + .Create(); + } + + public IEnumerable CreateSessionResults( + EventEntity @event, + IEnumerable members, + IEnumerable? startPositions = null, + IEnumerable? positions = null, + IEnumerable? racePoints = null) + { + startPositions ??= Enumerable.Range(1, members.Count()).Select(x => (double)x); + positions ??= startPositions; + racePoints ??= Enumerable.Range(1, members.Count()) + .Reverse() + .Select(x => x * 10.0); + + var startPosSeq = startPositions.CreateSequence(); + var positionsSeq = positions.CreateSequence(); + var racePointsSeq = racePoints.CreateSequence(); + return @event.Sessions.Select(session => fixture.Build() + .With(x => x.LeagueId, session.LeagueId) + .With(x => x.EventId, @event.EventId) + .With(x => x.Session, session) + .With(x => x.ResultRows, () => members.Select(member => fixture.Build() + .With(x => x.LeagueId, session.LeagueId) + .With(x => x.Member, member.Member) + .With(x => x.LeagueMember, member) + .With(x => x.Team, member.Team) + .With(x => x.TeamId, member.TeamId) + .With(x => x.FinishPosition, positionsSeq) + .With(x => x.StartPosition, startPosSeq) + .With(x => x.RacePoints, racePointsSeq) + .Without(x => x.SubResult) + .Create()).ToList()) + .With(x => x.IRSimSessionDetails, fixture.Build() + .With(x => x.Event, @event) + .Create()) + .Without(x => x.IRSimSessionDetails) + .Without(x => x.Result) + .Create()) + .ToList(); + } + + public IPostprocessComposer ConfigurationBuilder(EventEntity @event) + { + return fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Events, new[] { @event }) + .With(x => x.Scorings, @event.Sessions + .Where(x => x.SessionType == SessionType.Race) + .Select(session => fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Index, session.SessionNr) + .With(x => x.IsCombinedResult, false) + .With(x => x.PointsRule, () => fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .Without(x => x.Scorings) + .Without(x => x.AutoPenalties) + .Without(x => x.League) + .Without(x => x.BonusPoints) + .Create()) + .Without(x => x.DependendScorings) + .Without(x => x.ExtScoringSource) + .Without(x => x.ResultConfiguration) + .Create()) + .ToList()) + .Without(x => x.ChampSeason) + .Without(x => x.League) + .Without(x => x.PointFilters) + .Without(x => x.ResultFilters) + .Without(x => x.SourceResultConfigId) + .Without(x => x.SourceResultConfig); + } + + public ResultConfigurationEntity CreateConfiguration(EventEntity @event) + { + return ConfigurationBuilder(@event) + .Create(); + } + + public StandingConfigurationEntity CreateStandingConfiguration(LeagueEntity league) + { + return fixture.Build() + .With(x => x.LeagueId, league.Id) + .With(x => x.League, league) + .Without(x => x.Standings) + .Without(x => x.ChampSeasons) + .Create(); + } + + public ScoredEventResultEntity CreateScoredResult(EventEntity @event, ResultConfigurationEntity? config) + { + return fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Event, @event) + .With(x => x.ScoredSessionResults, @event.Sessions.Select(session => fixture.Build() + .With(x => x.LeagueId, session.LeagueId) + .With(x => x.Name, session.Name) + .With(x => x.SessionNr, session.SessionNr) + .With(x => x.ScoredResultRows, CreateScoredResultRows(session)) + .Without(x => x.Scoring) + .Without(x => x.ScoredEventResult) + .Without(x => x.CleanestDrivers) + .Without(x => x.FastestAvgLapDriver) + .Without(x => x.FastestLapDriver) + .Without(x => x.FastestQualyLapDriver) + .Without(x => x.HardChargers) + .Create()) + .ToList()) + .With(x => x.ResultConfig, config) + .With(x => x.ResultConfigId, config?.ResultConfigId) + .Without(x => x.ChampSeason) + .Create(); + } + + public IEnumerable CreateScoredResultRows(SessionEntity session) + { + return session.SessionResult.ResultRows.Select(row => fixture.Build() + .With(x => x.LeagueId, row.LeagueId) + .With(x => x.Member, row.Member) + .With(x => x.MemberId, row.MemberId) + .With(x => x.Team, row.Team) + .With(x => x.TeamId, row.TeamId) + .Without(x => x.AddPenalties) + .Without(x => x.ReviewPenalties) + .Without(x => x.ScoredSessionResult) + .Without(x => x.TeamResultRows) + .Without(x => x.TeamParentRows) + .Without(x => x.StandingRows) + .Create()).ToList(); + } + + public PointRuleEntity CreatePointRule(LeagueEntity league) + { + return fixture.Build() + .With(x => x.League, league) + .With(x => x.LeagueId, league.Id) + .Without(x => x.RuleType) + .Without(x => x.Scorings) + .Without(x => x.AutoPenalties) + .Without(x => x.BonusPoints) + .Without(x => x.Formula) + .Create(); + } + + public IEnumerable CreateReviews(EventEntity @event) + { + return @event.Sessions.Select(session => fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Session, session) + .With(x => x.SessionId, session.SessionId) + .Without(x => x.AcceptedReviewVotes) + .Without(x => x.Comments) + .Without(x => x.InvolvedMembers) + .Without(x => x.InvolvedTeams) + .Without(x => x.ReviewPenaltys) + .Create()).ToList(); + } + + public IEnumerable CreateComments(IncidentReviewEntity review) + { + return fixture.Build() + .With(x => x.Review, review) + .With(x => x.ReviewCommentVotes, () => CreateCommentVotes().ToList()) + .Without(x => x.Replies) + .Without(x => x.ReplyToComment) + .CreateMany(2); + } + + public IEnumerable CreateCommentVotes() + { + return fixture.Build() + .Without(x => x.MemberAtFault) + .Without(x => x.TeamAtFault) + .Without(x => x.VoteCategory) + .Without(x => x.Comment) + .CreateMany(); + } + + public IPostprocessComposer ChampionshipEntityBuilder(LeagueEntity league) + { + return fixture.Build() + .With(x => x.League, league) + .Without(x => x.ChampSeasons); + } + + public IEnumerable CreateChampionships(LeagueEntity league) + { + return ChampionshipEntityBuilder(league) + .CreateMany(2); + } + + public IPostprocessComposer ChampSeasonEntityBuilder(ChampionshipEntity championship, SeasonEntity season, int nResultConfigs = 1) + { + return fixture.Build() + .With(x => x.LeagueId, championship.LeagueId) + .With(x => x.ChampionshipId, championship.ChampionshipId) + .With(x => x.Championship, championship) + .With(x => x.SeasonId, season.SeasonId) + .With(x => x.Season, season) + .With(x => x.StandingConfiguration, () => CreateStandingConfiguration(championship.League)) + .With(x => x.ResultConfigurations, () => ConfigurationBuilder(season.Schedules.First().Events.First()).CreateMany(nResultConfigs).ToList()) + .With(x => x.IsActive, true) + .Without(x => x.Filters) + .Without(x => x.DefaultResultConfig) + .Without(x => x.Standings) + .Without(x => x.EventResults); + } + + public ChampSeasonEntity CreateChampSeason(ChampionshipEntity championship, SeasonEntity season, int nResultConfigs = 1) + { + return ChampSeasonEntityBuilder(championship, season, nResultConfigs: nResultConfigs) + .Create(); + } + + public IPostprocessComposer AcceptedReviewVoteBuilder() + { + return fixture.Build() + .Without(x => x.MemberAtFault) + .Without(x => x.TeamAtFault) + .Without(x => x.Review) + .Without(x => x.ReviewPenaltys) + .Without(x => x.VoteCategory); + } + + private IEnumerable CreateVoteCategories(LeagueEntity league) + { + return fixture.Build() + .With(x => x.League, league) + .Without(x => x.AcceptedReviewVotes) + .Without(x => x.CommentReviewVotes) + .CreateMany(); + } + + public IPostprocessComposer FilterOptionBuilder() + { + return fixture.Build() + .Without(x => x.Conditions) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.PointFilterResultConfigId) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ResultFilterResultConfigId); + } + + public void SetCurrentLeague(LeagueEntity league) + { + SetCurrentLeague(league.Id); + } + + public void SetCurrentLeague(long leagueId) + { + CurrentLeagueId = leagueId; + } +} diff --git a/test/iRLeagueApiCore.Mocking/DataAccess/DataAccessTestsBase.cs b/test/iRLeagueApiCore.Mocking/DataAccess/DataAccessTestsBase.cs new file mode 100644 index 00000000..a099197a --- /dev/null +++ b/test/iRLeagueApiCore.Mocking/DataAccess/DataAccessTestsBase.cs @@ -0,0 +1,60 @@ +using iRLeagueApiCore.Common; +using iRLeagueDatabaseCore; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Mocking.DataAccess; + +public abstract class DataAccessTestsBase : IAsyncLifetime +{ + protected readonly string databaseName; + protected readonly Fixture fixture; + protected readonly DataAccessMockHelper accessMockHelper; + protected readonly LeagueDbContext dbContext; + + protected ILeagueProvider LeagueProvider => accessMockHelper.LeagueProvider; + + protected const object? defaultId = null; + protected long TestLeagueId => dbContext.Leagues.IgnoreQueryFilters().First().Id; + protected string TestLeagueName => dbContext.Leagues.IgnoreQueryFilters().First().Name; + protected long TestSeasonId => dbContext.Seasons.IgnoreQueryFilters().First().SeasonId; + protected long TestScoringId => dbContext.Scorings.IgnoreQueryFilters().First().ScoringId; + protected long TestScheduleId => dbContext.Schedules.IgnoreQueryFilters().First().ScheduleId; + protected long TestEventId => dbContext.Events.IgnoreQueryFilters().First().EventId; + protected long TestSessionId => dbContext.Sessions.IgnoreQueryFilters().First().SessionId; + protected long TestResultId => dbContext.ScoredEventResults.IgnoreQueryFilters().First().ResultId; + protected long TestPointRuleId => dbContext.PointRules.IgnoreQueryFilters().First().PointRuleId; + protected long TestResultConfigId => dbContext.ResultConfigurations.IgnoreQueryFilters().First().ResultConfigId; + protected long TestReviewId => dbContext.IncidentReviews.IgnoreQueryFilters().First().ReviewId; + protected long TestMemberId => dbContext.Members.IgnoreQueryFilters().First().Id; + protected long TestMemberId2 => dbContext.Members.Skip(1).IgnoreQueryFilters().First().Id; + protected long TestCommentId => dbContext.ReviewComments.IgnoreQueryFilters().First().CommentId; + protected long TestReviewVoteId => dbContext.AcceptedReviewVotes.IgnoreQueryFilters().First().ReviewVoteId; + protected long TestVoteCategory => dbContext.VoteCategories.IgnoreQueryFilters().First().CatId; + protected const string testLeagueName = "TestLeague"; + protected const string testUserName = "TestUser"; + protected const string testUserId = "a0031cbe-a28b-48ac-a6db-cdca446a8162"; + protected static readonly IEnumerable testLeagueRoles = new string[] { LeagueRoles.Member }; + + public DataAccessTestsBase() + { + fixture = new Fixture(); + accessMockHelper = new(); + databaseName = fixture.Create(); + dbContext = accessMockHelper.CreateMockDbContext(databaseName); + fixture.Register(() => dbContext); + } + + public virtual async Task InitializeAsync() + { + dbContext.Database.EnsureCreated(); + await accessMockHelper.PopulateBasicTestSet(dbContext); + accessMockHelper.SetCurrentLeague(await dbContext.Leagues.FirstAsync()); + } + + public virtual async Task DisposeAsync() + { + dbContext.Database.EnsureDeleted(); + await dbContext.DisposeAsync(); + } +} diff --git a/test/iRLeagueApiCore.Mocking/Extensions/AutoFixtureExtensions.cs b/test/iRLeagueApiCore.Mocking/Extensions/AutoFixtureExtensions.cs new file mode 100644 index 00000000..b161ec2c --- /dev/null +++ b/test/iRLeagueApiCore.Mocking/Extensions/AutoFixtureExtensions.cs @@ -0,0 +1,26 @@ +using AutoFixture.Dsl; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.Mocking.Extensions; + +public static class AutoFixtureExtensions +{ + public static IPostprocessComposer WithSequence(this IPostprocessComposer composer, Expression> propertyPicker, IEnumerable sequence) + { + if (sequence.Any() == false) + { + throw new ArgumentException("Sequence must containe at least one entry", nameof(sequence)); + } + var enumerator = sequence.GetEnumerator(); + + return composer.With(propertyPicker, () => + { + if (enumerator.MoveNext() == false) + { + enumerator.Reset(); + enumerator.MoveNext(); + } + return enumerator.Current; + }); + } +} diff --git a/test/iRLeagueApiCore.Mocking/Extensions/EnumeratorExtensions.cs b/test/iRLeagueApiCore.Mocking/Extensions/EnumeratorExtensions.cs new file mode 100644 index 00000000..e4e21224 --- /dev/null +++ b/test/iRLeagueApiCore.Mocking/Extensions/EnumeratorExtensions.cs @@ -0,0 +1,35 @@ +namespace iRLeagueApiCore.Mocking.Extensions; + +public static class EnumeratorExtensions +{ + /// + /// Returns + /// Resets the enumerator when at the end of sequence/> + /// + /// + /// + /// Current value + public static T? Next(this IEnumerator enumerator) + { + if (enumerator.MoveNext()) + { + return enumerator.Current; + } + return default(T?); + } + + public static Func CreateSequence(this IEnumerable enumerable) + { + var enumerator = enumerable.GetEnumerator(); + return () => + { + if (enumerator.MoveNext()) + { + return enumerator.Current; + } + enumerator = enumerable.GetEnumerator(); + enumerator.MoveNext(); + return enumerator.Current; + }; + } +} diff --git a/test/iRLeagueApiCore.Mocking/_GlobaUsings.cs b/test/iRLeagueApiCore.Mocking/_GlobaUsings.cs new file mode 100644 index 00000000..abbc20ce --- /dev/null +++ b/test/iRLeagueApiCore.Mocking/_GlobaUsings.cs @@ -0,0 +1,3 @@ +global using AutoFixture; +global using Moq; +global using Xunit; diff --git a/test/iRLeagueApiCore.Mocking/iRLeagueApiCore.Mocking.csproj b/test/iRLeagueApiCore.Mocking/iRLeagueApiCore.Mocking.csproj new file mode 100644 index 00000000..ccacfde5 --- /dev/null +++ b/test/iRLeagueApiCore.Mocking/iRLeagueApiCore.Mocking.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + enable + enable + enable + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/CalculationMockHelper.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/CalculationMockHelper.cs new file mode 100644 index 00000000..14b43680 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/CalculationMockHelper.cs @@ -0,0 +1,72 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +internal static class CalculationMockHelper +{ + internal static PointRule MockPointRule( + FilterGroupRowFilter? pointFilters = default, + FilterGroupRowFilter? resultFilters = default, + FilterGroupRowFilter? champSeasonFilters = default, + Func, IReadOnlyList>? sortForPoints = default, + Func, IReadOnlyList>? sortFinal = default, + Func? getRacePoints = default, + IEnumerable? bonusPoints = default, + IEnumerable? autoPenalties = default) + { + pointFilters ??= new(Array.Empty<(FilterCombination, RowFilter)>()); + resultFilters ??= new(Array.Empty<(FilterCombination, RowFilter)>()); + champSeasonFilters ??= new(Array.Empty<(FilterCombination, RowFilter)>()); + sortForPoints ??= row => row.ToList(); + sortFinal ??= row => row.ToList(); + getRacePoints ??= (row, pos) => row.RacePoints; + bonusPoints ??= Array.Empty(); + autoPenalties ??= Array.Empty(); + return MockPointRule( + pointFilters, + resultFilters, + champSeasonFilters, + sortForPoints, + sortFinal, + getRacePoints, + bonusPoints, + autoPenalties); + } + + internal static PointRule MockPointRule( + FilterGroupRowFilter pointFilters, + FilterGroupRowFilter finalFilters, + FilterGroupRowFilter champSeasonFilters, + Func, IReadOnlyList> sortForPoints, + Func, IReadOnlyList> sortFinal, + Func getRacePoints, + IEnumerable bonusPoints, + IEnumerable autoPenalties) where T : IPointRow, IPenaltyRow + { + var mockRule = new Mock>(); + mockRule.Setup(x => x.GetPointFilters()).Returns(pointFilters); + mockRule.Setup(x => x.GetResultFilters()).Returns(finalFilters); + mockRule.Setup(x => x.GetChampSeasonFilters()).Returns(champSeasonFilters); + mockRule + .Setup(x => x.SortForPoints(It.IsAny>())) + .Returns((IEnumerable rows) => sortForPoints(rows).ToList()); + mockRule + .Setup(x => x.SortFinal(It.IsAny>())) + .Returns((IEnumerable rows) => sortFinal(rows).ToList()); + mockRule + .Setup(x => x.ApplyPoints(It.IsAny(), It.IsAny>())) + .Returns((SessionCalculationData _, IEnumerable rows) => + { + foreach ((T row, int pos) in rows.Select((x, i) => (x, i + 1))) + { + row.RacePoints = getRacePoints(row, pos); + } + return rows.ToList(); + }); + mockRule.Setup(x => x.GetBonusPoints()).Returns(bonusPoints); + mockRule.Setup(x => x.GetAutoPenalties()).Returns(autoPenalties); + return mockRule.Object; + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/CalculationPointRuleBaseTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/CalculationPointRuleBaseTests.cs new file mode 100644 index 00000000..8594feab --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/CalculationPointRuleBaseTests.cs @@ -0,0 +1,115 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueApiCore.Mocking.Extensions; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class CalculationPointRuleBaseTests +{ + private readonly Fixture fixture; + + public CalculationPointRuleBaseTests() + { + this.fixture = new(); + } + + [Fact] + public void SortForPoints_ShouldSort_WithSingleOption() + { + var pos = 1; + var sequence = (new[] { 2, 3, 1, 5, 4 }).AsEnumerable().GetEnumerator(); + var rows = fixture.Build() + .With(x => x.FinishPosition, () => pos++) + .With(x => x.RacePoints, () => sequence.Next()) + .CreateMany(5); + var sut = CreateSut(); + sut.PointSortOptions = new[] { SortOptions.RacePtsAsc }; + + var test = sut.SortForPoints(rows); + + var expected = new[] { 3, 1, 2, 5, 4 }; + foreach ((var testRow, var expectedPos) in test.Zip(expected)) + { + testRow.FinishPosition.Should().Be(expectedPos); + } + } + + [Fact] + public void SortForPoints_ShouldSort_WithMultipleOption() + { + var pos = 1; + var sequence1 = (new[] { 2, 2, 1, 4, 4 }).AsEnumerable().GetEnumerator(); + var sequence2 = (new[] { 5, 4, 3, 2, 2 }).AsEnumerable().GetEnumerator(); + var sequence3 = (new[] { 1, 2, 3, 5, 4 }).AsEnumerable().GetEnumerator(); + var rows = fixture.Build() + .With(x => x.FinishPosition, () => pos++) + .With(x => x.RacePoints, () => sequence1.Next()) + .With(x => x.BonusPoints, () => sequence2.Next()) + .With(x => x.Incidents, () => sequence3.Next()) + .CreateMany(5); + var sut = CreateSut(); + sut.PointSortOptions = new[] { SortOptions.RacePtsAsc, SortOptions.BonusPtsAsc, SortOptions.IncsAsc }; + + var test = sut.SortForPoints(rows); + + var expected = new[] { 3, 2, 1, 5, 4 }; + foreach ((var testRow, var expectedPos) in test.Zip(expected)) + { + testRow.FinishPosition.Should().Be(expectedPos); + } + } + + [Fact] + public void SortFinal_ShouldSort_WithSingleOption() + { + var pos = 1; + var sequence = (new[] { 2, 3, 1, 5, 4 }).AsEnumerable().GetEnumerator(); + var rows = fixture.Build() + .With(x => x.FinishPosition, () => pos++) + .With(x => x.RacePoints, () => sequence.Next()) + .CreateMany(5); + var sut = CreateSut(); + sut.FinalSortOptions = new[] { SortOptions.RacePtsAsc }; + + var test = sut.SortFinal(rows); + + var expected = new[] { 3, 1, 2, 5, 4 }; + foreach ((var testRow, var expectedPos) in test.Zip(expected)) + { + testRow.FinishPosition.Should().Be(expectedPos); + } + } + + [Fact] + public void SortFinal_ShouldSort_WithMultipleOption() + { + var pos = 1; + var sequence1 = (new[] { 2, 2, 1, 4, 4 }).AsEnumerable().GetEnumerator(); + var sequence2 = (new[] { 5, 4, 3, 2, 2 }).AsEnumerable().GetEnumerator(); + var sequence3 = (new[] { 1, 2, 3, 5, 4 }).AsEnumerable().GetEnumerator(); + var rows = fixture.Build() + .With(x => x.FinishPosition, () => pos++) + .With(x => x.RacePoints, () => sequence1.Next()) + .With(x => x.BonusPoints, () => sequence2.Next()) + .With(x => x.Incidents, () => sequence3.Next()) + .CreateMany(5); + var sut = CreateSut(); + sut.FinalSortOptions = new[] { SortOptions.RacePtsAsc, SortOptions.BonusPtsAsc, SortOptions.IncsAsc }; + + var test = sut.SortFinal(rows); + + var expected = new[] { 3, 2, 1, 5, 4 }; + foreach ((var testRow, var expectedPos) in test.Zip(expected)) + { + testRow.FinishPosition.Should().Be(expectedPos); + } + } + + private CalculationPointRuleBase CreateSut() + { + var mockSut = new Mock(); + mockSut.CallBase = true; + return mockSut.Object; + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/ColumnValueRowFilterTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/ColumnValueRowFilterTests.cs new file mode 100644 index 00000000..7dc396a4 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/ColumnValueRowFilterTests.cs @@ -0,0 +1,227 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Mocking.Extensions; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using System.Globalization; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class ColumnValueRowFilterTests +{ + private static readonly Fixture fixture = new(); + + private static IEnumerable TestValidConstructorData() => new[] + { + new object[] { nameof(ResultRowCalculationResult.FinalPosition), new[] { fixture.Create().ToString() } }, + new object[] { nameof(ResultRowCalculationResult.FinishPosition), new[] { fixture.Create().ToString(CultureInfo.InvariantCulture) }}, + new object[] { nameof(ResultRowCalculationResult.Firstname), new[] { fixture.Create() }}, + new object[] { nameof(ResultRowCalculationResult.QualifyingTime), new[] { fixture.Create().ToString() }}, + }; + + private static IEnumerable TestInValidConstructorData() => new[] + { + new object[] { nameof(ResultRowCalculationResult.FinalPosition), new[] { fixture.Create().ToString() } }, + new object[] { nameof(ResultRowCalculationResult.FinishPosition), new[] { fixture.Create().ToString(CultureInfo.InvariantCulture) }}, + new object[] { nameof(ResultRowCalculationResult.QualifyingTime), new[] { fixture.Create().ToString() }}, + new object[] { fixture.Create(), new[] { fixture.Create().ToString() }}, + }; + + private static IEnumerable TestFilterRowsData() + { + var matchRow = fixture.Create(); + return new[] + { + new object[] { nameof(ResultRowCalculationResult.CompletedLaps), matchRow, new[] { matchRow.CompletedLaps.ToString() } }, + new object[] { nameof(ResultRowCalculationResult.FastestLapTime), matchRow, new[] { matchRow.FastestLapTime.ToString() } }, + new object[] { nameof(ResultRowCalculationResult.Firstname), matchRow, new[] { matchRow.Firstname.ToString() } }, + new object[] { nameof(ResultRowCalculationResult.CompletedPct), matchRow, new[] { matchRow.CompletedPct.ToString() } }, + }; + } + + [Theory] + [MemberData(nameof(TestValidConstructorData))] + public void Constructor_ShouldNotThrow_WithValidValues(string propertyName, IEnumerable filterValues) + { + var test = () => CreateSut(propertyName, filterValues); + test.Should().NotThrow(); + } + + [Theory] + [MemberData(nameof(TestInValidConstructorData))] + public void Constructor_ShouldThrow_WithInvalidValues(string propertyName, IEnumerable filterValues) + { + var test = () => CreateSut(propertyName, filterValues); + test.Should().Throw(); + } + + [Theory] + [MemberData(nameof(TestFilterRowsData))] + public void FilterRows_ShouldKeepMatchingRows_WhenComparaterIsEqualAndActionIsKeep(string propertyName, + object matchRow, IEnumerable filterValues) + { + var rows = fixture.CreateMany().ToList(); + rows.Add((ResultRowCalculationResult)matchRow); + rows = rows.Shuffle().ToList(); + var sut = CreateSut(propertyName, filterValues, ComparatorType.IsEqual, MatchedValueAction.Keep); + + var test = sut.FilterRows(rows); + + test.Should().Contain((ResultRowCalculationResult)matchRow); + test.Should().HaveCount(1); + } + + [Theory] + [MemberData(nameof(TestFilterRowsData))] + public void FilterRows_ShouldRemoveMatchingRows_WhenComparaterIsEqualAndActionIsRemove(string propertyName, + object matchRow, IEnumerable filterValues) + { + var rows = fixture.CreateMany().ToList(); + rows.Add((ResultRowCalculationResult)matchRow); + rows = rows.Shuffle().ToList(); + var sut = CreateSut(propertyName, filterValues, ComparatorType.IsEqual, MatchedValueAction.Remove); + + var test = sut.FilterRows(rows); + + test.Should().NotContain((ResultRowCalculationResult)matchRow); + test.Should().HaveCount(rows.Count - 1); + } + + [Fact] + public void FilterRows_ShouldFilterValues_WhenComparaterIsSmaller() + { + var propertyName = nameof(ResultRowCalculationResult.TotalPoints); + var rows = fixture.CreateMany(5) + .OrderBy(x => x.TotalPoints); + var cutoffRow = rows.ElementAt(1); + var sut = CreateSut(propertyName, new[] { cutoffRow.TotalPoints.ToString() }, ComparatorType.IsSmaller, MatchedValueAction.Keep); + + var test = sut.FilterRows(rows); + + test.Should().Contain(rows.ElementAt(0)); + test.Should().HaveCount(1); + } + + [Fact] + public void FilterRows_ShouldFilterValues_WhenComparaterIsSmallerOrEqual() + { + var propertyName = nameof(ResultRowCalculationResult.TotalPoints); + var rows = fixture.CreateMany(5) + .OrderBy(x => x.TotalPoints); + var cutoffRow = rows.ElementAt(1); + var sut = CreateSut(propertyName, new[] { cutoffRow.TotalPoints.ToString() }, ComparatorType.IsSmallerOrEqual, MatchedValueAction.Keep); + + var test = sut.FilterRows(rows); + + test.Should().Contain(rows.ElementAt(0)); + test.Should().Contain(cutoffRow); + test.Should().HaveCount(2); + } + + [Fact] + public void FilterRows_ShouldFilterValues_WhenComparaterIsEqual() + { + var propertyName = nameof(ResultRowCalculationResult.TotalPoints); + var rows = fixture.CreateMany(5) + .OrderBy(x => x.TotalPoints); + var cutoffRow = rows.ElementAt(1); + var sut = CreateSut(propertyName, new[] { cutoffRow.TotalPoints.ToString() }, ComparatorType.IsEqual, MatchedValueAction.Keep); + + var test = sut.FilterRows(rows); + + test.Should().Contain(cutoffRow); + test.Should().HaveCount(1); + } + + [Fact] + public void FilterRows_ShouldFilterValues_WhenComparaterIsBiggerOrEqual() + { + var propertyName = nameof(ResultRowCalculationResult.TotalPoints); + var rows = fixture.CreateMany(5) + .OrderBy(x => x.TotalPoints); + var cutoffRow = rows.ElementAt(1); + var sut = CreateSut(propertyName, new[] { cutoffRow.TotalPoints.ToString() }, ComparatorType.IsBiggerOrEqual, MatchedValueAction.Keep); + + var test = sut.FilterRows(rows); + + test.Should().Contain(cutoffRow); + test.Should().HaveCount(rows.Count() - 1); + } + + [Fact] + public void FilterRows_ShouldFilterValues_WhenComparaterIsBigger() + { + var propertyName = nameof(ResultRowCalculationResult.TotalPoints); + var rows = fixture.CreateMany(5) + .OrderBy(x => x.TotalPoints); + var cutoffRow = rows.ElementAt(1); + var sut = CreateSut(propertyName, new[] { cutoffRow.TotalPoints.ToString() }, ComparatorType.IsBigger, MatchedValueAction.Keep); + + var test = sut.FilterRows(rows); + + test.Should().NotContain(rows.ElementAt(0)); + test.Should().NotContain(cutoffRow); + test.Should().HaveCount(rows.Count() - 2); + } + + [Fact] + public void FilterRows_ShouldFilterValues_WhenComparaterIsNotEqual() + { + var propertyName = nameof(ResultRowCalculationResult.TotalPoints); + var rows = fixture.CreateMany(5) + .OrderBy(x => x.TotalPoints); + var cutoffRow = rows.ElementAt(1); + var sut = CreateSut(propertyName, new[] { cutoffRow.TotalPoints.ToString() }, ComparatorType.NotEqual, MatchedValueAction.Keep); + + var test = sut.FilterRows(rows); + + test.Should().NotContain(cutoffRow); + test.Should().HaveCount(rows.Count() - 1); + } + + [Fact] + public void FilterRows_ShouldFilterValues_WhenComparaterIsInList() + { + var propertyName = nameof(ResultRowCalculationResult.Firstname); + var rows = fixture.CreateMany(5) + .OrderBy(x => x.Firstname); + var testRow1 = rows.ElementAt(1); + var testRow2 = rows.ElementAt(3); + var sut = CreateSut(propertyName, new[] { testRow1.Firstname, testRow2.Firstname }, ComparatorType.InList, MatchedValueAction.Keep); + + var test = sut.FilterRows(rows); + + test.Should().Contain(testRow1); + test.Should().Contain(testRow2); + test.Should().HaveCount(2); + } + + [Fact] + public void FilterRows_ShouldMultiplyRows_WhenComparatorIsForEach() + { + var propertyName = nameof(ResultRowCalculationResult.Incidents); + var incidents = new[] { 2.0, 4.0, 8.0 }; + var rows = fixture.Build() + .With(x => x.Incidents, incidents.CreateSequence()) + .CreateMany(incidents.Length); + var testRow1 = rows.ElementAt(0); + var testRow2 = rows.ElementAt(1); + var testRow3 = rows.ElementAt(2); + var sut = CreateSut(propertyName, new[] { "4.0" }, ComparatorType.ForEach, MatchedValueAction.Keep, allowForEach: true); + + var test = sut.FilterRows(rows); + + test.Count(x => x.ScoredResultRowId == testRow1.ScoredResultRowId).Should().Be(0); + test.Count(x => x.ScoredResultRowId == testRow2.ScoredResultRowId).Should().Be(1); + test.Count(x => x.ScoredResultRowId == testRow3.ScoredResultRowId).Should().Be(2); + } + + private ColumnValueRowFilter CreateSut(string propertyName, + IEnumerable filterValues, + ComparatorType comparator = ComparatorType.IsSmallerOrEqual, + MatchedValueAction action = MatchedValueAction.Keep, + bool allowForEach = false) + { + return new ColumnValueRowFilter(propertyName, comparator, filterValues, action, allowForEach); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/DefaultPointRuleTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/DefaultPointRuleTests.cs new file mode 100644 index 00000000..6dd580cd --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/DefaultPointRuleTests.cs @@ -0,0 +1,48 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class DefaultPointRuleTests +{ + private readonly Fixture fixture = new(); + + [Fact] + public void SortForPoints_ShouldNotChangeOrder() + { + var rows = GetTestRows(fixture); + var sut = GetPointRule(fixture); + + var test = sut.SortForPoints(rows.ToList()); + + test.Should().BeEquivalentTo(rows); + } + + [Fact] + public void ApplyPoints_ShouldCalculateTotalPoints() + { + var rows = GetTestRows(fixture); + var sut = GetPointRule(fixture); + + var test = sut.ApplyPoints(fixture.Create(), rows.ToList()); + + foreach (var row in test) + { + row.TotalPoints.Should().Be(row.RacePoints + row.BonusPoints - row.PenaltyPoints); + } + } + + private static IEnumerable GetTestRows(Fixture fixture) + { + return fixture + .Build() + .Without(x => x.AddPenalties) + .CreateMany(10).ToList(); + } + + private static DefaultPointRule GetPointRule(Fixture fixture) + { + return fixture.Create>(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/EventCalculationServiceProviderTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/EventCalculationServiceProviderTests.cs new file mode 100644 index 00000000..fdb3beb4 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/EventCalculationServiceProviderTests.cs @@ -0,0 +1,41 @@ +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class EventCalculationServiceProviderTests +{ + private readonly Fixture fixture; + private readonly Mock> + mockServiceProvider; + + public EventCalculationServiceProviderTests() + { + fixture = new(); + mockServiceProvider = new Mock>(); + mockServiceProvider.Setup(x => x.GetCalculationService(It.IsAny())) + .Returns(() => Mock.Of>()); + fixture.Register(() => mockServiceProvider.Object); + } + + [Fact] + public void GetCalculationService_ShouldProvideEventCalculationService() + { + var config = GetCalculationConfiguration(); + var sut = CreateSut(); + + var test = sut.GetCalculationService(config); + + test.Should().BeOfType(); + } + + private EventCalculationServiceProvider CreateSut() + { + return fixture.Create(); + } + + private EventCalculationConfiguration GetCalculationConfiguration() + { + return fixture.Create(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/EventCalculationServiceTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/EventCalculationServiceTests.cs new file mode 100644 index 00000000..2cea8dcc --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/EventCalculationServiceTests.cs @@ -0,0 +1,134 @@ +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class EventCalculationServiceTests +{ + private readonly Fixture fixture; + private readonly Mock> mockService; + private readonly Mock> + mockServiceProvider; + + public EventCalculationServiceTests() + { + fixture = new(); + mockService = new Mock>(); + mockService.Setup(x => x.Calculate(It.IsAny())) + .ReturnsAsync(() => fixture.Create()) + .Verifiable(); + mockServiceProvider = new Mock>(); + mockServiceProvider + .Setup(x => x.GetCalculationService(It.IsAny())) + .Returns(() => mockService.Object) + .Verifiable(); + fixture.Register(() => mockServiceProvider.Object); + } + + [Fact] + public async Task Calculate_ShouldThrow_WhenEventIdDoesNotMatch() + { + var data = GetCalculationData(); + var config = GetCalculationConfiguration(data.LeagueId, fixture.Create()); + var sut = CreateSut(config); + + var test = async () => await sut.Calculate(data); + + await test.Should().ThrowAsync(); + } + + [Fact] + public async Task Calculate_ShouldSetResultData() + { + var data = GetCalculationData(); + var config = GetCalculationConfiguration(data); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + test.LeagueId.Should().Be(config.LeagueId); + test.EventId.Should().Be(config.EventId); + test.ResultId.Should().Be(config.ResultId); + test.ResultConfigId.Should().Be(config.ResultConfigId); + test.Name.Should().Be(config.DisplayName); + test.SessionResults.Should().HaveSameCount(config.SessionResultConfigurations); + } + + [Fact] + public async Task Calculate_ShouldCallCalculateForEachSession() + { + var data = GetCalculationData(); + var config = GetCalculationConfiguration(data); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + foreach (var session in data.SessionResults) + { + mockService.Verify(x => x.Calculate(session), Times.Once()); + } + } + + [Fact] + public async Task Calculate_ShouldNotCallCalculate_WhenNoMatchingConfigFound() + { + var data = GetCalculationData(); + var config = GetCalculationConfiguration(data); + var addData = fixture.Create(); + data.SessionResults = data.SessionResults.Append(addData); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + test.SessionResults.Should().HaveCount(data.SessionResults.Count() - 1); + mockService.Verify(x => x.Calculate(addData), Times.Never()); + } + + [Fact] + public async Task Calculate_ShouldIngoreSessionConfig_WhenNoMatchingSessionFound() + { + var data = GetCalculationData(); + var config = GetCalculationConfiguration(data); + var addConfig = fixture.Create(); + config.SessionResultConfigurations = config.SessionResultConfigurations.Append(addConfig); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + test.SessionResults.Should().HaveCount(config.SessionResultConfigurations.Count() - 1); + } + + private EventCalculationService CreateSut(EventCalculationConfiguration config) + { + fixture.Register(() => config); + return fixture.Create(); + } + + private EventCalculationData GetCalculationData() + { + return fixture.Create(); + } + + private EventCalculationConfiguration GetCalculationConfiguration(EventCalculationData data) + { + return GetCalculationConfiguration(data.LeagueId, data.EventId, data.SessionResults); + } + + private EventCalculationConfiguration GetCalculationConfiguration(long leagueId, long eventId, IEnumerable? sessionData = default) + { + var sessionIds = sessionData?.Select(x => x.SessionId).NotNull() ?? Array.Empty(); + var sessionNrs = sessionData?.Select(x => x.SessionNr).NotNull() ?? Array.Empty(); + var config = fixture.Build() + .With(x => x.LeagueId, leagueId) + .With(x => x.EventId, eventId) + .Create(); + foreach ((var sessionConfig, var index) in config.SessionResultConfigurations.Select((x, i) => (x, i))) + { + sessionConfig.SessionId = sessionIds.ElementAtOrDefault(index); + sessionConfig.SessionNr = sessionNrs.ElementAtOrDefault(index); + sessionConfig.IsCombinedResult = false; + } + return config; + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/FilterGroupRowFilterTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/FilterGroupRowFilterTests.cs new file mode 100644 index 00000000..622fc6a7 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/FilterGroupRowFilterTests.cs @@ -0,0 +1,110 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Mocking.Extensions; +using iRLeagueApiCore.Services.ResultService.Calculation; +using System.Diagnostics; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; +public sealed class FilterGroupRowFilterTests +{ + private readonly Fixture fixture = new(); + + [Fact] + public void FilterRows_ShouldFilter_WithSingleFilter() + { + var pos = Enumerable.Range(1, 10); + var rows = fixture.Build() + .With(x => x.Value1, pos.CreateSequence()) + .CreateMany(10) + .ToList(); + Debug.Assert(rows[1].Value1 == 2); + var filter = TestFilter(x => x.Value1 <= 5); + Debug.Assert(filter.FilterRows(rows).Count() == 5); + var filterGroup = new FilterGroupRowFilter(new[] { (FilterCombination.And, filter) }); + + var testRows = filterGroup.FilterRows(rows); + + testRows.Should().HaveCount(5); + testRows.Select(x => x.Value1).Should().BeEquivalentTo(pos.Take(5)); + } + + [Fact] + public void FilterRows_ShouldFilter_MultipleAndFilters() + { + var pos = Enumerable.Range(1, 10); + var rows = fixture.Build() + .With(x => x.Value1, pos.CreateSequence()) + .CreateMany(10) + .ToList(); + Debug.Assert(rows[1].Value1 == 2); + var filter1 = TestFilter(x => x.Value1 <= 5); + var filter2 = TestFilter(x => x.Value1 > 2); + Debug.Assert(filter1.FilterRows(rows).Count() == 5); + Debug.Assert(filter2.FilterRows(rows).Count() == 8); + var filterGroup = new FilterGroupRowFilter(new[] { (FilterCombination.And, filter1), (FilterCombination.And, filter2) }); + + var testRows = filterGroup.FilterRows(rows); + + testRows.Should().HaveCount(3); + testRows.Select(x => x.Value1).Should().BeEquivalentTo(pos.Skip(2).Take(3)); + } + + [Fact] + public void FilterRows_ShouldFilter_MultipleAndAndOrFilters() + { + var pos = Enumerable.Range(1, 10); + var rating = new[] { 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.0, 1.0 }; + var rows = fixture.Build() + .With(x => x.Value1, pos.CreateSequence()) + .With(x => x.Value2, rating.CreateSequence()) + .CreateMany(10) + .ToList(); + Debug.Assert(rows[1].Value1 == 2); + var filter1 = TestFilter(x => x.Value1 <= 3); + var filter2 = TestFilter(x => x.Value2 == 1.0); + Debug.Assert(filter1.FilterRows(rows).Count() == 3); + Debug.Assert(filter2.FilterRows(rows).Count() == 2); + var filterGroup = new FilterGroupRowFilter(new[] { (FilterCombination.And, filter1), (FilterCombination.Or, filter2) }); + + var testRows = filterGroup.FilterRows(rows); + + testRows.Should().HaveCount(5); + testRows.Take(3).Select(x => x.Value1).Should().BeEquivalentTo(pos.Take(3)); + testRows.Skip(3).Select(x => x.Value1).Should().BeEquivalentTo(pos.Skip(8)); + } + + [Fact] + public void FilterRows_ShouldNotChangeOrder() + { + var pos = Enumerable.Range(1, 10); + var rating = new[] { 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 }; + var rows = fixture.Build() + .With(x => x.Value1, pos.CreateSequence()) + .With(x => x.Value2, rating.CreateSequence()) + .CreateMany(10) + .ToList(); + Debug.Assert(rows[1].Value1 == 2); + var filter1 = TestFilter(x => x.Value1 > 7); + var filter2 = TestFilter(x => x.Value2 == 1.0); + Debug.Assert(filter1.FilterRows(rows).Count() == 3); + Debug.Assert(filter2.FilterRows(rows).Count() == 2); + var filterGroup = new FilterGroupRowFilter(new[] { (FilterCombination.And, filter1), (FilterCombination.Or, filter2) }); + + var testRows = filterGroup.FilterRows(rows); + + testRows.Should().HaveCount(5); + testRows.Take(2).Select(x => x.Value1).Should().BeEquivalentTo(pos.Take(2)); + testRows.Skip(2).Select(x => x.Value1).Should().BeEquivalentTo(pos.Skip(7)); + } + + private static RowFilter TestFilter(Func filterFunc) + { + var filter = new Mock>(); + filter.Setup(x => x.FilterRows(It.IsAny>())) + .Returns((IEnumerable rows) => rows.Where(filterFunc)); + return filter.Object; + } + + public record TestRow(int Value1, double Value2); +} + + diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/FormulaPointRuleTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/FormulaPointRuleTests.cs new file mode 100644 index 00000000..53df94a1 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/FormulaPointRuleTests.cs @@ -0,0 +1,125 @@ +using AutoFixture; +using AutoFixture.Dsl; +using iRLeagueApiCore.Mocking.Extensions; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Models; +using System.Xml.Serialization; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; +public sealed class FormulaPointRuleTests +{ + private readonly Fixture fixture = new(); + + [Theory] + [InlineData("pos", 1)] + [InlineData("position", 1)] + [InlineData("start", 2)] + [InlineData("start_position", 2)] + [InlineData("count", 1)] + [InlineData("driver_count", 1)] + [InlineData("irating", 4200)] + [InlineData("flap", 4.20)] + [InlineData("fastest_lap", 4.20)] + [InlineData("qlap", 42.0)] + [InlineData("qualy_lap", 42.0)] + [InlineData("avglap", 420.0)] + [InlineData("avg_lap", 420.0)] + [InlineData("sof", 1234)] + [InlineData("strength_of_field", 1234)] + [InlineData("flapsession", 1.23)] + [InlineData("session_fastest_lap", 1.23)] + [InlineData("qlapsession", 12.3)] + [InlineData("session_fastest_qualy_lap", 12.3)] + [InlineData("avglapsession", 123.0)] + [InlineData("session_fastest_avg_lap", 123.0)] + public void ApplyPoints_ShouldWorkWithAliases(string alias, double expected) + { + var formula = $"[{alias}]"; + var rows = TestRowsBuilder(fixture, 1) + .With(x => x.OldIrating, 4200) + .With(x => x.FastestLapTime, TimeSpan.FromSeconds(4.20)) + .With(x => x.QualifyingTime, TimeSpan.FromSeconds(42.0)) + .With(x => x.AvgLapTime, TimeSpan.FromSeconds(420)) + .With(x => x.StartPosition, 2) + .CreateMany(1); + var session = SessionDataBuilder(fixture, rows) + .With(x => x.Sof, 1234) + .With(x => x.FastestLap, TimeSpan.FromSeconds(1.23)) + .With(x => x.FastestQualyLap, TimeSpan.FromSeconds(12.3)) + .With(x => x.FastestAvgLap, TimeSpan.FromSeconds(123.0)) + .Create(); + var sut = GetPointRule(formula, allowNegativePoints: false); + + var test = sut.ApplyPoints(session, rows.ToList()).ToList(); + + test.First().RacePoints.Should().Be(expected); + } + + [Theory] + [InlineData("10 - ([pos] - 1)", new double[] { 10, 9, 8 }, false)] + [InlineData("1 - ([pos] - 1)", new double[] { 1, 0, 0 }, false)] + [InlineData("1 - ([pos] - 1)", new double[] { 1, 0, -1 }, true)] + public void Should_ApplyPointsBasedOnPosition(string formula, double[] expected, bool allowNegativePoints) + { + var rows = GetTestRows(fixture, expected.Length); + var session = GetSessionData(fixture, rows); + var sut = GetPointRule(formula, allowNegativePoints); + + var test = sut.ApplyPoints(session, rows.ToList()).ToList(); + + foreach (var (row, points) in test.Zip(expected)) + { + row.RacePoints.Should().Be(points); + } + } + + [Theory] + [InlineData("[count]", new double[] { 5, 5, 5, 5, 5 }, false)] + [InlineData("[count] - ([pos] - 1)", new double[] { 3, 2, 1 }, false)] + [InlineData("[count] - 2 - ([pos] - 1)", new double[] { 1, 0, 0 }, false)] + [InlineData("[count] - 2 - ([pos] - 1)", new double[] { 1, 0, -1 }, true)] + [InlineData("[count] * 10 - ([pos] - 1)*[count]", new double[] { 30, 27, 24 }, false)] + public void Should_ApplyPointsBasedOnCount(string formula, double[] expected, bool allowNegativePoints) + { + var rows = GetTestRows(fixture, expected.Length); + var session = GetSessionData(fixture, rows); + var sut = GetPointRule(formula, allowNegativePoints); + + var test = sut.ApplyPoints(session, rows.ToList()).ToList(); + + foreach (var (row, points) in test.Zip(expected)) + { + row.RacePoints.Should().Be(points); + } + } + + private static IPostprocessComposer TestRowsBuilder(Fixture fixture, int count) + { + var position = Enumerable.Range(1, count).AsEnumerable().CreateSequence(); + return fixture + .Build() + .With(x => x.FinishPosition, () => position()) + .Without(x => x.AddPenalties); + } + + private static IEnumerable GetTestRows(Fixture fixture, int count) + { + return TestRowsBuilder(fixture, count).CreateMany(count).ToList(); + } + + private static IPostprocessComposer SessionDataBuilder(Fixture fixture, IEnumerable rows) + { + return fixture.Build() + .With(x => x.ResultRows, rows); + } + + private static SessionCalculationData GetSessionData(Fixture fixture, IEnumerable rows) + { + return SessionDataBuilder(fixture, rows).Create(); + } + + private static FormulaPointRule GetPointRule(string formula, bool allowNegativePoints) + { + return new(formula, allowNegativePoints); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/IdRowFilterTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/IdRowFilterTests.cs new file mode 100644 index 00000000..166d5b34 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/IdRowFilterTests.cs @@ -0,0 +1,75 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.Globalization; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; +public sealed class IdRowFilterTests +{ + private static readonly Fixture fixture = new(); + + private static IEnumerable TestValidConstructorData() => new[] + { + new object[] { fixture.CreateMany().Select(x => x.ToString()) }, + }; + + private static IEnumerable TestInvalidConstructorData() => new[] + { + new object[] { new[] { "123a4" } }, + new object[] { new[] { fixture.Create().ToString() } }, + new object[] { new[] { "1.23" } }, + }; + + [Theory] + [MemberData(nameof(TestValidConstructorData))] + public void Constructor_ShouldNotThrow_WithValidValues(IEnumerable values) + { + _ = new IdRowFilter(values, x => x.MemberId.GetValueOrDefault(), MatchedValueAction.Keep); + } + + [Theory] + [MemberData(nameof(TestInvalidConstructorData))] + public void Constructor_ShouldThrow_WithInvalidValues(IEnumerable values) + { + var test = () => new IdRowFilter(values, x => x.MemberId.GetValueOrDefault(), MatchedValueAction.Keep); + test.Should().Throw(); + } + + [Fact] + public void FilterValues_ShouldFilterValues_WithKeepAction() + { + int valueCount = 3; + var rows = fixture.CreateMany(10).ToList(); + var memberIds = rows.Select(x => x.MemberId).Take(valueCount).ToList(); + rows = rows.Shuffle().ToList(); + var sut = new IdRowFilter(memberIds.Select(x => x.ToString()).NotNull(), x => x.MemberId.GetValueOrDefault(), MatchedValueAction.Keep); + + var test = sut.FilterRows(rows); + + test.Should().HaveCount(valueCount); + foreach(var row in test) + { + memberIds.Should().Contain(row.MemberId); + } + } + + [Fact] + public void FilterValues_ShouldFilterValues_WithRemoveAction() + { + int valueCount = 3; + var rows = fixture.CreateMany(10).ToList(); + var memberIds = rows.Select(x => x.MemberId).Take(valueCount).ToList(); + rows = rows.Shuffle().ToList(); + var sut = new IdRowFilter(memberIds.Select(x => x.ToString()).NotNull(), x => x.MemberId.GetValueOrDefault(), MatchedValueAction.Remove); + + var test = sut.FilterRows(rows); + + test.Should().HaveCount(10 - valueCount); + foreach (var row in test) + { + memberIds.Should().NotContain(row.MemberId); + } + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/MemberSessionCalculationServiceTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/MemberSessionCalculationServiceTests.cs new file mode 100644 index 00000000..6ce8eab5 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/MemberSessionCalculationServiceTests.cs @@ -0,0 +1,727 @@ +using AutoFixture.Dsl; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueApiCore.Mocking.Extensions; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Common.Models; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class MemberSessionCalculationServiceTests +{ + private readonly Fixture fixture = new(); + + [Fact] + public async Task Calculate_ShouldSetResultMetaData() + { + var data = GetCalculationData(); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.LeagueId.Should().Be(config.LeagueId); + test.Name.Should().Be(config.Name); + test.SessionId.Should().Be(config.SessionId); + test.SessionResultId.Should().Be(config.SessionResultId); + } + + [Fact] + public async Task Calculate_ShouldApplyPoints_BasedOnOriginalPosition() + { + var data = GetCalculationData(); + data.ResultRows = GetTestRows(); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.PointRule = CalculationMockHelper.MockPointRule(getRacePoints: (row, pos) => pos); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().HaveSameCount(data.ResultRows); + foreach ((var row, var pos) in test.ResultRows.Select((x, i) => (x, i + 1))) + { + row.RacePoints.Should().Be(pos); + row.TotalPoints.Should().Be(row.RacePoints); + } + } + + [Fact] + public async Task Calculate_ShouldApplyPoints_BasedOnSortedPosition() + { + var data = GetCalculationData(); + data.ResultRows = GetTestRows(); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.PointRule = CalculationMockHelper.MockPointRule( + sortForPoints: rows => rows.OrderBy(x => x.FinishPosition).ToList(), + getRacePoints: (row, pos) => pos); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().HaveSameCount(data.ResultRows); + test.ResultRows.Select(x => x.FinishPosition).Should() + .BeEquivalentTo(data.ResultRows.Select(x => x.FinishPosition)); + foreach ((var row, var pos) in test.ResultRows.OrderBy(x => x.FinishPosition).Select((x, i) => (x, i + 1))) + { + row.RacePoints.Should().Be(pos); + } + } + + [Fact] + public async Task Calculate_ShouldSortFinal() + { + var data = GetCalculationData(); + data.ResultRows = GetTestRows(); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.PointRule = CalculationMockHelper.MockPointRule( + sortFinal: rows => rows.OrderBy(x => x.FinishPosition).ToList()); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().BeInAscendingOrder(x => x.FinishPosition); + } + + [Fact] + public async Task Calculate_ShouldSetFinalPositionAndChange() + { + var data = GetCalculationData(); + data.ResultRows = GetTestRows(); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var expectedFinalPositions = Enumerable.Range(1, data.ResultRows.Count()); + var expectedFinalPositionChanges = data.ResultRows.Select((x, i) => (int)(x.StartPosition - (i + 1))); + test.ResultRows.Select(x => x.FinalPosition).Should().BeEquivalentTo(expectedFinalPositions); + test.ResultRows.Select(x => x.FinalPositionChange).Should().BeEquivalentTo(expectedFinalPositionChanges); + } + + [Fact] + public async Task Calculate_ShouldSetFastestLap() + { + var data = GetCalculationData(); + var rows = data.ResultRows = GetTestRows(); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var expectedLapRow = rows.MinBy(x => x.FastestLapTime)!; + test.FastestLap.Should().Be(expectedLapRow.FastestLapTime); + test.FastestLapDriverMemberId.Should().Be(expectedLapRow.MemberId); + } + + [Fact] + public async Task Calculate_ShouldSetFastestAvgLap() + { + var data = GetCalculationData(); + var rows = data.ResultRows = GetTestRows(); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var expectedLapRow = rows.MinBy(x => x.AvgLapTime)!; + test.FastestAvgLap.Should().Be(expectedLapRow.AvgLapTime); + test.FastestAvgLapDriverMemberId.Should().Be(expectedLapRow.MemberId); + } + + [Fact] + public async Task Calculate_ShouldSetFastestQualyLap() + { + var data = GetCalculationData(); + var rows = data.ResultRows = GetTestRows(); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var expectedLapRow = rows.MinBy(x => x.QualifyingTime)!; + test.FastestQualyLap.Should().Be(expectedLapRow.QualifyingTime); + test.FastestQualyLapDriverMemberId.Should().Be(expectedLapRow.MemberId); + } + + [Fact] + public async Task Calculate_ShouldSetHardChargers() + { + const int rowCount = 3; + var startPositions = new[] { 3, 2, 5 }.AsEnumerable().GetEnumerator(); + var finishPositions = new[] { 1, 2, 3 }.AsEnumerable().GetEnumerator(); + var data = GetCalculationData(); + var rows = data.ResultRows = TestRowBuilder() + .With(x => x.StartPosition, () => startPositions.Next()) + .With(x => x.FinishPosition, () => finishPositions.Next()) + .CreateMany(rowCount); + var pointRule = CalculationMockHelper.MockPointRule( + sortFinal: rows => rows.OrderBy(x => x.FinishPosition).ToList()); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var expectedHardChargers = new[] { rows.ElementAt(0), rows.ElementAt(2) }.Select(x => x.MemberId); + test.HardChargers.Should().BeEquivalentTo(expectedHardChargers); + } + + [Fact] + public async Task Calculate_ShouldSetCleanestDrivers() + { + const int rowCount = 3; + var incidents = new[] { 1, 2, 1 }.AsEnumerable().GetEnumerator(); + var data = GetCalculationData(); + var rows = data.ResultRows = TestRowBuilder() + .With(x => x.Incidents, () => incidents.Next()) + .CreateMany(rowCount); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var expectedCleanestDrivers = new[] { rows.ElementAt(0), rows.ElementAt(2) }.Select(x => x.MemberId); + test.CleanestDrivers.Should().BeEquivalentTo(expectedCleanestDrivers); + } + + [Fact] + public async Task Calculate_ShoulNotThrow_WhenColumnsHaveDefaultValues() + { + const int rowCount = 3; + var data = GetCalculationData(); + var rows = data.ResultRows = TestRowBuilder() + .OmitAutoProperties() + .With(x => x.MemberId) + .With(x => x.Firstname) + .With(x => x.Lastname) + .CreateMany(rowCount); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = async () => await sut.Calculate(data); + + await test.Should().NotThrowAsync(); + } + + [Fact] + public async Task Calculate_ShouldApplyTimePenaltyToInterval() + { + const int rowCount = 3; + const int spread = 5; + // create fixed intervals to test sorting + var intervals = Enumerable.Range(0, rowCount) + .Select(x => TimeSpan.FromSeconds(x * spread)) + .CreateSequence(); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.Interval, () => intervals()) + .CreateMany(rowCount); + var addPenalty = fixture.Build() + .With(x => x.Type, PenaltyType.Time) + .With(x => x.Time, TimeSpan.FromSeconds(spread + 1)) + .Create(); + var penaltyRow = data.ResultRows.ElementAt(0); + penaltyRow.AddPenalties = new[] { addPenalty }; + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var testResultRow = test.ResultRows.First(x => x.ScoredResultRowId == penaltyRow.ScoredResultRowId); + testResultRow.Interval.Should().Be(penaltyRow.Interval + addPenalty.Time); + } + + [Fact] + public async Task Calculate_ShouldSortAfterApplyingTimePenalty() + { + const int rowCount = 3; + const int spread = 5; + const int penaltyIndex = 1; + // create fixed intervals to test sorting + var intervals = Enumerable.Range(0, rowCount) + .Select(x => TimeSpan.FromSeconds(x * spread)) + .CreateSequence(); + var positions = Enumerable.Range(1, rowCount).CreateSequence(); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.Interval, () => intervals()) + .With(x => x.FinishPosition, () => positions()) + .CreateMany(rowCount); + var addPenalty = fixture.Build() + .With(x => x.Type, PenaltyType.Time) + .With(x => x.Time, TimeSpan.FromSeconds(spread + 1)) + .Create(); + var penaltyRow = data.ResultRows.ElementAt(penaltyIndex); + penaltyRow.AddPenalties = new[] { addPenalty }; + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.PointRule = CalculationMockHelper.MockPointRule( + sortForPoints: x => x.OrderBy(x => x.Interval).ToList()); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var testResultRow = test.ResultRows.First(x => x.ScoredResultRowId == penaltyRow.ScoredResultRowId); + test.ResultRows.ToList().IndexOf(testResultRow).Should().Be(penaltyIndex + 1); + testResultRow.FinalPosition.Should().Be((int)penaltyRow.FinishPosition + 1); + } + + [Theory] + [InlineData(1, 1)] + [InlineData(1, 2)] + [InlineData(3, 3)] + public async Task Calculate_ShouldApplyPositioningPenalty(int penaltyIndex, int positionPenalty) + { + const int rowCount = 5; + // create fixed intervals to test sorting + var positions = Enumerable.Range(1, rowCount).CreateSequence(); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.FinishPosition, () => positions()) + .CreateMany(rowCount); + var addPenalty = fixture.Build() + .With(x => x.Type, PenaltyType.Position) + .With(x => x.Positions, positionPenalty) + .Create(); + var penaltyRow = data.ResultRows.ElementAt(penaltyIndex); + penaltyRow.AddPenalties = new[] { addPenalty }; + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var expIndex = Math.Min(penaltyIndex + positionPenalty, rowCount - 1); + var testResultRow = test.ResultRows.First(x => x.ScoredResultRowId == penaltyRow.ScoredResultRowId); + test.ResultRows.ToList().IndexOf(testResultRow).Should().Be(expIndex); + testResultRow.FinalPosition.Should().Be(expIndex + 1); + } + + [Theory] + [InlineData(0, 2, 2, 2, 1, 3)] + [InlineData(0, 2, 2, 1, 1, 1)] + [InlineData(1, 1, 2, 2, 1, 3)] + public async Task Calculate_ShouldApplyPositioningPenalty_WithMultiple( + int penaltyIndex1, int positionPenalty1, int expIndex1, + int penaltyIndex2, int positionPenalty2, int expIndex2) + { + const int rowCount = 5; + // create fixed intervals to test sorting + var positions = Enumerable.Range(1, rowCount) + .CreateSequence(); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.FinishPosition, () => positions()) + .CreateMany(rowCount); + var addPenalty1 = fixture.Build() + .With(x => x.Type, PenaltyType.Position) + .With(x => x.Positions, positionPenalty1) + .Create(); + var addPenalty2 = fixture.Build() + .With(x => x.Type, PenaltyType.Position) + .With(x => x.Positions, positionPenalty2) + .Create(); + var penaltyRow1 = data.ResultRows.ElementAt(penaltyIndex1); + penaltyRow1.AddPenalties = new[] { addPenalty1 }; + var penaltyRow2 = data.ResultRows.ElementAt(penaltyIndex2); + penaltyRow2.AddPenalties = new[] { addPenalty2 }; + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var testResultRow1 = test.ResultRows.First(x => x.ScoredResultRowId == penaltyRow1.ScoredResultRowId); + var testResultRow2 = test.ResultRows.First(x => x.ScoredResultRowId == penaltyRow2.ScoredResultRowId); + test.ResultRows.ToList().IndexOf(testResultRow1).Should().Be(expIndex1); + testResultRow1.FinalPosition.Should().Be(expIndex1 + 1); + test.ResultRows.ToList().IndexOf(testResultRow2).Should().Be(expIndex2); + testResultRow2.FinalPosition.Should().Be(expIndex2 + 1); + } + + [Fact] + public async Task Calculate_ShouldApplyPointsPenalty() + { + const int rowCount = 3; + const int spread = 5; + const int penaltyIndex = 1; + // create fixed intervals to test sorting + var points = Enumerable.Range(0, rowCount) + .Select(x => (rowCount - x) * spread) + .CreateSequence(); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.RacePoints, () => points()) + .CreateMany(rowCount); + var addPenalty = fixture.Build() + .With(x => x.Type, PenaltyType.Points) + .With(x => x.Points, spread + 1) + .Create(); + var penaltyRow = data.ResultRows.ElementAt(penaltyIndex); + penaltyRow.AddPenalties = new[] { addPenalty }; + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.PointRule = CalculationMockHelper.MockPointRule( + sortFinal: x => x.OrderByDescending(x => x.TotalPoints).ToList()); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var testResultRow = test.ResultRows.First(x => x.ScoredResultRowId == penaltyRow.ScoredResultRowId); + var expIndex = penaltyIndex + 1; + testResultRow.PenaltyPoints.Should().Be(addPenalty.Points); + testResultRow.TotalPoints.Should().Be(testResultRow.RacePoints - testResultRow.PenaltyPoints); + test.ResultRows.ToList().IndexOf(testResultRow).Should().Be(expIndex); + } + + [Fact] + public async Task Calculate_ShouldApplyNegativePointsPenaltyAsBonus() + { + const int rowCount = 3; + const int spread = 5; + const int penaltyIndex = 1; + // create fixed intervals to test sorting + var points = Enumerable.Range(0, rowCount) + .Select(x => (rowCount - x) * spread) + .CreateSequence(); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.RacePoints, () => points()) + .CreateMany(rowCount); + var addPenalty = fixture.Build() + .With(x => x.Type, PenaltyType.Points) + .With(x => x.Points, -(spread + 1)) + .Create(); + var penaltyRow = data.ResultRows.ElementAt(penaltyIndex); + penaltyRow.AddPenalties = new[] { addPenalty }; + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.PointRule = CalculationMockHelper.MockPointRule( + sortFinal: x => x.OrderByDescending(x => x.TotalPoints).ToList()); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var testResultRow = test.ResultRows.First(x => x.ScoredResultRowId == penaltyRow.ScoredResultRowId); + var expIndex = penaltyIndex - 1; + testResultRow.BonusPoints.Should().Be(-addPenalty.Points); + testResultRow.TotalPoints.Should().Be(testResultRow.RacePoints + testResultRow.BonusPoints); + test.ResultRows.ToList().IndexOf(testResultRow).Should().Be(expIndex); + } + + [Fact] + public async Task Calculate_ShouldApplyPositionBonusPoints() + { + var startPositions = new double[] { 3, 2, 1 }.CreateSequence(); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.StartPosition, startPositions) + .CreateMany(3); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.PointRule = CalculationMockHelper.MockPointRule( + bonusPoints: new BonusPointConfiguration[] + { + new() { Type = BonusPointType.QualyPosition, Value = 1, Points = 2 }, + new() { Type = BonusPointType.QualyPosition, Value = 2, Points = 1 }, + }); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().HaveSameCount(data.ResultRows); + var testRow1 = test.ResultRows.ElementAt(2); + var testRow2 = test.ResultRows.ElementAt(1); + testRow1.BonusPoints.Should().Be(2); + testRow2.BonusPoints.Should().Be(1); + } + + [Fact] + public async Task Calculate_ShouldApplyCustomBonusPoints() + { + var startPositions = new double[] { 3, 2, 1 }.CreateSequence(); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.StartPosition, startPositions) + .With(x => x.LeadLaps, 0) + .CreateMany(3); + data.ResultRows.First().LeadLaps = 16; + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + RowFilter condition1 = new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.StartPosition), ComparatorType.IsEqual, new[] { "1" }, + MatchedValueAction.Keep, allowForEach: true); + RowFilter condition2 = new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.StartPosition), ComparatorType.IsEqual, new[] { "2" }, + MatchedValueAction.Keep, allowForEach: true); + RowFilter condition3 = new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.LeadLaps), ComparatorType.ForEach, new[] { "5" }, + MatchedValueAction.Keep, allowForEach: true); + config.PointRule = CalculationMockHelper.MockPointRule( + bonusPoints: new BonusPointConfiguration[] + { + new() { Type = BonusPointType.Custom, Points = 2, Conditions = new(new[] { (FilterCombination.And, condition1) }) }, + new() { Type = BonusPointType.Custom, Points = 1, Conditions = new(new[] { (FilterCombination.And, condition2) }) }, + new() { Type = BonusPointType.Custom, Points = 2, Conditions = new(new[] { (FilterCombination.And, condition3) }) }, + }); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().HaveSameCount(data.ResultRows); + var testRow1 = test.ResultRows.ElementAt(2); + var testRow2 = test.ResultRows.ElementAt(1); + var testRow3 = test.ResultRows.ElementAt(0); + testRow1.BonusPoints.Should().Be(2); + testRow2.BonusPoints.Should().Be(1); + testRow3.BonusPoints.Should().Be(6); + } + + [Fact] + public async Task Calculate_ShouldAddAutoPenalties() + { + var incidents = new[] { 2.0, 4.0, 8.0 }; + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.Incidents, incidents.CreateSequence()) + .CreateMany(incidents.Length); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + RowFilter filter = new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.Incidents), + ComparatorType.ForEach, + new[] { "4.0" }, + MatchedValueAction.Keep, + allowForEach: true); + var autoPenalty = new AutoPenaltyConfigurationData() + { + Conditions = new FilterGroupRowFilter(new[] { (FilterCombination.And, filter) }), + Description = "Test Autopenalty", + Points = 10, + Type = PenaltyType.Points, + }; + config.PointRule = CalculationMockHelper.MockPointRule( + autoPenalties: new[] { autoPenalty }); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var testRow1 = test.ResultRows.ElementAt(1); + testRow1.AddPenalties.Should().HaveCount(1); + testRow1.AddPenalties.First().Points.Should().Be(autoPenalty.Points); + testRow1.PenaltyPoints.Should().Be(autoPenalty.Points); + var testRow2 = test.ResultRows.ElementAt(2); + testRow2.AddPenalties.Should().HaveCount(1); + testRow2.AddPenalties.First().Points.Should().Be(autoPenalty.Points*2); + testRow2.PenaltyPoints.Should().Be(autoPenalty.Points*2); + } + + [Fact] + public async Task Calculate_ShouldApplyResultFilters() + { + var pos = Enumerable.Range(1, 5).Select(x => (double)x); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.FinishPosition, pos.CreateSequence()) + .CreateMany(pos.Count()); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + RowFilter filter = new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.FinishPosition), + ComparatorType.IsSmallerOrEqual, + new[] { "3" }, + MatchedValueAction.Keep); + config.PointRule = CalculationMockHelper.MockPointRule( + resultFilters: new(new[] { (FilterCombination.And, filter) })); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().HaveCount(3); + } + + [Fact] + public async Task Calculate_ShouldApplyChampSeasonFilters() + { + var pos = Enumerable.Range(1, 5).Select(x => (double)x); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.FinishPosition, pos.CreateSequence()) + .CreateMany(pos.Count()); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + RowFilter filter = new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.FinishPosition), + ComparatorType.IsSmallerOrEqual, + new[] { "3" }, + MatchedValueAction.Keep); + config.PointRule = CalculationMockHelper.MockPointRule( + champSeasonFilters: new(new[] { (FilterCombination.And, filter) })); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().HaveCount(3); + } + + [Fact] + public async Task Calculate_ShouldApplyPointFilters() + { + var pos = Enumerable.Range(1, 5).Select(x => (double)x); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.FinishPosition, pos.CreateSequence()) + .CreateMany(pos.Count()); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + RowFilter filter = new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.FinishPosition), + ComparatorType.IsSmallerOrEqual, + new[] { "3" }, + MatchedValueAction.Keep); + config.PointRule = CalculationMockHelper.MockPointRule( + pointFilters: new(new[] { (FilterCombination.And, filter) }), + getRacePoints: (x, p) => 1); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Take(3).Should().Match(x => x.All(r => r.RacePoints == 1)); + test.ResultRows.Skip(3).Should().Match(x => x.None(r => r.RacePoints == 1)); + } + + [Fact] + public async Task Calculate_ShouldSetPointsZero_WhenFiltered() + { + var pos = Enumerable.Range(1, 5).Select(x => (double)x); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.FinishPosition, pos.CreateSequence()) + .With(x => x.RacePoints, 2) + .CreateMany(pos.Count()); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + RowFilter filter = new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.FinishPosition), + ComparatorType.IsSmallerOrEqual, + new[] { "3" }, + MatchedValueAction.Keep); + config.PointRule = CalculationMockHelper.MockPointRule( + pointFilters: new(new[] { (FilterCombination.And, filter) }), + getRacePoints: (x, p) => 1); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Take(3).Should().Match(x => x.All(r => r.RacePoints == 1)); + test.ResultRows.Skip(3).Should().Match(x => x.All(r => r.RacePoints == 0)); + } + + [Fact] + public async Task Calculate_ShouldSetPointsEligible() + { + var pos = Enumerable.Range(1, 5).Select(x => (double)x); + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.FinishPosition, pos.CreateSequence()) + .With(x => x.RacePoints, 2) + .CreateMany(pos.Count()); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + RowFilter filter = new ColumnValueRowFilter( + nameof(ResultRowCalculationResult.FinishPosition), + ComparatorType.IsSmallerOrEqual, + new[] { "3" }, + MatchedValueAction.Keep); + config.PointRule = CalculationMockHelper.MockPointRule( + pointFilters: new(new[] { (FilterCombination.And, filter) }), + getRacePoints: (x, p) => 1); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Take(3).Should().Match(x => x.All(r => r.PointsEligible == true)); + test.ResultRows.Skip(3).Should().Match(x => x.All(r => r.PointsEligible == false)); + } + + [Fact] + public async Task Calculate_ShouldApplyDsqPenalty() + { + const int rowCount = 3; + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .With(x => x.Status, (int)RaceStatus.Running) + .CreateMany(rowCount); + var addPenalty = fixture.Build() + .With(x => x.Type, PenaltyType.Disqualification) + .Create(); + var penaltyRow = data.ResultRows.ElementAt(0); + penaltyRow.AddPenalties = new[] { addPenalty }; + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var testResultRow = test.ResultRows.First(x => x.ScoredResultRowId == penaltyRow.ScoredResultRowId); + testResultRow.Status.Should().Be((int)RaceStatus.Disqualified); + } + + [Fact] + public async Task Calculate_ShouldNotCrashOnEmptyRows() + { + const int rowCount = 0; + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .CreateMany(rowCount); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = async () => await sut.Calculate(data); + + await test.Should().NotThrowAsync(); + } + + private MemberSessionCalculationService CreateSut() + { + return fixture.Create(); + } + + private SessionCalculationData GetCalculationData() + { + return fixture.Create(); + } + + private SessionCalculationConfiguration GetCalculationConfiguration(long leagueId, long? sessionId) + { + return fixture + .Build() + .With(x => x.LeagueId, leagueId) + .With(x => x.SessionId, sessionId) + .With(x => x.IsCombinedResult, false) + .Create(); + } + + private IPostprocessComposer TestRowBuilder() + { + return fixture.Build() + .Without(x => x.RacePoints) + .Without(x => x.BonusPoints) + .Without(x => x.PenaltyPoints) + .Without(x => x.AddPenalties); + } + + private IEnumerable GetTestRows() + { + return TestRowBuilder().CreateMany(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/MemberStandingCalculationServiceTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/MemberStandingCalculationServiceTests.cs new file mode 100644 index 00000000..f235b03b --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/MemberStandingCalculationServiceTests.cs @@ -0,0 +1,299 @@ +using AutoFixture.Dsl; +using DbIntegrationTests; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Mocking.Extensions; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class MemberStandingCalculationServiceTests +{ + private readonly Fixture fixture = new(); + + public static IEnumerable TestSortOptions() + { + yield return new object[] { SortOptions.RacePtsAsc, new Func(x => ((StandingRowCalculationResult)x).RacePoints) }; + yield return new object[] { SortOptions.RacePtsDesc, new Func(x => -((StandingRowCalculationResult)x).RacePoints) }; + yield return new object[] { SortOptions.TotalPtsAsc, new Func(x => ((StandingRowCalculationResult)x).TotalPoints) }; + yield return new object[] { SortOptions.TotalPtsDesc, new Func(x => -((StandingRowCalculationResult)x).TotalPoints) }; + yield return new object[] { SortOptions.PenPtsAsc, new Func(x => ((StandingRowCalculationResult)x).PenaltyPoints) }; + yield return new object[] { SortOptions.PenPtsDesc, new Func(x => -((StandingRowCalculationResult)x).PenaltyPoints) }; + yield return new object[] { SortOptions.IncsAsc, new Func(x => ((StandingRowCalculationResult)x).Incidents) }; + yield return new object[] { SortOptions.IncsDesc, new Func(x => -((StandingRowCalculationResult)x).Incidents) }; + yield return new object[] { SortOptions.LastRaceOrderAsc, new Func(x => ((StandingRowCalculationResult)x).ResultRows.Last().FinalPosition) }; + yield return new object[] { SortOptions.LastRaceOrderDesc, new Func(x => -((StandingRowCalculationResult)x).ResultRows.Last().FinalPosition) }; + yield return new object[] { SortOptions.WinsAsc, new Func(x => ((StandingRowCalculationResult)x).Wins) }; + yield return new object[] { SortOptions.WinsDesc, new Func(x => -((StandingRowCalculationResult)x).Wins) }; + yield return new object[] { SortOptions.Top3Asc, new Func(x => ((StandingRowCalculationResult)x).Top3) }; + yield return new object[] { SortOptions.Top3Desc, new Func(x => -((StandingRowCalculationResult)x).Top3) }; + yield return new object[] { SortOptions.Top5Asc, new Func(x => ((StandingRowCalculationResult)x).Top5) }; + yield return new object[] { SortOptions.Top5Desc, new Func(x => -((StandingRowCalculationResult)x).Top5) }; + yield return new object[] { SortOptions.Top10Asc, new Func(x => ((StandingRowCalculationResult)x).Top10) }; + yield return new object[] { SortOptions.Top10Desc, new Func(x => -((StandingRowCalculationResult)x).Top10) }; + yield return new object[] { SortOptions.RacesAsc, new Func(x => ((StandingRowCalculationResult)x).Races) }; + yield return new object[] { SortOptions.RacesDesc, new Func(x => -((StandingRowCalculationResult)x).Races) }; + yield return new object[] { SortOptions.RacesCountedAsc, new Func(x => ((StandingRowCalculationResult)x).RacesCounted) }; + yield return new object[] { SortOptions.RacesCountedDesc, new Func(x => -((StandingRowCalculationResult)x).RacesCounted) }; + yield return new object[] { SortOptions.RacesScoredAsc, new Func(x => ((StandingRowCalculationResult)x).RacesScored) }; + yield return new object[] { SortOptions.RacesScoredDesc, new Func(x => -((StandingRowCalculationResult)x).RacesScored) }; + yield return new object[] { SortOptions.RacesInPointsAsc, new Func(x => ((StandingRowCalculationResult)x).RacesInPoints) }; + yield return new object[] { SortOptions.RacesInPointsDesc, new Func(x => -((StandingRowCalculationResult)x).RacesInPoints) }; + } + + [Fact] + public async Task Calculate_ShouldNotThrow() + { + var data = GetCalculationData(); + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId).Create(); + var sut = CreateSut(config); + + await sut.Calculate(data); + } + + [Fact] + public async Task Calculate_ShouldAccumulateMemberRows() + { + const int nEvents = 3; + const int nRaces = 2; + var memberId = fixture.Create(); + var testRowData = TestRowBuilder() + .With(x => x.MemberId, memberId) + .With(x => x.PointsEligible, true) + .CreateMany(nEvents * nRaces); + testRowData.TakeLast(2).ForEach(x => x.PointsEligible = false); + testRowData.TakeLast(3).ForEach(x => x.RacePoints = x.BonusPoints = 0); + var data = CalculationDataBuilder(3, 2, true).Create(); + var tmp = data.PreviousEventResults.SelectMany(x => x.SessionResults).Concat(data.CurrentEventResult.SessionResults) + .Zip(testRowData); + foreach (var (result, rowData) in tmp) + { + result.ResultRows = result.ResultRows.Concat(new[] { rowData }); + } + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId) + .With(x => x.ResultKind, Common.Enums.ResultKind.Member) + .With(x => x.UseCombinedResult, false) + .With(x => x.WeeksCounted, nEvents) + .Create(); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + test.StandingRows.Should().ContainSingle(x => x.MemberId == memberId); + var testRow = test.StandingRows.Single(x => x.MemberId == memberId); + var lastResultRowData = testRowData.TakeLast(2); + testRow.Wins.Should().Be(testRowData.Sum(x => x.FinalPosition == 1 ? 1 : 0)); + testRow.RacePoints.Should().Be((int)testRowData.Sum(x => x.RacePoints + x.BonusPoints)); + testRow.TotalPoints.Should().Be((int)testRowData.Sum(x => x.RacePoints + x.BonusPoints - x.PenaltyPoints)); + testRow.CompletedLaps.Should().Be((int)testRowData.Sum(x => x.CompletedLaps)); + testRow.CompletedLapsChange.Should().Be((int)lastResultRowData.Sum(x => x.CompletedLaps)); + testRow.DroppedResultCount.Should().Be(0); + testRow.Incidents.Should().Be((int)testRowData.Sum(x => x.Incidents)); + testRow.IncidentsChange.Should().Be((int)lastResultRowData.Sum(x => x.Incidents)); + testRow.LeadLaps.Should().Be((int)testRowData.Sum(x => x.LeadLaps)); + testRow.LeadLapsChange.Should().Be((int)lastResultRowData.Sum(x => x.LeadLaps)); + testRow.PenaltyPoints.Should().Be((int)testRowData.Sum(x => x.PenaltyPoints)); + testRow.PenaltyPointsChange.Should().Be((int)lastResultRowData.Sum(x => x.PenaltyPoints)); + testRow.PolePositions.Should().Be(testRowData.Count(x => x.StartPosition == 1)); + testRow.PolePositionsChange.Should().Be(lastResultRowData.Count(x => x.StartPosition == 1)); + testRow.Races.Should().Be(testRowData.Count()); + testRow.RacesCounted.Should().Be(testRowData.Count()); + testRow.Top10.Should().Be(testRowData.Count(x => x.FinalPosition <= 10)); + testRow.Top5.Should().Be(testRowData.Count(x => x.FinalPosition <= 5)); + testRow.Top3.Should().Be(testRowData.Count(x => x.FinalPosition <= 3)); + testRow.RacesScored.Should().Be(testRowData.Count() - 2); + testRow.RacesInPoints.Should().Be(testRowData.Count() - 3); + } + + [Fact] + public async Task Calculate_ShouldOnlyUseLastSessionResult_WhenCombinedResultConfigure() + { + const int nEvents = 3; + const int nRaces = 2; + var memberId = fixture.Create(); + var testRowData = TestRowBuilder() + .With(x => x.MemberId, memberId) + .CreateMany(nEvents * (nRaces + 1)); + var data = CalculationDataBuilder(nEvents, nRaces + 1, false).Create(); + var tmp = data.PreviousEventResults.SelectMany(x => x.SessionResults.OrderBy(x => x.SessionNr)).Concat(data.CurrentEventResult.SessionResults.OrderBy(x => x.SessionNr)) + .Zip(testRowData); + foreach (var (result, rowData) in tmp) + { + //result.ResultRows = result.ResultRows.Concat(new[] { rowData }); + result.ResultRows = new[] { rowData }; + } + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId) + .With(x => x.ResultKind, Common.Enums.ResultKind.Member) + .With(x => x.UseCombinedResult, true) + .With(x => x.WeeksCounted, nEvents) + .Create(); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + test.StandingRows.Should().ContainSingle(x => x.MemberId == memberId); + var testRow = test.StandingRows.Single(x => x.MemberId == memberId); + var combinedResultRowData = testRowData.Chunk(3).Select(x => x.Last()).ToList(); + var lastResultRowData = combinedResultRowData.TakeLast(1); + testRow.Wins.Should().Be(combinedResultRowData.Sum(x => x.FinalPosition == 1 ? 1 : 0)); + testRow.RacePoints.Should().Be((int)combinedResultRowData.Sum(x => x.RacePoints + x.BonusPoints)); + testRow.TotalPoints.Should().Be((int)combinedResultRowData.Sum(x => x.RacePoints + x.BonusPoints - x.PenaltyPoints)); + testRow.CompletedLaps.Should().Be((int)combinedResultRowData.Sum(x => x.CompletedLaps)); + testRow.CompletedLapsChange.Should().Be((int)lastResultRowData.Sum(x => x.CompletedLaps)); + testRow.DroppedResultCount.Should().Be(0); + testRow.Incidents.Should().Be((int)combinedResultRowData.Sum(x => x.Incidents)); + testRow.IncidentsChange.Should().Be((int)lastResultRowData.Sum(x => x.Incidents)); + testRow.LeadLaps.Should().Be((int)combinedResultRowData.Sum(x => x.LeadLaps)); + testRow.LeadLapsChange.Should().Be((int)lastResultRowData.Sum(x => x.LeadLaps)); + testRow.PenaltyPoints.Should().Be((int)combinedResultRowData.Sum(x => x.PenaltyPoints)); + testRow.PenaltyPointsChange.Should().Be((int)lastResultRowData.Sum(x => x.PenaltyPoints)); + testRow.PolePositions.Should().Be(combinedResultRowData.Count(x => x.StartPosition == 1)); + testRow.PolePositionsChange.Should().Be(lastResultRowData.Count(x => x.StartPosition == 1)); + testRow.Races.Should().Be(combinedResultRowData.Count()); + testRow.RacesCounted.Should().Be(combinedResultRowData.Count()); + testRow.Top10.Should().Be(combinedResultRowData.Count(x => x.FinalPosition <= 10)); + testRow.Top5.Should().Be(combinedResultRowData.Count(x => x.FinalPosition <= 5)); + testRow.Top3.Should().Be(combinedResultRowData.Count(x => x.FinalPosition <= 3)); + } + + [Fact] + public async Task Calculate_ShouldAssignPositions_ByTotalPointsAndPenaltyPoints() + { + var nEvents = 3; + var nRaces = 1; + var data = CalculationDataBuilder(nEvents, nRaces, false).Create(); + // make sure two rows have same total points + var racePoints = fixture.Create(); + var bonusPoints = fixture.Create(); + var penaltyPoints = fixture.Create(); + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(0).RacePoints = racePoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(1).RacePoints = racePoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(0).BonusPoints = bonusPoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(1).BonusPoints = bonusPoints + penaltyPoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(0).PenaltyPoints = 0.0; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(1).PenaltyPoints = penaltyPoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(0).TotalPoints = racePoints + bonusPoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(1).TotalPoints = racePoints + bonusPoints - penaltyPoints; + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId) + .With(x => x.ResultKind, ResultKind.Member) + .With(x => x.WeeksCounted, nEvents) + .With(x => x.SortOptions, new[] + { + SortOptions.TotalPtsDesc, + SortOptions.PenPtsAsc, + }) + .Create(); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + var testOrder = test.StandingRows + .OrderByDescending(x => x.TotalPoints) + .ThenBy(x => x.PenaltyPoints); + var positions = Enumerable.Range(1, testOrder.Count()); + testOrder.Should().BeInAscendingOrder(x => x.Position); + testOrder.Select(x => x.Position).Should().BeEquivalentTo(positions); + test.StandingRows.Should().BeEquivalentTo(testOrder); + } + + [Theory] + [MemberData(nameof(TestSortOptions))] + public async Task Calculate_ShouldAssignPositions_BySortOption(SortOptions sortOption, Func testSortFunc) + { + var nEvents = 3; + var nRaces = 1; + var data = CalculationDataBuilder(nEvents, nRaces, false).Create(); + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId) + .With(x => x.ResultKind, ResultKind.Member) + .With(x => x.WeeksCounted, nEvents) + .With(x => x.SortOptions, new[] + { + sortOption, + }) + .Create(); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + var testOrder = test.StandingRows + .OrderBy(x => testSortFunc(x)); + var positions = Enumerable.Range(1, testOrder.Count()); + testOrder.Should().BeInAscendingOrder(x => x.Position); + testOrder.Select(x => x.Position).Should().BeEquivalentTo(positions); + test.StandingRows.Should().BeEquivalentTo(testOrder); + } + + [Fact] + public async Task Calculate_ShouldSetChampSeasonId() + { + var data = GetCalculationData(); + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId).Create(); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + test.ChampSeasonId.Should().Be(config.ChampSeasonId); + } + + private MemberStandingCalculationService CreateSut(StandingCalculationConfiguration config) + { + if (config != null) + { + fixture.Register(() => config); + } + return fixture.Create(); + } + + private StandingCalculationData GetCalculationData() + { + return CalculationDataBuilder().Create(); + } + + private IPostprocessComposer CalculationDataBuilder(int nEvents = 3, int nRacesPerEvent = 3, bool hasCombinedResult = false) + { + var memberIds = fixture.CreateMany(10); + return fixture.Build() + .With(x => x.PreviousEventResults, () => EventResultDataBuilder(memberIds, nRacesPerEvent, hasCombinedResult).CreateMany(nEvents - 1).ToList()) + .With(x => x.CurrentEventResult, () => EventResultDataBuilder(memberIds, nRacesPerEvent, hasCombinedResult).Create()); + } + + private IPostprocessComposer EventResultDataBuilder(IEnumerable memberIds, int nRaces = 2, bool hasCombinedResult = false) + { + return fixture.Build() + .With(x => x.SessionResults, () => SessionResultDataBuilder(memberIds).CreateMany(nRaces)); + } + + private IPostprocessComposer SessionResultDataBuilder(IEnumerable memberIds) + { + var getMemberIds = memberIds.ToList(); + return fixture + .Build() + .With(x => x.ResultRows, fixture.Build() + .With(x => x.MemberId, () => getMemberIds.PopRandom()) + .CreateMany(memberIds.Count() - 1) + ); + } + + private IPostprocessComposer CalculationConfigurationBuilder(long leagueId, long eventId, + ChampSeasonEntity? champSeason = null) + { + return fixture.Build() + .With(x => x.LeagueId, leagueId) + .With(x => x.EventId, eventId) + .With(x => x.ResultConfigs, champSeason?.ResultConfigurations.Select(x => x.ResultConfigId) ?? Array.Empty()); + } + + private IPostprocessComposer TestRowBuilder() + { + return fixture.Build() + .Without(x => x.AddPenalties) + .Do(x => { x.TotalPoints = x.RacePoints + x.BonusPoints - x.PenaltyPoints; }); + } + + private IEnumerable GetTestRows() + { + return TestRowBuilder().CreateMany(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/SessionCalculationServiceProviderTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/SessionCalculationServiceProviderTests.cs new file mode 100644 index 00000000..d0637567 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/SessionCalculationServiceProviderTests.cs @@ -0,0 +1,49 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Models; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class SessionCalculationServiceProviderTests +{ + private readonly Fixture fixture; + + public SessionCalculationServiceProviderTests() + { + fixture = new(); + } + + [Fact] + public void GetCalculationService_ShouldProvideMemberCalculationService_WhenScoringKindIsMember() + { + var config = GetCalculationConfiguration(); + config.ResultKind = ResultKind.Member; + var sut = CreateSut(); + + var test = sut.GetCalculationService(config); + + test.Should().BeOfType(); + } + + [Fact] + public void GetCalculationService_ShouldProvideTeamCalculationService_WhenScoringKindIsTeam() + { + var config = GetCalculationConfiguration(); + config.ResultKind = ResultKind.Team; + var sut = CreateSut(); + + var test = sut.GetCalculationService(config); + + test.Should().BeOfType(); + } + + private SessionCalculationServiceProvider CreateSut() + { + return fixture.Create(); + } + + private SessionCalculationConfiguration GetCalculationConfiguration() + { + return fixture.Create(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/TeamSessionCalculationServiceTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/TeamSessionCalculationServiceTests.cs new file mode 100644 index 00000000..17d9ac98 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/TeamSessionCalculationServiceTests.cs @@ -0,0 +1,310 @@ +using AutoFixture.Dsl; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueApiCore.Mocking.Extensions; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class TeamSessionCalculationServiceTests +{ + private readonly Fixture fixture = new(); + + [Fact] + public async Task Calculate_ShouldSetResultMetaData() + { + var data = GetCalculationData(); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.LeagueId.Should().Be(config.LeagueId); + test.Name.Should().Be(config.Name); + test.SessionId.Should().Be(config.SessionId); + test.SessionResultId.Should().Be(config.SessionResultId); + } + + [Theory] + [InlineData(1)] + [InlineData(2)] + [InlineData(4)] + public async Task Calculate_ShouldGroupTeams_WithMaxNrOfRows(int groupRowCount) + { + var teamCount = 3; + var teamIds = fixture.CreateMany(teamCount).Concat(new[] { default(long?) }); + var rowsPerTeam = 3; + var data = GetCalculationData(); + data.ResultRows = GetTestRows(teamIds, rowsPerTeam); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.MaxResultsPerGroup = groupRowCount; + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().HaveCount(teamCount); + foreach (var teamRow in test.ResultRows) + { + teamRow.ScoredMemberResultRowIds.Should().HaveCount(Math.Min(rowsPerTeam, groupRowCount)); + teamRow.ScoredMemberResultRowIds.OrderBy(x => x).Should() + .BeEquivalentTo(data.ResultRows + .Where(x => x.TeamId == teamRow.TeamId) + .OrderBy(x => x.FinalPosition) + .Take(groupRowCount) + .Select(x => x.ScoredResultRowId) + .OrderBy(x => x) + ); + } + } + + [Fact] + public async Task Calculate_ShouldAccumulateTeamResultData() + { + var groupRowCount = 3; + var teamCount = 3; + var teamIds = fixture.CreateMany(teamCount); + var rowsPerTeam = 5; + var data = GetCalculationData(); + data.ResultRows = GetTestRows(teamIds, rowsPerTeam); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.MaxResultsPerGroup = groupRowCount; + config.PointRule = CalculationMockHelper.MockPointRule(); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().HaveCount(teamCount); + foreach (var teamRow in test.ResultRows) + { + var memberRows = data.ResultRows + .Where(x => x.TeamId == teamRow.TeamId) + .OrderBy(x => x.FinalPosition) + .Take(groupRowCount); + teamRow.AvgLapTime.Should().BeCloseTo(TimeSpan.FromSeconds(memberRows.Sum(x => x.AvgLapTime.TotalSeconds * x.CompletedLaps) / memberRows.Sum(x => x.CompletedLaps)), TimeSpan.FromMilliseconds(1)); + teamRow.BonusPoints.Should().Be(0); + teamRow.CompletedLaps.Should().Be(memberRows.Sum(x => x.CompletedLaps)); + teamRow.FastestLapTime.Should().Be(memberRows.Min(x => x.FastestLapTime)); + teamRow.MemberId.Should().BeNull(); + teamRow.Firstname.Should().BeEmpty(); + teamRow.Lastname.Should().BeEmpty(); + teamRow.Incidents.Should().Be(memberRows.Sum(x => x.Incidents)); + teamRow.Interval.Should().BeCloseTo(TimeSpan.FromSeconds(memberRows.Sum(x => x.Interval.TotalSeconds)), TimeSpan.FromMilliseconds(1)); + teamRow.LeadLaps.Should().Be(memberRows.Sum(x => x.LeadLaps)); + teamRow.PenaltyPoints.Should().Be(memberRows.Sum(x => x.PenaltyPoints)); + teamRow.QualifyingTime.Should().Be(memberRows.Min(x => x.QualifyingTime)); + teamRow.RacePoints.Should().Be(memberRows.Sum(x => x.RacePoints + x.BonusPoints)); + } + } + + [Fact] + public async Task Calculate_ShouldCalculateTotalPoints() + { + var groupRowCount = 3; + var teamCount = 3; + var teamIds = fixture.CreateMany(teamCount); + var rowsPerTeam = 5; + var data = GetCalculationData(); + data.ResultRows = GetTestRows(teamIds, rowsPerTeam); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.PointRule = CalculationMockHelper.MockPointRule(); + config.MaxResultsPerGroup = groupRowCount; + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + foreach (var row in test.ResultRows) + { + row.TotalPoints.Should().Be(row.RacePoints + row.BonusPoints - row.PenaltyPoints); + } + } + + [Fact] + public async Task Calculate_ShouldSortFinal() + { + var teamCount = 3; + var teamIds = fixture.CreateMany(teamCount); + var rowsPerTeam = 5; + var data = GetCalculationData(); + data.ResultRows = GetTestRows(teamIds, rowsPerTeam); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.PointRule = CalculationMockHelper.MockPointRule( + sortFinal: rows => rows.OrderBy(x => x.TotalPoints).ToList()); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + test.ResultRows.Should().BeInAscendingOrder(x => x.TotalPoints); + } + + [Fact] + public async Task Calculate_ShouldSetFinalPosition() + { + var teamCount = 3; + var teamIds = fixture.CreateMany(teamCount); + var rowsPerTeam = 5; + var data = GetCalculationData(); + data.ResultRows = GetTestRows(teamIds, rowsPerTeam); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var expectedFinalPositions = Enumerable.Range(1, teamCount); + test.ResultRows.Select(x => x.FinalPosition).Should().BeEquivalentTo(expectedFinalPositions); + } + + [Theory] + [InlineData(PenaltyType.Points)] + [InlineData(PenaltyType.Time)] + [InlineData(PenaltyType.Position)] + [InlineData(PenaltyType.Disqualification)] + public async Task Calculate_ShouldApplyTeamPenalties(PenaltyType penaltyType) + { + var groupRowCount = 3; + var teamCount = 3; + var teamIds = fixture.CreateMany(teamCount); + var rowsPerTeam = 3; + var data = GetCalculationData(); + data.ResultRows = GetTestRows(teamIds, rowsPerTeam); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.MaxResultsPerGroup = groupRowCount; + config.PointRule = CalculationMockHelper.MockPointRule( + sortForPoints: x => x.OrderBy(x => x.TeamId).ToList()); + + var testTeamId = teamIds.OrderBy(x => x).First(); + var testTeamRows = data.ResultRows.Where(x => x.TeamId == testTeamId).ToList(); + testTeamRows.ForEach(x => x.PenaltyPoints = 0); + var penalty = new AddPenaltyCalculationData() + { + TeamId = testTeamId, + Type = penaltyType, + Points = 3, + Time = TimeSpan.FromSeconds(3), + Positions = 1, + }; + testTeamRows.ForEach(x => x.AddPenalties = new[] { penalty }); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var testRow = test.ResultRows.Single(x => x.TeamId == testTeamId); + + switch (penaltyType) + { + case PenaltyType.Points: + testRow.PenaltyPoints.Should().Be(penalty.Points); + testRow.TotalPoints.Should().Be(testRow.RacePoints + testRow.BonusPoints - testRow.PenaltyPoints); + break; + case PenaltyType.Time: + var interval = TimeSpan.FromSeconds(testTeamRows.Sum(x => x.Interval.TotalSeconds)); + testRow.Interval.Should().BeCloseTo(interval + penalty.Time, TimeSpan.FromSeconds(0.001)); + break; + case PenaltyType.Position: + var position = test.ResultRows.OrderBy(x => x.TeamId).ToList().IndexOf(testRow) + 1; + testRow.FinalPosition.Should().Be(position + penalty.Positions); + break; + case PenaltyType.Disqualification: + testRow.Status.Should().Be((int)RaceStatus.Disqualified); + break; + default: + break; + } + } + + [Fact] + public async Task Calculate_ShouldApplyReviewPenalty() + { + var groupRowCount = 3; + var teamCount = 3; + var teamIds = fixture.CreateMany(teamCount); + var rowsPerTeam = 3; + var data = GetCalculationData(); + data.ResultRows = GetTestRows(teamIds, rowsPerTeam); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + config.MaxResultsPerGroup = groupRowCount; + config.PointRule = CalculationMockHelper.MockPointRule( + sortFinal: x => x.OrderBy(x => x.TeamId).ToList()); + + var testTeamId = teamIds.OrderBy(x => x).First(); + var testTeamRows = data.ResultRows.Where(x => x.TeamId == testTeamId).ToList(); + testTeamRows.ForEach(x => x.PenaltyPoints = 0); + var voteData = new AcceptedReviewVoteCalculationData() + { + TeamAtFaultId = testTeamId, + DefaultPenalty = 3, + }; + data.AcceptedReviewVotes = new[] { voteData }; + + fixture.Register(() => config); + var sut = CreateSut(); + + var test = await sut.Calculate(data); + + var testRow = test.ResultRows.Single(x => x.TeamId == testTeamId); + + testRow.PenaltyPoints.Should().Be(voteData.DefaultPenalty); + testRow.TotalPoints.Should().Be(testRow.RacePoints + testRow.BonusPoints - testRow.PenaltyPoints); + } + + [Fact] + public async Task Calculate_ShouldNotCrashOnEmptyRows() + { + const int rowCount = 0; + var data = GetCalculationData(); + data.ResultRows = TestRowBuilder() + .CreateMany(rowCount); + var config = GetCalculationConfiguration(data.LeagueId, data.SessionId); + fixture.Register(() => config); + var sut = CreateSut(); + + var test = async () => await sut.Calculate(data); + + await test.Should().NotThrowAsync(); + } + + private TeamSessionCalculationService CreateSut() + { + return fixture.Create(); + } + + private SessionCalculationData GetCalculationData() + { + return fixture.Create(); + } + + private SessionCalculationConfiguration GetCalculationConfiguration(long leagueId, long? sessionId) + { + return fixture + .Build() + .With(x => x.LeagueId, leagueId) + .With(x => x.SessionId, sessionId) + .With(x => x.ResultKind, ResultKind.Team) + .Create(); + } + + private IPostprocessComposer TestRowBuilder() + { + return fixture.Build() + .Without(x => x.AddPenalties); + } + + private IPostprocessComposer TeamTestRowBuilder(IEnumerable teamIds) + { + var idSequence = teamIds.CreateSequence(); + return TestRowBuilder() + .With(x => x.TeamId, () => idSequence()); + } + + private IEnumerable GetTestRows(IEnumerable teamIds, int rowsPerTeam) + { + return TeamTestRowBuilder(teamIds) + .CreateMany(teamIds.Count() * rowsPerTeam); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/TeamStandingsCalculationTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/TeamStandingsCalculationTests.cs new file mode 100644 index 00000000..bd794a2f --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Calculation/TeamStandingsCalculationTests.cs @@ -0,0 +1,221 @@ +using AutoFixture.Dsl; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using System.Diagnostics; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Calculation; + +public sealed class TeamStandingCalculationServiceTests +{ + private readonly Fixture fixture = new(); + + [Fact] + public async Task Calculate_ShouldNotThrow() + { + var data = GetCalculationData(); + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId).Create(); + var sut = CreateSut(config); + + await sut.Calculate(data); + } + + [Fact] + public async Task Calculate_ShouldAccumulateTeamRows() + { + const int nEvents = 3; + const int nRaces = 2; + var teamId = fixture.Create(); + var testRowData = TestRowBuilder() + .With(x => x.TeamId, teamId) + .CreateMany(nEvents * nRaces); + var data = CalculationDataBuilder(nEvents, nRaces, true).Create(); + var tmp = data.PreviousEventResults.SelectMany(x => x.SessionResults).Concat(data.CurrentEventResult.SessionResults) + .Zip(testRowData); + Debug.Assert(tmp.None(x => x.First.ResultRows.Any(y => y.TeamId == teamId))); + foreach (var (result, rowData) in tmp) + { + //result.ResultRows = result.ResultRows.Concat(new[] { rowData }); + result.ResultRows = new[] { rowData }; + } + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId) + .With(x => x.ResultKind, Common.Enums.ResultKind.Team) + .With(x => x.UseCombinedResult, false) + .With(x => x.WeeksCounted, nEvents) + .Create(); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + test.StandingRows.Should().ContainSingle(x => x.TeamId == teamId); + var testRow = test.StandingRows.Single(x => x.TeamId == teamId); + var lastResultRowData = testRowData.TakeLast(2); + testRow.MemberId.Should().BeNull(); + testRow.Wins.Should().Be(testRowData.Sum(x => x.FinalPosition == 1 ? 1 : 0)); + testRow.RacePoints.Should().Be((int)testRowData.Sum(x => x.RacePoints + x.BonusPoints)); + testRow.TotalPoints.Should().Be((int)testRowData.Sum(x => x.RacePoints + x.BonusPoints - x.PenaltyPoints)); + testRow.CompletedLaps.Should().Be((int)testRowData.Sum(x => x.CompletedLaps)); + testRow.CompletedLapsChange.Should().Be((int)lastResultRowData.Sum(x => x.CompletedLaps)); + testRow.DroppedResultCount.Should().Be(0); + testRow.Incidents.Should().Be((int)testRowData.Sum(x => x.Incidents)); + testRow.IncidentsChange.Should().Be((int)lastResultRowData.Sum(x => x.Incidents)); + testRow.LeadLaps.Should().Be((int)testRowData.Sum(x => x.LeadLaps)); + testRow.LeadLapsChange.Should().Be((int)lastResultRowData.Sum(x => x.LeadLaps)); + testRow.PenaltyPoints.Should().Be((int)testRowData.Sum(x => x.PenaltyPoints)); + testRow.PenaltyPointsChange.Should().Be((int)lastResultRowData.Sum(x => x.PenaltyPoints)); + testRow.PolePositions.Should().Be(testRowData.Count(x => x.StartPosition == 1)); + testRow.PolePositionsChange.Should().Be(lastResultRowData.Count(x => x.StartPosition == 1)); + testRow.Races.Should().Be(testRowData.Count()); + testRow.RacesCounted.Should().Be(testRowData.Count()); + testRow.Top10.Should().Be(testRowData.Count(x => x.FinalPosition <= 10)); + testRow.Top5.Should().Be(testRowData.Count(x => x.FinalPosition <= 5)); + testRow.Top3.Should().Be(testRowData.Count(x => x.FinalPosition <= 3)); + } + + [Fact] + public async Task Calculate_ShouldOnlyUseLastSessionResult_WhenCombinedResultConfigure() + { + const int nEvents = 3; + const int nRaces = 2; + var teamId = fixture.Create(); + var testRowData = TestRowBuilder() + .With(x => x.TeamId, teamId) + .CreateMany(nEvents * (nRaces + 1)); + var data = CalculationDataBuilder(nEvents, nRaces + 1, false).Create(); + var tmp = data.PreviousEventResults.SelectMany(x => x.SessionResults.OrderBy(x => x.SessionNr)).Concat(data.CurrentEventResult.SessionResults.OrderBy(x => x.SessionNr)) + .Zip(testRowData); + foreach (var (result, rowData) in tmp) + { + //result.ResultRows = result.ResultRows.Concat(new[] { rowData }); + result.ResultRows = new[] { rowData }; + } + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId) + .With(x => x.ResultKind, Common.Enums.ResultKind.Team) + .With(x => x.UseCombinedResult, true) + .With(x => x.WeeksCounted, nEvents) + .Create(); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + test.StandingRows.Should().ContainSingle(x => x.TeamId == teamId); + var testRow = test.StandingRows.Single(x => x.TeamId == teamId); + var combinedResultRowData = testRowData.Chunk(3).Select(x => x.Last()).ToList(); + var lastResultRowData = combinedResultRowData.TakeLast(1); + testRow.Wins.Should().Be(combinedResultRowData.Sum(x => x.FinalPosition == 1 ? 1 : 0)); + testRow.RacePoints.Should().Be((int)combinedResultRowData.Sum(x => x.RacePoints + x.BonusPoints)); + testRow.TotalPoints.Should().Be((int)combinedResultRowData.Sum(x => x.RacePoints + x.BonusPoints - x.PenaltyPoints)); + testRow.CompletedLaps.Should().Be((int)combinedResultRowData.Sum(x => x.CompletedLaps)); + testRow.CompletedLapsChange.Should().Be((int)lastResultRowData.Sum(x => x.CompletedLaps)); + testRow.DroppedResultCount.Should().Be(0); + testRow.Incidents.Should().Be((int)combinedResultRowData.Sum(x => x.Incidents)); + testRow.IncidentsChange.Should().Be((int)lastResultRowData.Sum(x => x.Incidents)); + testRow.LeadLaps.Should().Be((int)combinedResultRowData.Sum(x => x.LeadLaps)); + testRow.LeadLapsChange.Should().Be((int)lastResultRowData.Sum(x => x.LeadLaps)); + testRow.PenaltyPoints.Should().Be((int)combinedResultRowData.Sum(x => x.PenaltyPoints)); + testRow.PenaltyPointsChange.Should().Be((int)lastResultRowData.Sum(x => x.PenaltyPoints)); + testRow.PolePositions.Should().Be(combinedResultRowData.Count(x => x.StartPosition == 1)); + testRow.PolePositionsChange.Should().Be(lastResultRowData.Count(x => x.StartPosition == 1)); + testRow.Races.Should().Be(combinedResultRowData.Count()); + testRow.RacesCounted.Should().Be(combinedResultRowData.Count()); + testRow.Top10.Should().Be(combinedResultRowData.Count(x => x.FinalPosition <= 10)); + testRow.Top5.Should().Be(combinedResultRowData.Count(x => x.FinalPosition <= 5)); + testRow.Top3.Should().Be(combinedResultRowData.Count(x => x.FinalPosition <= 3)); + } + + [Fact] + public async Task Calculate_ShouldAssignPositions_ByTotalPointsAndPenaltyPoints() + { + var nEvents = 3; + var nRaces = 1; + var data = CalculationDataBuilder(nEvents, nRaces, false).Create(); + // make sure two rows have same total points + var racePoints = fixture.Create(); + var bonusPoints = fixture.Create(); + var penaltyPoints = fixture.Create(); + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(0).RacePoints = racePoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(1).RacePoints = racePoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(0).BonusPoints = bonusPoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(1).BonusPoints = bonusPoints + penaltyPoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(0).PenaltyPoints = 0.0; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(1).PenaltyPoints = penaltyPoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(0).TotalPoints = racePoints + bonusPoints; + data.CurrentEventResult.SessionResults.First().ResultRows.ElementAt(1).TotalPoints = racePoints + bonusPoints - penaltyPoints; + var config = CalculationConfigurationBuilder(data.LeagueId, data.EventId) + .With(x => x.ResultKind, ResultKind.Member) + .With(x => x.WeeksCounted, nEvents) + .With(x => x.SortOptions, new[] + { + SortOptions.TotalPtsDesc, + SortOptions.PenPtsAsc, + }) + .Create(); + var sut = CreateSut(config); + + var test = await sut.Calculate(data); + + var testOrder = test.StandingRows + .OrderByDescending(x => x.TotalPoints) + .ThenBy(x => x.PenaltyPoints); + var positions = Enumerable.Range(1, testOrder.Count()); + testOrder.Should().BeInAscendingOrder(x => x.Position); + testOrder.Select(x => x.Position).Should().BeEquivalentTo(positions); + test.StandingRows.Should().BeEquivalentTo(testOrder); + } + + private TeamStandingCalculationService CreateSut(StandingCalculationConfiguration config) + { + if (config != null) + { + fixture.Register(() => config); + } + return fixture.Create(); + } + + private StandingCalculationData GetCalculationData() + { + return fixture.Create(); + } + + private IPostprocessComposer CalculationDataBuilder(int nEvents = 3, int nRacesPerEvent = 3, bool hasCombinedResult = false) + { + return fixture.Build() + .With(x => x.PreviousEventResults, () => EventResultDataBuilder(nRacesPerEvent, hasCombinedResult).CreateMany(nEvents - 1).ToList()) + .With(x => x.CurrentEventResult, () => EventResultDataBuilder(nRacesPerEvent, hasCombinedResult).Create()); + } + + private IPostprocessComposer EventResultDataBuilder(int nRaces = 2, bool hasCombinedResult = false) + { + return fixture.Build() + .With(x => x.SessionResults, () => SessionResultDataBuilder().CreateMany(nRaces)); + } + + private IPostprocessComposer SessionResultDataBuilder() + { + return fixture.Build(); + } + + private IPostprocessComposer CalculationConfigurationBuilder(long leagueId, long eventId, + ChampSeasonEntity? champSeason = null) + { + return fixture.Build() + .With(x => x.LeagueId, leagueId) + .With(x => x.EventId, eventId) + .With(x => x.ResultConfigs, champSeason?.ResultConfigurations.Select(x => x.ResultConfigId) ?? Array.Empty()); + } + + private IPostprocessComposer TestRowBuilder() + { + return fixture.Build() + .Without(x => x.AddPenalties) + .Do(x => { x.TotalPoints = x.RacePoints + x.BonusPoints - x.PenaltyPoints; }); + } + + private IEnumerable GetTestRows() + { + return TestRowBuilder().CreateMany(); + } +} + diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/DataAccessMockHelperTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/DataAccessMockHelperTests.cs new file mode 100644 index 00000000..f5474df2 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/DataAccessMockHelperTests.cs @@ -0,0 +1,173 @@ +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Services.ResultService.Extensions; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.Tests.ResultService.DataAccess; + +public sealed class DataAccessMockHelperTests : IAsyncLifetime +{ + private readonly string databaseName = Guid.NewGuid().ToString(); + private readonly DataAccessMockHelper accessMockHelper = new(); + + [Fact] + public async Task PopulateBasicTestsSet_ShouldNotThrow() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + await accessMockHelper.PopulateBasicTestSet(dbContext); + } + + [Fact] + public async Task PopulateBasicTestSet_ShouldNotLoseDataBetweenContexts() + { + using (var dbContext = accessMockHelper.CreateMockDbContext(databaseName)) + { + await accessMockHelper.PopulateBasicTestSet(dbContext); + } + + using (var dbContext = accessMockHelper.CreateMockDbContext(databaseName)) + { + dbContext.Leagues.Should().HaveCount(2); + } + } + + [Fact] + public async Task PopulateBasicTestSet_ShouldHaveCorrectNavigationProperties() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + await accessMockHelper.PopulateBasicTestSet(dbContext); + accessMockHelper.SetCurrentLeague(await dbContext.Leagues.FirstAsync()); + + var session = await dbContext.Sessions + .Include(x => x.Event) + .FirstAsync(); + var @event = session.Event; + + session.Event.Should().NotBeNull(); + @event.Sessions.Should().Contain(session); + } + + [Fact] + public async Task PopulateBasicTestSet_EventsShouldHaveRawResults() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + await accessMockHelper.PopulateBasicTestSet(dbContext); + accessMockHelper.SetCurrentLeague(await dbContext.Leagues.FirstAsync()); + + var events = await dbContext.Events + .Include(x => x.EventResult) + .ToListAsync(); + + foreach (var @event in events) + { + @event.EventResult.Should().NotBeNull(); + } + } + + [Fact] + public async Task PopulateBasicTestSet_SomeLeagueMembersShouldHaveTeam() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + await accessMockHelper.PopulateBasicTestSet(dbContext); + accessMockHelper.SetCurrentLeague(await dbContext.Leagues.FirstAsync()); + + var leagueMembers = await dbContext.LeagueMembers + .Include(x => x.Team) + .ToListAsync(); + + leagueMembers.Where(x => x.Team != null).Should().HaveCountGreaterThan(0); + } + + [Fact] + public async Task PopulateBasicTestSet_ResultShouldHaveSessionResults() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + await accessMockHelper.PopulateBasicTestSet(dbContext); + accessMockHelper.SetCurrentLeague(await dbContext.Leagues.FirstAsync()); + + var result = await dbContext.EventResults + .Include(x => x.SessionResults) + .FirstAsync(); + + result.SessionResults.Should().NotBeEmpty(); + } + + [Fact] + public async Task PopulateBasicTestSet_SessionsShouldHaveAtLeastOneReview() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + await accessMockHelper.PopulateBasicTestSet(dbContext); + accessMockHelper.SetCurrentLeague(await dbContext.Leagues.FirstAsync()); + + var sessions = await dbContext.Sessions + .Include(x => x.IncidentReviews) + .ToListAsync(); + + foreach (var session in sessions) + { + session.IncidentReviews.Should().NotBeEmpty(); + } + } + + [Fact] + public async Task PopulateBasicTestSet_ShouldHaveVoteCategories() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + await accessMockHelper.PopulateBasicTestSet(dbContext); + accessMockHelper.SetCurrentLeague(await dbContext.Leagues.FirstAsync()); + + var voteCategories = await dbContext.VoteCategories + .ToListAsync(); + + voteCategories.Should().NotBeEmpty(); + } + + [Fact] + public async Task ShouldAddPointRule_WithoutDeletingScoring() + { + long configId; + long pointRuleId; + int scoringCount; + + using (var dbContext = accessMockHelper.CreateMockDbContext(databaseName)) + { + await accessMockHelper.PopulateBasicTestSet(dbContext); + accessMockHelper.SetCurrentLeague(await dbContext.Leagues.FirstAsync()); + + var @event = await dbContext.Events + .Include(x => x.Schedule.Season.League) + .FirstAsync(); + var config = accessMockHelper.CreateConfiguration(@event); + var pointRule = accessMockHelper.CreatePointRule(@event.Schedule.Season.League); + configId = config.ResultConfigId; + pointRuleId = pointRule.PointRuleId; + scoringCount = config.Scorings.Count(); + dbContext.ResultConfigurations.Add(config); + dbContext.PointRules.Add(pointRule); + config.Scorings.ForEach(x => x.PointsRule = pointRule); + await dbContext.SaveChangesAsync(); + } + + using (var dbContext = accessMockHelper.CreateMockDbContext(databaseName)) + { + var config = await dbContext.ResultConfigurations + .Include(x => x.Scorings) + .FirstAsync(x => x.ResultConfigId == configId); + + config.Scorings.Should().HaveCount(scoringCount); + } + } + + public async Task InitializeAsync() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + dbContext.Database.EnsureCreated(); + await Task.CompletedTask; + } + + public async Task DisposeAsync() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + dbContext.Database.EnsureDeleted(); + await Task.CompletedTask; + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/EventCalculationConfigurationProviderTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/EventCalculationConfigurationProviderTests.cs new file mode 100644 index 00000000..9a0da685 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/EventCalculationConfigurationProviderTests.cs @@ -0,0 +1,206 @@ +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.Tests.ResultService.DataAccess; + +public sealed class EventCalculationConfigurationProviderTests : DataAccessTestsBase +{ + public EventCalculationConfigurationProviderTests() + { + var sessionConfigurationProvider = fixture.Create(); + fixture.Register(() => sessionConfigurationProvider); + } + + [Fact] + public async Task GetResultConfigIds_ShouldReturnEmpty_WhenNoResulConfigConfigured() + { + var @event = await dbContext.Events + .FirstAsync(); + var sut = CreateSut(); + + var test = await sut.GetResultConfigIds(@event.EventId); + + test.Should().BeEmpty(); + } + + [Fact] + public async Task GetResultConfigIds_ShouldReturnCollection_WhenResultConfigsConfigured() + { + var @event = await dbContext.Events + .FirstAsync(); + var configs = accessMockHelper.ConfigurationBuilder(@event).CreateMany(); + dbContext.ResultConfigurations.AddRange(configs); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetResultConfigIds(@event.EventId); + + test.Should().HaveSameCount(configs); + test.Should().BeEquivalentTo(configs.Select(x => x.ResultConfigId)); + } + + [Fact] + public async Task GetResultConfigIds_ShouldReturnInOrderOfDependency_WhenSourceResultConfigIsConfigured() + { + var @event = await dbContext.Events.FirstAsync(); + int resultConfigCount = 5; + var resultConfigs = accessMockHelper.ConfigurationBuilder(@event).CreateMany(resultConfigCount).ToList(); + // add dependencies + resultConfigs[0].SourceResultConfigId = resultConfigs[2].ResultConfigId; + resultConfigs[1].SourceResultConfigId = resultConfigs[0].ResultConfigId; + resultConfigs[2].SourceResultConfigId = resultConfigs[4].ResultConfigId; + resultConfigs[3].SourceResultConfigId = null; + resultConfigs[4].SourceResultConfigId = resultConfigs[3].ResultConfigId; + dbContext.ResultConfigurations.AddRange(resultConfigs); + await dbContext.SaveChangesAsync(); + var expectedOrder = new[] { 3, 4, 2, 0, 1 }; + var sut = CreateSut(); + + var test = await sut.GetResultConfigIds(@event.EventId); + + foreach ((var configId, var expIndex) in test.Zip(expectedOrder)) + { + configId.Should().Be(resultConfigs[expIndex].ResultConfigId); + } + } + + [Fact] + public async Task GetResultConfigIds_ShouldThrow_WhenSourceResultConfigContainsCyclicDependency() + { + var @event = await dbContext.Events.FirstAsync(); + int resultConfigCount = 5; + var resultConfigs = accessMockHelper.ConfigurationBuilder(@event).CreateMany(resultConfigCount).ToList(); + // add dependencies + resultConfigs[0].SourceResultConfigId = resultConfigs[1].ResultConfigId; + resultConfigs[1].SourceResultConfigId = resultConfigs[0].ResultConfigId; + resultConfigs[2].SourceResultConfigId = resultConfigs[4].ResultConfigId; + resultConfigs[3].SourceResultConfigId = null; + resultConfigs[4].SourceResultConfigId = resultConfigs[3].ResultConfigId; + dbContext.ResultConfigurations.AddRange(resultConfigs); + await dbContext.SaveChangesAsync(); + var expectedOrder = new[] { 3, 4, 2, 0, 1 }; + var sut = CreateSut(); + + var test = async () => await sut.GetResultConfigIds(@event.EventId); + + await test.Should().ThrowAsync(); + } + + [Fact] + public async Task GetConfiguration_ShouldReturnDefaultConfiguration_WhenResultConfigIsNull() + { + var @event = await dbContext.Events + .Include(x => x.Sessions) + .FirstAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(@event.EventId, null); + + test.LeagueId.Should().Be(@event.LeagueId); + test.EventId.Should().Be(@event.EventId); + test.DisplayName.Should().Be("Default"); + test.ResultConfigId.Should().BeNull(); + test.SessionResultConfigurations.Should().HaveSameCount(@event.Sessions); + } + + [Fact] + public async Task GetConfiguration_ShouldReturnConfiguration_WithChampSeasonId() + { + var @event = await dbContext.Events + .Include(x => x.Schedule) + .ThenInclude(x => x.Season) + .Include(x => x.Sessions) + .FirstAsync(); + var championship = await dbContext.Championships.FirstAsync(); + var champSeason = accessMockHelper.CreateChampSeason(championship, @event.Schedule.Season); + var config = accessMockHelper.CreateConfiguration(@event); + champSeason.ResultConfigurations = new[] { config }; + dbContext.ChampSeasons.Add(champSeason); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(@event.EventId, config.ResultConfigId); + + test.ChampSeasonId.Should().Be(champSeason.ChampSeasonId); + } + + [Fact] + public async Task GetConfiguration_ShouldReturnConfiguration_WhenResultConfigIsNotNull() + { + var @event = await dbContext.Events + .Include(x => x.Sessions) + .FirstAsync(); + var config = accessMockHelper.CreateConfiguration(@event); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(@event.EventId, config.ResultConfigId); + + test.ResultConfigId.Should().Be(config.ResultConfigId); + } + + [Fact] + public async Task GetConfiguration_ShouldProvideDefaultResultId_WhenResultExistsAndConfigIsNull() + { + var @event = await dbContext.Events + .Include(x => x.Sessions) + .FirstAsync(); + var config = (ResultConfigurationEntity?)null; + var eventResult = accessMockHelper.CreateScoredResult(@event, config); + dbContext.ScoredEventResults.Add(eventResult); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(@event.EventId, config?.ResultConfigId); + + test.ResultId.Should().Be(eventResult.ResultId); + } + + [Fact] + public async Task GetConfiguration_ShouldProvideConfigurationResultId_WhenResultExistsAndConfigIsNotNull() + { + var @event = await dbContext.Events + .Include(x => x.Sessions) + .FirstAsync(); + var config = accessMockHelper.CreateConfiguration(@event); + var eventResult = accessMockHelper.CreateScoredResult(@event, config); + dbContext.ScoredEventResults.Add(eventResult); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(@event.EventId, config.ResultConfigId); + + test.ResultConfigId.Should().Be(config.ResultConfigId); + test.ResultId.Should().Be(eventResult.ResultId); + } + + [Fact] + public async Task GetConfiguration_ShouldProvideSourceConfigId_WhenSourceConfigIsConfigured() + { + var @event = await dbContext.Events + .Include(x => x.Sessions) + .FirstAsync(); + var sourceConfig = accessMockHelper.CreateConfiguration(@event); + var config = accessMockHelper.CreateConfiguration(@event); + config.SourceResultConfig = sourceConfig; + dbContext.ResultConfigurations.Add(sourceConfig); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(@event.EventId, config.ResultConfigId); + + test.ResultConfigId.Should().Be(config.ResultConfigId); + test.SourceResultConfigId.Should().Be(sourceConfig.ResultConfigId); + } + + private EventCalculationConfigurationProvider CreateSut() + { + return fixture.Create(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/EventCalculationDataProviderTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/EventCalculationDataProviderTests.cs new file mode 100644 index 00000000..9c037157 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/EventCalculationDataProviderTests.cs @@ -0,0 +1,265 @@ +using DbIntegrationTests; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.Tests.ResultService.DataAccess; + +public sealed class EventCalculationDataProviderTests : DataAccessTestsBase +{ + [Fact] + public async Task GetData_ShouldReturnNull_WhenNoResultDataExists() + { + var schedule = await dbContext.Schedules.FirstAsync(); + var @event = accessMockHelper.EventBuilder(schedule).Create(); + var config = GetConfiguration(@event); + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().BeNull(); + } + + [Fact] + public async Task GetData_ShouldReturnData_WhenResultDataExists() + { + var @event = await GetFirstEventEntity(); + var rawResult = @event.EventResult; + var config = GetConfiguration(@event); + var sut = CreateSut(); + + var test = (await sut.GetData(config))!; + + test.Should().NotBeNull(); + test.LeagueId = @event.LeagueId; + test.EventId = @event.EventId; + test.SessionResults.Should().HaveSameCount(@event.Sessions); + test.SessionResults.Should().HaveSameCount(rawResult.SessionResults); + foreach ((var sessionResultData, var session, var sessionResult) in test.SessionResults.Zip(@event.Sessions, rawResult.SessionResults)) + { + sessionResultData.LeagueId.Should().Be(session.LeagueId); + sessionResultData.SessionId.Should().Be(session.SessionId); + sessionResultData.SessionId.Should().Be(sessionResult.SessionId); + sessionResultData.ResultRows.Should().HaveSameCount(sessionResult.ResultRows); + sessionResultData.AcceptedReviewVotes.Should().BeEmpty(); + } + } + + [Fact] + public async Task GetData_ShouldProvideAcceptedReviewVotes_WhenAcceptedVoteExists() + { + var @event = await GetFirstEventEntity(); + var review = @event.Sessions.First().IncidentReviews.First(); + var memberAtFault = @event.Sessions.First().SessionResult.ResultRows.First().Member; + var voteCat = await dbContext.VoteCategories.FirstAsync(); + var vote = accessMockHelper.AcceptedReviewVoteBuilder() + .With(x => x.LeagueId, review.LeagueId) + .With(x => x.Review, review) + .With(x => x.ReviewId, review.ReviewId) + .With(x => x.MemberAtFault, memberAtFault) + .With(x => x.MemberAtFaultId, memberAtFault.Id) + .With(x => x.VoteCategory, voteCat) + .Without(x => x.ReviewPenaltys) + .Create(); + dbContext.AcceptedReviewVotes.Add(vote); + await dbContext.SaveChangesAsync(); + var config = GetConfiguration(@event); + var sut = CreateSut(); + + var test = (await sut.GetData(config))!; + + test.SessionResults.First().AcceptedReviewVotes.First().ReviewVoteId.Should().Be(vote.ReviewVoteId); + } + + [Fact] + public async Task GetData_ShouldProvideResultFromSoure_WhenSourceConfigIsConfigured() + { + var @event = await GetFirstEventEntity(); + var sourceConfig = accessMockHelper.CreateConfiguration(@event); + var sourceResult = accessMockHelper.CreateScoredResult(@event, sourceConfig); + dbContext.ResultConfigurations.Add(sourceConfig); + dbContext.ScoredEventResults.Add(sourceResult); + await dbContext.SaveChangesAsync(); + var config = GetConfiguration(@event); + config.SourceResultConfigId = sourceConfig.ResultConfigId; + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().NotBeNull(); + test!.SessionResults.Should().HaveSameCount(sourceResult.ScoredSessionResults); + foreach ((var testSession, var sourceSession) in test.SessionResults.OrderBy(x => x.SessionNr).Zip(sourceResult.ScoredSessionResults.OrderBy(x => x.SessionNr))) + { + foreach ((var testRow, var sourceRow) in testSession.ResultRows.OrderBy(x => x.MemberId).Zip(sourceSession.ScoredResultRows.OrderBy(x => x.MemberId))) + { + testRow.RacePoints.Should().Be(sourceRow.RacePoints); + testRow.Car.Should().Be(sourceRow.Car); + } + } + } + + [Fact] + public async Task GetData_ShouldProvideAddPenalties() + { + var @event = await GetFirstEventEntity(); + var rawResult = @event.EventResult; + var configEntity = accessMockHelper.CreateConfiguration(@event); + var scoredResult = accessMockHelper.CreateScoredResult(@event, configEntity); + var addPenalty = new AddPenaltyEntity() + { + LeagueId = scoredResult.LeagueId, + ScoredResultRow = scoredResult.ScoredSessionResults.First().ScoredResultRows.First(), + Value = new() + { + Type = PenaltyType.Points, + Points = 420, + }, + }; + dbContext.ResultConfigurations.Add(configEntity); + dbContext.ScoredEventResults.Add(scoredResult); + dbContext.AddPenaltys.Add(addPenalty); + await dbContext.SaveChangesAsync(); + var config = GetConfiguration(@event); + config.ResultId = scoredResult.ResultId; + var sut = CreateSut(); + + var test = (await sut.GetData(config))!; + + test.Should().NotBeNull(); + test.AddPenalties.Should().NotBeEmpty(); + var testPenalty = test.AddPenalties.First(); + testPenalty.SessionNr.Should().Be(scoredResult.ScoredSessionResults.First().SessionNr); + testPenalty.MemberId.Should().Be(addPenalty.ScoredResultRow.MemberId); + testPenalty.Type.Should().Be(addPenalty.Value.Type); + testPenalty.Points.Should().Be(addPenalty.Value.Points); + } + + [Fact] + public async Task GetData_ShouldProvideResultRowData() + { + var @event = await GetFirstEventEntity(); + var rawResult = @event.EventResult; + var config = GetConfiguration(@event); + var sut = CreateSut(); + + var test = (await sut.GetData(config))!; + + test.Should().NotBeNull(); + var compareRow = rawResult.SessionResults.First().ResultRows.First(); + var testRow = test.SessionResults + .FirstOrDefault()? + .ResultRows + .FirstOrDefault(); + testRow.Should().NotBeNull(); + + testRow!.AvgLapTime.Should().Be(compareRow.AvgLapTime); + testRow.Car.Should().Be(compareRow.Car); + testRow.MemberId.Should().Be(compareRow.MemberId); + testRow.Firstname.Should().Be(compareRow.Member.Firstname); + testRow.Lastname.Should().Be(compareRow.Member.Lastname); + testRow.TeamId.Should().Be(compareRow.TeamId); + testRow.TeamName.Should().Be(compareRow.Team?.Name ?? string.Empty); + testRow.TeamColor.Should().Be(compareRow.Team?.TeamColor ?? string.Empty); + testRow.StartPosition.Should().Be(compareRow.StartPosition); + testRow.FinishPosition.Should().Be(compareRow.FinishPosition); + testRow.CarNumber.Should().Be(compareRow.CarNumber); + testRow.ClassId.Should().Be(compareRow.ClassId); + testRow.ClubId.Should().Be(compareRow.ClubId); + testRow.ClubName.Should().Be(compareRow.ClubName); + testRow.Car.Should().Be(compareRow.Car); + testRow.CarClass.Should().Be(compareRow.CarClass); + testRow.CompletedLaps.Should().Be(compareRow.CompletedLaps); + testRow.LeadLaps.Should().Be(compareRow.LeadLaps); + testRow.FastLapNr.Should().Be(compareRow.FastLapNr); + testRow.Incidents.Should().Be(compareRow.Incidents); + testRow.Status.Should().Be(compareRow.Status); + testRow.QualifyingTime.Should().Be(compareRow.QualifyingTime); + testRow.Interval.Should().Be(compareRow.Interval); + testRow.AvgLapTime.Should().Be(compareRow.AvgLapTime); + testRow.FastestLapTime.Should().Be(compareRow.FastestLapTime); + testRow.PositionChange.Should().Be(compareRow.PositionChange); + testRow.OldIrating.Should().Be(compareRow.OldIRating); + testRow.NewIrating.Should().Be(compareRow.NewIRating); + testRow.SeasonStartIrating.Should().Be(compareRow.SeasonStartIRating); + testRow.License.Should().Be(compareRow.License); + testRow.NewCpi.Should().Be(compareRow.NewCpi); + testRow.OldCpi.Should().Be(compareRow.OldCpi); + testRow.OldSafetyRating.Should().Be(compareRow.OldSafetyRating); + testRow.NewSafetyRating.Should().Be(compareRow.NewSafetyRating); + testRow.CarId.Should().Be(compareRow.CarId); + testRow.CompletedPct.Should().Be(compareRow.CompletedPct); + testRow.Division.Should().Be(compareRow.Division); + testRow.OldLicenseLevel.Should().Be(compareRow.OldLicenseLevel); + testRow.NewLicenseLevel.Should().Be(compareRow.NewLicenseLevel); + testRow.RacePoints.Should().Be(compareRow.RacePoints); + testRow.PointsEligible.Should().Be(compareRow.PointsEligible); + } + + [Fact] + public async Task GetData_ShouldProvideSessionLapTimes() + { + var @event = await GetFirstEventEntity(); + var fastestLap = fixture.Create(); + var fastestQualyLap = fixture.Create(); + var fastestAvgLap = fixture.Create(); + var rawResult = @event.EventResult; + foreach(var session in rawResult.SessionResults) + { + session.ResultRows.ForEach(x => + { + x.FastestLapTime = fastestLap + fixture.Create(); + x.QualifyingTime = fastestQualyLap + fixture.Create(); + x.AvgLapTime = fastestAvgLap + fixture.Create(); + }); + session.ResultRows.GetRandom().FastestLapTime = TimeSpan.Zero; + session.ResultRows.GetRandom().FastestLapTime = fastestLap; + session.ResultRows.GetRandom().QualifyingTime = TimeSpan.Zero; + session.ResultRows.GetRandom().QualifyingTime = fastestQualyLap; + session.ResultRows.GetRandom().AvgLapTime = TimeSpan.Zero; + session.ResultRows.GetRandom().AvgLapTime = fastestAvgLap; + } + await dbContext.SaveChangesAsync(); + var config = GetConfiguration(@event); + var sut = CreateSut(); + + var test = (await sut.GetData(config))!; + + test.Should().NotBeNull(); + foreach(var session in test.SessionResults) + { + session.FastestLap.Should().Be(fastestLap); + session.FastestQualyLap.Should().Be(fastestQualyLap); + session.FastestAvgLap.Should().Be(fastestAvgLap); + } + } + + private EventCalculationDataProvider CreateSut() + { + return fixture.Create(); + } + + private async Task GetFirstEventEntity() + { + return await dbContext.Events + .Include(x => x.EventResult) + .ThenInclude(x => x.SessionResults) + .ThenInclude(x => x.ResultRows) + .Include(x => x.Schedule.Season.League) + .Include(x => x.Sessions) + .ThenInclude(x => x.IncidentReviews) + .FirstAsync(); + } + + private EventCalculationConfiguration GetConfiguration(EventEntity @event) + { + return fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.EventId, @event.EventId) + .Without(x => x.SourceResultConfigId) + .Create(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/EventCalculationResultStoreTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/EventCalculationResultStoreTests.cs new file mode 100644 index 00000000..88e09512 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/EventCalculationResultStoreTests.cs @@ -0,0 +1,330 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.Tests.ResultService.DataAccess; + +public sealed class EventCalculationResultStoreTests : DataAccessTestsBase +{ + [Fact] + public async Task StoreCalculationResult_ShouldStoreNewResult_WhenResultNotExists() + { + var @event = await GetFirstEventEntity(); + var configEntity = accessMockHelper.CreateConfiguration(@event); + var config = GetConfiguration(@event); + var result = GetCalculationResult(@event, config); + dbContext.ResultConfigurations.Add(configEntity); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + dbContext.ScoredEventResults + .Where(x => x.EventId == @event.EventId) + .Should().BeEmpty(); + + await sut.StoreCalculationResult(result); + + dbContext.ScoredEventResults + .Where(x => x.EventId == @event.EventId) + .Should().NotBeEmpty(); + } + + [Fact] + public async Task StoreCalculationResult_ShouldStoreSameResult_WhenResultExists() + { + var @event = await GetFirstEventEntity(); + var configEntity = accessMockHelper.CreateConfiguration(@event); + var resultEntity = accessMockHelper.CreateScoredResult(@event, configEntity); + var testRowEntity = resultEntity.ScoredSessionResults.First().ScoredResultRows.First(); + dbContext.ResultConfigurations.Add(configEntity); + dbContext.ScoredEventResults.Add(resultEntity); + await dbContext.SaveChangesAsync(); + var config = GetConfiguration(@event, resultEntity); + var result = GetCalculationResult(@event, config, resultEntity); + var testRow = result.SessionResults.First().ResultRows.First(x => x.MemberId == testRowEntity.MemberId); + testRowEntity.RacePoints = 0d; + testRow.RacePoints = fixture.Create(); + var sut = CreateSut(); + + await sut.StoreCalculationResult(result); + + resultEntity = await dbContext.ScoredEventResults + .FirstAsync(x => x.ResultId == config.ResultId); + testRowEntity = resultEntity.ScoredSessionResults.First().ScoredResultRows + .First(x => x.MemberId == testRow.MemberId); + testRowEntity.RacePoints.Should().Be(testRow.RacePoints); + } + + [Fact] + public async Task StoreCalculationResult_ShouldDeleteSessionResult_WhenNotInCalculationResult() + { + var @event = await GetFirstEventEntity(); + var configEntity = accessMockHelper.CreateConfiguration(@event); + var resultEntity = accessMockHelper.CreateScoredResult(@event, configEntity); + var removeScoring = configEntity.Scorings.OrderBy(x => x.Index).Last(); + var removeSessionResult = resultEntity.ScoredSessionResults.ElementAt(1); + dbContext.ResultConfigurations.Add(configEntity); + dbContext.ScoredEventResults.Add(resultEntity); + await dbContext.SaveChangesAsync(); + var config = GetConfiguration(@event, resultEntity); + config.SessionResultConfigurations = config.SessionResultConfigurations + .Where(x => x.SessionResultId != removeSessionResult.SessionResultId); + var result = GetCalculationResult(@event, config); + var sut = CreateSut(); + + await sut.StoreCalculationResult(result); + + var test = await dbContext.ScoredSessionResults + .Where(x => x.SessionResultId == removeSessionResult.SessionResultId) + .SingleOrDefaultAsync(); + test.Should().BeNull(); + } + + [Fact] + public async Task StoreCalculationResult_ShouldDeleteResultRow_WhenNotInSessionResult() + { + var @event = await GetFirstEventEntity(); + var configEntity = accessMockHelper.CreateConfiguration(@event); + var resultEntity = accessMockHelper.CreateScoredResult(@event, configEntity); + var removeScoring = configEntity.Scorings.OrderBy(x => x.Index).Last(); + var removeRow = resultEntity.ScoredSessionResults + .OrderBy(x => x.SessionNr) + .Last() + .ScoredResultRows.OrderBy(x => x.FinishPosition) + .ElementAt(1); + dbContext.ResultConfigurations.Add(configEntity); + dbContext.ScoredEventResults.Add(resultEntity); + await dbContext.SaveChangesAsync(); + var config = GetConfiguration(@event, resultEntity); + var result = GetCalculationResult(@event, config, resultEntity); + var removeRowFromSessionResult = result.SessionResults.Single(x => x.SessionResultId == removeRow.SessionResultId); + removeRowFromSessionResult.ResultRows = removeRowFromSessionResult.ResultRows + .Where(x => x.MemberId != removeRow.MemberId); + var sut = CreateSut(); + + await sut.StoreCalculationResult(result); + + var testResult = await dbContext.ScoredSessionResults + .SingleAsync(x => x.SessionNr == removeRowFromSessionResult.SessionNr); + testResult.ScoredResultRows.Should().HaveSameCount(removeRowFromSessionResult.ResultRows); + testResult.ScoredResultRows.Should().NotContain(x => x.ScoredResultRowId == removeRow.ScoredResultRowId); + } + + [Fact] + public async Task StoreCalculationResult_ShouldStoreTeamResultRows_WhenIsTeamResult() + { + var @event = await GetFirstEventEntity(); + var members = await dbContext.LeagueMembers.ToListAsync(); + @event.Sessions = @event.Sessions.Where(x => x.SessionType == SessionType.Race).Take(1).ToList(); + var sourceConfigEntity = accessMockHelper.CreateConfiguration(@event); + var configEntity = accessMockHelper.ConfigurationBuilder(@event) + .With(x => x.SourceResultConfig, sourceConfigEntity) + .Create(); + var sourceResultEntity = accessMockHelper.CreateScoredResult(@event, sourceConfigEntity); + dbContext.ResultConfigurations.Add(sourceConfigEntity); + dbContext.ResultConfigurations.Add(configEntity); + dbContext.ScoredEventResults.Add(sourceResultEntity); + await dbContext.SaveChangesAsync(); + var config = GetConfiguration(@event, configEntity); + var result = GetCalculationResult(@event, config); + result.SessionResults.Single().ResultRows.ForEach(x => x.MemberId = null); + result.SessionResults.Single().ResultRows.First().ScoredMemberResultRowIds = sourceResultEntity + .ScoredSessionResults.Single().ScoredResultRows.Take(2).Select(x => x.ScoredResultRowId).ToList(); + var sut = CreateSut(); + + await sut.StoreCalculationResult(result); + + var testResult = await dbContext.ScoredEventResults + .Include(x => x.ScoredSessionResults) + .ThenInclude(x => x.ScoredResultRows) + .ThenInclude(x => x.TeamResultRows) + .Where(x => x.ResultConfigId == config.ResultConfigId) + .SingleAsync(x => x.EventId == @event.EventId); + var teamRows = testResult.ScoredSessionResults.Single().ScoredResultRows.First().TeamResultRows; + teamRows.Should().NotBeEmpty(); + teamRows.Should().HaveCount(2); + teamRows.Select(x => x.ScoredResultRowId).Should().BeEquivalentTo( + sourceResultEntity.ScoredSessionResults.Single().ScoredResultRows.Select(x => x.ScoredResultRowId).Take(2)); + } + + [Fact] + public async Task StoreCalculationResult_ShouldStoreResult_WithChampSeason() + { + var @event = await GetFirstEventEntity(); + var championship = await dbContext.Championships.FirstAsync(); + var champSeason = accessMockHelper.CreateChampSeason(championship, @event.Schedule.Season); + var configEntity = accessMockHelper.CreateConfiguration(@event); + var config = GetConfiguration(@event, configEntity); + var result = GetCalculationResult(@event, config); + result.ChampSeasonId = champSeason.ChampSeasonId; + dbContext.ChampSeasons.Add(champSeason); + dbContext.ResultConfigurations.Add(configEntity); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + await sut.StoreCalculationResult(result); + + var test = await dbContext.ScoredEventResults + .Where(x => x.EventId == @event.EventId) + .Where(x => x.ResultConfigId == configEntity.ResultConfigId) + .FirstOrDefaultAsync(); + test.Should().NotBeNull(); + test!.ChampSeasonId.Should().Be(champSeason.ChampSeasonId); + } + + [Fact] + public async Task StoreCalculationResult_ShouldStoreResultRowData() + { + var @event = await GetFirstEventEntity(); + @event.ScoredEventResults.Clear(); + var configEntity = accessMockHelper.CreateConfiguration(@event); + var resultEntity = accessMockHelper.CreateScoredResult(@event, configEntity); + var testRowEntity = resultEntity.ScoredSessionResults.First().ScoredResultRows.First(); + dbContext.ResultConfigurations.Add(configEntity); + await dbContext.SaveChangesAsync(); + var config = GetConfiguration(@event); + var result = GetCalculationResult(@event, config, resultEntity); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + await sut.StoreCalculationResult(result); + + var testResult = await dbContext.ScoredEventResults + .Where(x => x.EventId == @event.EventId) + .FirstOrDefaultAsync(); + testResult.Should().NotBeNull(); + var compareRow = result.SessionResults + .OrderBy(x => x.SessionNr) + .First() + .ResultRows + .First(); + var testRow = testResult!.ScoredSessionResults + .OrderBy(x => x.SessionNr) + .FirstOrDefault()? + .ScoredResultRows + .FirstOrDefault(x => x.MemberId == compareRow.MemberId); + testRow.Should().NotBeNull(); + + testRow!.StartPosition.Should().Be(compareRow.StartPosition); + testRow.FinishPosition.Should().Be(compareRow.FinishPosition); + testRow.CarNumber.Should().Be(compareRow.CarNumber); + testRow.ClassId.Should().Be(compareRow.ClassId); + testRow.Car.Should().Be(compareRow.Car); + testRow.CarClass.Should().Be(compareRow.CarClass); + testRow.CompletedLaps.Should().Be(compareRow.CompletedLaps); + testRow.LeadLaps.Should().Be(compareRow.LeadLaps); + testRow.FastLapNr.Should().Be(compareRow.FastLapNr); + testRow.Incidents.Should().Be(compareRow.Incidents); + testRow.Status.Should().Be(compareRow.Status); + testRow.QualifyingTime.Should().Be(compareRow.QualifyingTime); + testRow.Interval.Should().Be(compareRow.Interval); + testRow.AvgLapTime.Should().Be(compareRow.AvgLapTime); + testRow.FastestLapTime.Should().Be(compareRow.FastestLapTime); + testRow.PositionChange.Should().Be(compareRow.PositionChange); + testRow.OldIRating.Should().Be(compareRow.OldIrating); + testRow.NewIRating.Should().Be(compareRow.NewIrating); + testRow.SeasonStartIRating.Should().Be(compareRow.SeasonStartIrating); + testRow.License.Should().Be(compareRow.License); + testRow.OldSafetyRating.Should().Be(compareRow.OldSafetyRating); + testRow.NewSafetyRating.Should().Be(compareRow.NewSafetyRating); + testRow.OldCpi.Should().Be(compareRow.OldCpi); + testRow.NewCpi.Should().Be(compareRow.NewCpi); + testRow.ClubId.Should().Be(compareRow.ClubId); + testRow.ClubName.Should().Be(compareRow.ClubName); + testRow.CarId.Should().Be(compareRow.CarId); + testRow.CompletedPct.Should().Be(compareRow.CompletedPct); + testRow.Division.Should().Be(compareRow.Division); + testRow.OldLicenseLevel.Should().Be(compareRow.OldLicenseLevel); + testRow.NewLicenseLevel.Should().Be(compareRow.NewLicenseLevel); + testRow.RacePoints.Should().Be(compareRow.RacePoints); + testRow.MemberId.Should().Be(compareRow.MemberId); + testRow.TeamId.Should().Be(compareRow.TeamId); + testRow.BonusPoints.Should().Be(compareRow.BonusPoints); + testRow.PenaltyPoints.Should().Be(compareRow.PenaltyPoints); + testRow.FinalPosition.Should().Be(compareRow.FinalPosition); + testRow.FinalPositionChange.Should().Be(compareRow.FinalPositionChange); + testRow.TotalPoints.Should().Be(compareRow.TotalPoints); + testRow.PointsEligible.Should().Be(compareRow.PointsEligible); +} + + private EventCalculationResultStore CreateSut() + { + return fixture.Create(); + } + + private async Task GetFirstEventEntity() + { + return await dbContext.Events + .Include(x => x.Schedule.Season) + .ThenInclude(x => x.League) + .Include(x => x.Sessions) + .ThenInclude(x => x.IncidentReviews) + .Include(x => x.ScoredEventResults) + .FirstAsync(); + } + + private EventCalculationConfiguration GetConfiguration(EventEntity @event, ResultConfigurationEntity config) + { + return fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.EventId, @event.EventId) + .With(x => x.ResultConfigId, config.ResultConfigId) + .With(x => x.SourceResultConfigId, config.SourceResultConfigId) + .With(x => x.SessionResultConfigurations, @event.Sessions + .Select(z => fixture.Build() + .With(x => x.SessionId, z.SessionId) + .Without(x => x.SessionResultId) + .Create()) + .ToList()) + .Without(x => x.ResultId) + .Create(); + } + + private EventCalculationConfiguration GetConfiguration(EventEntity @event, ScoredEventResultEntity? scoredEventResult = null) + { + return fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.EventId, @event.EventId) + .With(x => x.ResultConfigId, scoredEventResult?.ResultConfigId) + .With(x => x.ResultId, scoredEventResult?.ResultId) + .With(x => x.SessionResultConfigurations, @event.Sessions + .Zip(scoredEventResult?.ScoredSessionResults ?? Array.Empty()) + .Select(z => fixture.Build() + .With(x => x.SessionId, z.First.SessionId) + .With(x => x.SessionResultId, z.Second.SessionResultId) + .Create()) + .ToList()) + .Create(); + } + + private EventCalculationResult GetCalculationResult(EventEntity @event, EventCalculationConfiguration config, + ScoredEventResultEntity? resultEntity = null, IEnumerable? members = null) + { + return fixture.Build() + .With(x => x.EventId, @event.EventId) + .With(x => x.ResultConfigId, config.ResultConfigId) + .With(x => x.ResultId, config.ResultId) + .With(x => x.SessionResults, resultEntity?.ScoredSessionResults.Select(sessionResult => fixture.Build() + .With(x => x.LeagueId, sessionResult.LeagueId) + .With(x => x.SessionResultId, sessionResult.SessionResultId) + .With(x => x.SessionNr, sessionResult.SessionNr) + .With(x => x.ResultRows, sessionResult.ScoredResultRows.Select(resultRow => fixture.Build() + .With(x => x.MemberId, resultRow.MemberId) + .With(x => x.TeamId, resultRow.TeamId) + .With(x => x.PointsEligible, true) + .Create()).ToList()) + .Create()).ToList() + ?? config.SessionResultConfigurations.Select(sessionConfig => fixture.Build() + .With(x => x.LeagueId, sessionConfig.LeagueId) + .With(x => x.SessionResultId, sessionConfig.SessionResultId) + .With(x => x.ResultRows, (members?.Select(member => fixture.Build() + .With(x => x.MemberId, member.MemberId) + .With(x => x.TeamId, member.TeamId) + .Create()) + ?? fixture.CreateMany()).ToList()) + .Create()).ToList()) + .Create(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/SessionCalculationConfigurationProviderTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/SessionCalculationConfigurationProviderTests.cs new file mode 100644 index 00000000..e37b44ff --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/SessionCalculationConfigurationProviderTests.cs @@ -0,0 +1,841 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Extensions; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.Tests.ResultService.DataAccess; + +public sealed class SessionCalculationConfigurationProviderTests : DataAccessTestsBase +{ + [Fact] + public async Task GetConfigurations_ShouldProvideDefaultConfiguration_WhenConfigIsNull() + { + var @event = await GetFirstEventEntity(); + var config = (ResultConfigurationEntity?)null; + var sut = fixture.Create(); + + var test = await sut.GetConfigurations(@event, config); + + test.Should().HaveSameCount(@event.Sessions); + foreach ((var sessionConfig, var session) in test.Zip(@event.Sessions.OrderBy(x => x.SessionNr))) + { + sessionConfig.LeagueId.Should().Be(@event.LeagueId); + sessionConfig.SessionId.Should().Be(session.SessionId); + sessionConfig.ScoringId.Should().BeNull(); + sessionConfig.UpdateTeamOnRecalculation.Should().BeFalse(); + sessionConfig.UseResultSetTeam.Should().BeFalse(); + sessionConfig.MaxResultsPerGroup.Should().Be(int.MaxValue); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideDefaultSessionResultId_WhenCalculatedResultExistsAndConfigIsNull() + { + var @event = await GetFirstEventEntity(); + var config = (ResultConfigurationEntity?)null; + var scoredEventResult = accessMockHelper.CreateScoredResult(@event, config); + dbContext.ScoredEventResults.Add(scoredEventResult); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + test.Should().HaveSameCount(scoredEventResult.ScoredSessionResults); + foreach ((var sessionConfig, var sessionResult) in test.Zip(scoredEventResult.ScoredSessionResults.OrderBy(x => x.SessionNr))) + { + sessionConfig.SessionResultId.Should().Be(sessionResult.SessionResultId); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideConfigurationFromEntity_WhenConfigIsNotNull() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + var sut = fixture.Create(); + + var test = await sut.GetConfigurations(@event, config); + + test.Should().HaveSameCount(@event.Sessions); + test.Should().HaveSameCount(config.Scorings); + foreach ((var sessionConfig, var session, var scoring) in test.Zip(@event.Sessions.OrderBy(x => x.SessionNr), config.Scorings.OrderBy(x => x.Index))) + { + sessionConfig.LeagueId.Should().Be(@event.LeagueId); + sessionConfig.SessionId.Should().Be(session.SessionId); + sessionConfig.ScoringId.Should().Be(scoring.ScoringId); + sessionConfig.MaxResultsPerGroup.Should().Be(config.ResultsPerTeam); + sessionConfig.UpdateTeamOnRecalculation.Should().Be(scoring.UpdateTeamOnRecalculation); + sessionConfig.UseResultSetTeam.Should().Be(scoring.UseResultSetTeam); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideMemberKindConfig_WhenResultConfigIsMemberKind() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var championship = accessMockHelper.ChampionshipEntityBuilder(@event.Schedule.Season.League).Create(); + var champSeason = accessMockHelper.CreateChampSeason(championship, @event.Schedule.Season); + champSeason.ResultKind = ResultKind.Member; + champSeason.ResultConfigurations.Add(config); + championship.ChampSeasons.Add(champSeason); + dbContext.Championships.Add(championship); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + var sut = fixture.Create(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + sessionConfig.ResultKind.Should().Be(ResultKind.Member); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideTeamKindConfig_WhenResultConfigIsTeamKind() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var championship = accessMockHelper.ChampionshipEntityBuilder(@event.Schedule.Season.League).Create(); + var champSeason = accessMockHelper.CreateChampSeason(championship, @event.Schedule.Season); + champSeason.ResultKind = ResultKind.Team; + champSeason.ResultConfigurations.Add(config); + championship.ChampSeasons.Add(champSeason); + dbContext.Championships.Add(championship); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + var sut = fixture.Create(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + sessionConfig.ResultKind.Should().Be(ResultKind.Team); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideConfigurationSessionResultId_WhenCalculatedResultExistsAndConfigIsNotNull() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + ScoredEventResultEntity scoredEventResult = accessMockHelper.CreateScoredResult(@event, config); + dbContext.ScoredEventResults.Add(scoredEventResult); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + test.Should().HaveSameCount(scoredEventResult.ScoredSessionResults); + foreach ((var sessionConfig, var sessionResult) in test.Zip(scoredEventResult.ScoredSessionResults.OrderBy(x => x.SessionNr))) + { + sessionConfig.SessionResultId.Should().Be(sessionResult.SessionResultId); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideUseResultPointsPointRule_WhenScoringOrPointRuleEntityIsNull() + { + var @event = await GetFirstEventEntity(); + // creates default config with null point rule + var config = accessMockHelper.CreateConfiguration(@event); + config.Scorings.ForEach(x => x.PointsRule = null); + // for testing null scoring + config.Scorings.Remove(config.Scorings.Last()); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + sessionConfig.PointRule.Should().BeOfType(); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideFormulaPointRule_WhenFormulaConfigured() + { + var formula = fixture.Create(); + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var pointRule = accessMockHelper.CreatePointRule(@event.Schedule.Season.League); + pointRule.PointsPerPlace = new List(); + pointRule.MaxPoints = 0; + pointRule.PointDropOff = 0; + pointRule.RuleType = PointRuleType.Formula; + pointRule.Formula = formula; + dbContext.PointRules.Add(pointRule); + dbContext.ResultConfigurations.Add(config); + config.Scorings.ForEach(x => { x.PointsRule = pointRule; }); + await dbContext.SaveChangesAsync(); + config = await dbContext.ResultConfigurations + .Include(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .FirstAsync(x => x.ResultConfigId == config.ResultConfigId); + var scorings = await dbContext.Scorings + .Include(x => x.ResultConfiguration) + .ToListAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + sessionConfig.PointRule.Should().BeOfType(typeof(FormulaPointRule)); + var sessionConfigPointRule = (FormulaPointRule)sessionConfig.PointRule; + sessionConfigPointRule.Formula.Should().Be(formula); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideDefaultConfiguration_WhenSessionIsPracticeOrQualifying() + { + var @event = await GetFirstEventEntity(); + var practice = accessMockHelper.CreateSession(@event, SessionType.Practice); + var qualy = accessMockHelper.CreateSession(@event, SessionType.Qualifying); + var sessionNr = 1; + practice.SessionNr = sessionNr++; + qualy.SessionNr = sessionNr++; + @event.Sessions.ForEach(x => x.SessionNr = sessionNr++); + var config = accessMockHelper.CreateConfiguration(@event); + @event.Sessions.Add(practice); + @event.Sessions.Add(qualy); + dbContext.Sessions.Add(practice); + dbContext.Sessions.Add(qualy); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + test.Should().HaveSameCount(@event.Sessions); + var scoringIndex = 0; + foreach ((var sessionConfig, var session) in test.Zip(@event.Sessions.OrderBy(x => x.SessionNr))) + { + if (session == practice || session == qualy) + { + sessionConfig.ScoringId.Should().BeNull(); + sessionConfig.ResultKind.Should().Be(ResultKind.Member); + sessionConfig.PointRule.Should().BeOfType(); + } + else + { + sessionConfig.ScoringId.Should().Be(config.Scorings.ElementAt(scoringIndex++).ScoringId); + } + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideUseResultPointsPointRule_WhenResultPointRuleHasNoPoints() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var pointRule = accessMockHelper.CreatePointRule(@event.Schedule.Season.League); + pointRule.PointsPerPlace = new List(); + pointRule.MaxPoints = 0; + pointRule.PointDropOff = 0; + dbContext.PointRules.Add(pointRule); + dbContext.ResultConfigurations.Add(config); + config.Scorings.ForEach(x => { x.PointsRule = pointRule; }); + await dbContext.SaveChangesAsync(); + config = await dbContext.ResultConfigurations + .Include(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .FirstAsync(x => x.ResultConfigId == config.ResultConfigId); + var scorings = await dbContext.Scorings + .Include(x => x.ResultConfiguration) + .ToListAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + sessionConfig.PointRule.Should().BeOfType(); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideMaxPointRule_WhenMaxPointsConfigured() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var pointRule = accessMockHelper.CreatePointRule(@event.Schedule.Season.League); + pointRule.PointsPerPlace = new List(); + pointRule.RuleType = PointRuleType.MaxPointsDropOff; + dbContext.PointRules.Add(pointRule); + dbContext.ResultConfigurations.Add(config); + config.Scorings.ForEach(x => { x.PointsRule = pointRule; }); + await dbContext.SaveChangesAsync(); + config = await dbContext.ResultConfigurations + .Include(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .FirstAsync(x => x.ResultConfigId == config.ResultConfigId); + var scorings = await dbContext.Scorings + .Include(x => x.ResultConfiguration) + .ToListAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + sessionConfig.PointRule.Should().BeOfType(typeof(MaxPointRule)); + var sessionConfigPointRule = (MaxPointRule)sessionConfig.PointRule; + sessionConfigPointRule.MaxPoints.Should().Be(pointRule.MaxPoints); + sessionConfigPointRule.DropOff.Should().Be(pointRule.PointDropOff); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvidePerPlacePointRule_WhenPointsPerPlaceConfigured() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var pointRule = accessMockHelper.CreatePointRule(@event.Schedule.Season.League); + pointRule.PointsPerPlace = new[] { 3, 2, 1 }.ToList(); + dbContext.PointRules.Add(pointRule); + dbContext.ResultConfigurations.Add(config); + config.Scorings.ForEach(x => { x.PointsRule = pointRule; }); + await dbContext.SaveChangesAsync(); + config = await dbContext.ResultConfigurations + .Include(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .FirstAsync(x => x.ResultConfigId == config.ResultConfigId); + var scorings = await dbContext.Scorings + .Include(x => x.ResultConfiguration) + .ToListAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + sessionConfig.PointRule.Should().BeOfType(typeof(PerPlacePointRule)); + var sessionConfigPointRule = (PerPlacePointRule)sessionConfig.PointRule; + sessionConfigPointRule.PointsPerPlace.Values.Should().BeEquivalentTo(pointRule.PointsPerPlace); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvidePointRuleWithPointFilters_WhenResultConfigHasPointFilters() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var pointRule = accessMockHelper.CreatePointRule(@event.Schedule.Season.League); + var condition = fixture.Build() + .With(x => x.ColumnPropertyName, nameof(ResultRowCalculationResult.Firstname)) + .Create(); + var filter = fixture.Build() + .With(x => x.Conditions, new[] + { + condition, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + config.PointFilters.Add(filter); + config.Scorings.ForEach(x => { x.PointsRule = pointRule; }); + dbContext.PointRules.Add(pointRule); + dbContext.ResultConfigurations.Add(config); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + var filterGroup = sessionConfig.PointRule.GetPointFilters() as FilterGroupRowFilter; + var testFilter = filterGroup!.GetFilters().First().rowFilter as ColumnValueRowFilter; + testFilter.Should().NotBeNull(); + testFilter!.ColumnProperty.Name.Should().Be(condition.ColumnPropertyName); + testFilter.Comparator.Should().Be(condition.Comparator); + testFilter.FilterValues.Should().BeEquivalentTo(condition.FilterValues); + testFilter.Action.Should().Be(condition.Action); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvidePointRuleWithResultFilters_WhenResultConfigHasResultFilters() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var pointRule = accessMockHelper.CreatePointRule(@event.Schedule.Season.League); + var condition = fixture.Build() + .With(x => x.ColumnPropertyName, nameof(ResultRowCalculationResult.Firstname)) + .Create(); + var filter = fixture.Build() + .With(x => x.Conditions, new[] + { + condition, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + config.ResultFilters.Add(filter); + config.Scorings.ForEach(x => { x.PointsRule = pointRule; }); + dbContext.PointRules.Add(pointRule); + dbContext.ResultConfigurations.Add(config); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + var filterGroup = sessionConfig.PointRule.GetResultFilters() as FilterGroupRowFilter; + var testFilter = filterGroup!.GetFilters().First().rowFilter as ColumnValueRowFilter; + testFilter.Should().NotBeNull(); + testFilter!.ColumnProperty.Name.Should().Be(condition.ColumnPropertyName); + testFilter.Comparator.Should().Be(condition.Comparator); + testFilter.FilterValues.Should().BeEquivalentTo(condition.FilterValues); + testFilter.Action.Should().Be(condition.Action); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideColumnValueRowFilter_WhenConfigured() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var condition = fixture.Build() + .With(x => x.FilterType, FilterType.ColumnProperty) + .With(x => x.ColumnPropertyName, nameof(ResultRowCalculationResult.Firstname)) + .Create(); + var filter = fixture.Build() + .With(x => x.Conditions, new[] + { + condition, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + config.ResultFilters.Add(filter); + dbContext.ResultConfigurations.Add(config); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + var filterGroup = sessionConfig.PointRule.GetResultFilters(); + var testFilter = filterGroup!.GetFilters().First().rowFilter as ColumnValueRowFilter; + testFilter.Should().NotBeNull(); + testFilter!.ColumnProperty.Name.Should().Be(condition.ColumnPropertyName); + testFilter.Comparator.Should().Be(condition.Comparator); + testFilter.FilterValues.Should().BeEquivalentTo(condition.FilterValues); + testFilter.Action.Should().Be(condition.Action); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideMemberRowFilter_WhenConfigured() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var condition = fixture.Build() + .With(x => x.FilterType, FilterType.Member) + .With(x => x.FilterValues, fixture.CreateMany().Select(x => x.ToString()).ToList()) + .Create(); + var filter = fixture.Build() + .With(x => x.Conditions, new[] + { + condition, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + config.ResultFilters.Add(filter); + dbContext.ResultConfigurations.Add(config); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + var filterGroup = sessionConfig.PointRule.GetResultFilters(); + var testFilter = filterGroup!.GetFilters().First().rowFilter as IdRowFilter; + testFilter.Should().NotBeNull(); + testFilter!.MatchIds.Select(x => x.ToString()).Should().BeEquivalentTo(condition.FilterValues); + testFilter.Action.Should().Be(condition.Action); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideTeamRowFilter_WhenConfigured() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var condition = fixture.Build() + .With(x => x.FilterType, FilterType.Member) + .With(x => x.FilterValues, fixture.CreateMany().Select(x => x.ToString()).ToList()) + .Create(); + var filter = fixture.Build() + .With(x => x.Conditions, new[] + { + condition, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + config.ResultFilters.Add(filter); + dbContext.ResultConfigurations.Add(config); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + var filterGroup = sessionConfig.PointRule.GetResultFilters(); + var testFilter = filterGroup!.GetFilters().First().rowFilter as IdRowFilter; + testFilter.Should().NotBeNull(); + testFilter!.MatchIds.Select(x => x.ToString()).Should().BeEquivalentTo(condition.FilterValues); + testFilter.Action.Should().Be(condition.Action); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideDsqFilter_WhenNoStatusFilterConfigured() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + dbContext.ResultConfigurations.Add(config); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + var filterGroup = sessionConfig.PointRule.GetPointFilters(); + var testFilter = filterGroup!.GetFilters() + .Where(x => x.combination == FilterCombination.And) + .Select(x => x.rowFilter) + .OfType() + .SingleOrDefault(x => x.ColumnProperty.Name == nameof(ResultRowCalculationResult.Status)); + testFilter.Should().NotBeNull(); + testFilter!.Comparator.Should().Be(ComparatorType.IsEqual); + testFilter.Action.Should().Be(MatchedValueAction.Remove); + testFilter.FilterValues.Should().BeEquivalentTo(new[] { (int)RaceStatus.Disqualified }); + } + } + + [Fact] + public async Task GetConfigurations_ShouldNotProvideDsqFilter_WhenStatusFilterConfigured() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var condition = fixture.Build() + .With(x => x.FilterType, FilterType.ColumnProperty) + .With(x => x.Comparator, ComparatorType.NotEqual) + .With(x => x.Action, MatchedValueAction.Keep) + .With(x => x.ColumnPropertyName, nameof(ResultRowCalculationResult.Status)) + .With(x => x.FilterValues, new[] { ((int)RaceStatus.Disconnected).ToString() }) + .Create(); + var filter = fixture.Build() + .With(x => x.Conditions, new[] + { + condition, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + config.PointFilters.Add(filter); + dbContext.ResultConfigurations.Add(config); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + var filterGroup = sessionConfig.PointRule.GetPointFilters(); + var testFilter = filterGroup!.GetFilters() + .Where(x => x.combination == FilterCombination.And) + .Select(x => x.rowFilter) + .OfType() + .SingleOrDefault(x => x.ColumnProperty.Name == nameof(ResultRowCalculationResult.Status)); + testFilter.Should().NotBeNull(); + testFilter!.Comparator.Should().Be(ComparatorType.NotEqual); + testFilter.Action.Should().Be(MatchedValueAction.Keep); + testFilter.FilterValues.Should().BeEquivalentTo(new[] { (int)RaceStatus.Disconnected }); + } + } + + [Theory] + [InlineData( + MatchedValueAction.Keep, FilterCombination.And, + MatchedValueAction.Keep, FilterCombination.Or, + MatchedValueAction.Remove, FilterCombination.And)] + [InlineData( + MatchedValueAction.Remove, FilterCombination.And, + MatchedValueAction.Keep, FilterCombination.Or, + MatchedValueAction.Remove, FilterCombination.And)] + [InlineData( + MatchedValueAction.Keep, FilterCombination.And, + MatchedValueAction.Keep, FilterCombination.Or, + MatchedValueAction.Keep, FilterCombination.Or)] + [InlineData( + MatchedValueAction.Remove, FilterCombination.And, + MatchedValueAction.Remove, FilterCombination.And, + MatchedValueAction.Remove, FilterCombination.And)] + public async Task GetConfigurations_ShouldProvideCombinedFilters_WhenConfigured( + MatchedValueAction action1, FilterCombination combination1, + MatchedValueAction action2, FilterCombination combination2, + MatchedValueAction action3, FilterCombination combination3) + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var condition1 = fixture.Build() + .With(x => x.FilterType, FilterType.ColumnProperty) + .With(x => x.ColumnPropertyName, nameof(ResultRowCalculationResult.Firstname)) + .With(x => x.Action, action1) + .Create(); + var filter1 = fixture.Build() + .With(x => x.Conditions, new[] + { + condition1, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + var condition2 = fixture.Build() + .With(x => x.FilterType, FilterType.ColumnProperty) + .With(x => x.ColumnPropertyName, nameof(ResultRowCalculationResult.Lastname)) + .With(x => x.Action, action2) + .Create(); + var filter2 = fixture.Build() + .With(x => x.Conditions, new[] + { + condition2, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + var condition3 = fixture.Build() + .With(x => x.FilterType, FilterType.Member) + .With(x => x.FilterValues, fixture.CreateMany().Select(x => x.ToString()).ToList()) + .With(x => x.Action, action3) + .Create(); + var filter3 = fixture.Build() + .With(x => x.Conditions, new[] + { + condition3, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + config.ResultFilters.Add(filter1); + config.ResultFilters.Add(filter2); + config.ResultFilters.Add(filter3); + dbContext.ResultConfigurations.Add(config); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + var filterGroup = sessionConfig.PointRule.GetResultFilters(); + var testFilter1 = filterGroup!.GetFilters().First(); + testFilter1.combination.Should().Be(combination1); + testFilter1.rowFilter.Should().BeOfType(); + var testFilter2 = filterGroup.GetFilters().ElementAt(1); + testFilter2.combination.Should().Be(combination2); + testFilter2.rowFilter.Should().BeOfType(); + var testFilter3 = filterGroup.GetFilters().ElementAt(2); + testFilter3.combination.Should().Be(combination3); + testFilter3.rowFilter.Should().BeOfType>(); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideAutoPenalties() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var pointRule = accessMockHelper.CreatePointRule(@event.Schedule.Season.League); + var autoPenalty = fixture.Build() + .With(x => x.Conditions, () => fixture.Build() + .With(x => x.ColumnPropertyName, nameof(ResultRowCalculationResult.Incidents)) + .With(x => x.FilterType, FilterType.ColumnProperty) + .With(x => x.Comparator, ComparatorType.ForEach) + .With(x => x.FilterValues, new[] { "4.0" }) + .CreateMany(1).ToList()) + .With(x => x.PointRule, pointRule) + .With(x => x.Description, "Test Autopenalty") + .With(x => x.Points, 42) + .With(x => x.Positions, 420) + .With(x => x.Time, new TimeSpan(1, 2, 3)) + .With(x => x.Type, PenaltyType.Position) + .Create(); + pointRule.AutoPenalties.Add(autoPenalty); + dbContext.PointRules.Add(pointRule); + dbContext.ResultConfigurations.Add(config); + config.Scorings.ForEach(x => { x.PointsRule = pointRule; }); + await dbContext.SaveChangesAsync(); + config = await dbContext.ResultConfigurations + .Include(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .FirstAsync(x => x.ResultConfigId == config.ResultConfigId); + var scorings = await dbContext.Scorings + .Include(x => x.ResultConfiguration) + .ToListAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + sessionConfig.PointRule.Should().BeAssignableTo(typeof(CalculationPointRuleBase)); + var sessionConfigPointRule = (CalculationPointRuleBase)sessionConfig.PointRule; + sessionConfigPointRule.AutoPenalties.Should().HaveCount(1); + var testPenalty = sessionConfigPointRule.AutoPenalties.First(); + testPenalty.Description.Should().Be("Test Autopenalty"); + testPenalty.Points.Should().Be(42); + testPenalty.Positions.Should().Be(420); + testPenalty.Time.Should().Be(new TimeSpan(1, 2, 3)); + testPenalty.Type.Should().Be(PenaltyType.Position); + testPenalty.Conditions.GetFilters().Should().HaveCount(1); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideChampSeasonFilters() + { + var @event = await GetFirstEventEntity(); + var championship = accessMockHelper.ChampionshipEntityBuilder(@event.Schedule.Season.League).Create(); + var champseason = accessMockHelper.CreateChampSeason(championship, @event.Schedule.Season); + var config = accessMockHelper.CreateConfiguration(@event); + config.ChampSeason = champseason; + var condition = fixture.Build() + .With(x => x.FilterType, FilterType.Member) + .With(x => x.FilterValues, fixture.CreateMany().Select(x => x.ToString()).ToList()) + .Create(); + var filter = fixture.Build() + .With(x => x.Conditions, new[] + { + condition, + }) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Without(x => x.ChampSeason) + .Create(); + champseason.Filters.Add(filter); + dbContext.Championships.Add(championship); + dbContext.ChampSeasons.Add(champseason); + dbContext.ResultConfigurations.Add(config); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + var filterGroup = sessionConfig.PointRule.GetChampSeasonFilters(); + var testFilter = filterGroup!.GetFilters().First().rowFilter as IdRowFilter; + testFilter.Should().NotBeNull(); + testFilter!.MatchIds.Select(x => x.ToString()).Should().BeEquivalentTo(condition.FilterValues); + testFilter.Action.Should().Be(condition.Action); + } + } + + [Fact] + public async Task GetConfigurations_ShouldProvideBonusPointConfiguration() + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + var pointRule = accessMockHelper.CreatePointRule(@event.Schedule.Season.League); + var bonusPoint = fixture.Build() + .With(x => x.Type, BonusPointType.Custom) + .With(x => x.Value, 420) + .With(x => x.Points, 42) + .With(x => x.Conditions, new[] + { + new FilterConditionModel() + { + FilterType = FilterType.ColumnProperty, + ColumnPropertyName = nameof(ResultRowCalculationResult.CompletedLaps), + FilterValues = new[] { "10" }, + Action = MatchedValueAction.Keep, + Comparator = ComparatorType.IsEqual, + }, + }) + .Create(); + pointRule.BonusPoints.Add(bonusPoint); + dbContext.PointRules.Add(pointRule); + dbContext.ResultConfigurations.Add(config); + config.Scorings.ForEach(x => { x.PointsRule = pointRule; }); + await dbContext.SaveChangesAsync(); + config = await dbContext.ResultConfigurations + .Include(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .FirstAsync(x => x.ResultConfigId == config.ResultConfigId); + var scorings = await dbContext.Scorings + .Include(x => x.ResultConfiguration) + .ToListAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach (var sessionConfig in test) + { + sessionConfig.PointRule.Should().BeAssignableTo(typeof(CalculationPointRuleBase)); + var sessionConfigPointRule = (CalculationPointRuleBase)sessionConfig.PointRule; + sessionConfigPointRule.BonusPoints.Should().HaveCount(1); + var testBonusPoint = sessionConfigPointRule.BonusPoints.First(); + testBonusPoint.Points.Should().Be(42); + testBonusPoint.Value.Should().Be(420); + testBonusPoint.Type.Should().Be(BonusPointType.Custom); + testBonusPoint.Conditions.GetFilters().Should().HaveCount(1); + } + } + + [Theory] + [InlineData(1, 1)] + [InlineData(3, 3)] + [InlineData(0, int.MaxValue)] + [InlineData(-1, int.MaxValue)] + [InlineData(-42, int.MaxValue)] + public async Task GetConfigurations_ShouldProvideConfigWithMaximuResultsPerTeam(int maxResultsPerTeam, int expected) + { + var @event = await GetFirstEventEntity(); + var config = accessMockHelper.CreateConfiguration(@event); + config.ResultsPerTeam = maxResultsPerTeam; + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfigurations(@event, config); + + foreach(var sessionConfig in test) + { + sessionConfig.MaxResultsPerGroup.Should().Be(expected); + } + } + + private SessionCalculationConfigurationProvider CreateSut() + { + return fixture.Create(); + } + + private async Task GetFirstEventEntity() + { + return await dbContext.Events + .Include(x => x.Schedule.Season.League) + .Include(x => x.Sessions) + .FirstAsync(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/StandingCalculationConfigurationProviderTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/StandingCalculationConfigurationProviderTests.cs new file mode 100644 index 00000000..10af3514 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/StandingCalculationConfigurationProviderTests.cs @@ -0,0 +1,163 @@ +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.Tests.ResultService.DataAccess; + +public sealed class StandingCalculationConfigurationProviderTests : DataAccessTestsBase +{ + [Theory] + [InlineData(default(long))] + [InlineData(-42)] + public async Task GetConfiguration_ShouldProvideEmptyConfiguration_WhenEventDoesNotExist(long? eventId) + { + var season = await GetFirstSeasonAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(season.SeasonId, eventId, null); + + test.LeagueId.Should().Be(0); + test.SeasonId.Should().Be(0); + test.EventId.Should().Be(0); + test.ResultConfigs.Should().BeEmpty(); + } + + [Fact] + public async Task GetConfiguration_ShouldConfigurationForEvent_WhenEventIdIsNotNull() + { + var season = await GetFirstSeasonAsync(); + var @event = season.Schedules.First().Events.First(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(season.SeasonId, @event.EventId, null); + + test.LeagueId.Should().Be(season.LeagueId); + test.SeasonId.Should().Be(season.SeasonId); + test.EventId.Should().Be(@event.EventId); + test.ResultConfigs.Should().BeEmpty(); + } + + [Fact] + public async Task GetConfiguration_ShouldProvideConfigurationForLatestEvent_WhenEventIdIsNull() + { + var season = await GetFirstSeasonAsync(); + // create results for first two events + var events = season.Schedules.SelectMany(x => x.Events).OrderBy(x => x.Date); + foreach (var @event in events.Take(2)) + { + var result = accessMockHelper.CreateScoredResult(@event, null); + @event.ScoredEventResults.Add(result); + dbContext.ScoredEventResults.Add(result); + } + var latestEvent = events.ElementAt(1); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(season.SeasonId, null, null); + + test.LeagueId.Should().Be(season.LeagueId); + test.SeasonId.Should().Be(season.SeasonId); + test.EventId.Should().Be(latestEvent.EventId); + test.ResultConfigs.Should().BeEmpty(); + } + + [Fact] + public async Task GetConfiguration_ShouldProvideConfiguration_WithStandingConfigId() + { + var season = await GetFirstSeasonAsync(); + var @event = season.Schedules.First().Events.First(); + var championship = await GetFirstChampionshipAsync(); + var config = accessMockHelper.CreateConfiguration(@event); + var champSeason = accessMockHelper.CreateChampSeason(championship, season); + var standingConfig = accessMockHelper.CreateStandingConfiguration(season.League); + dbContext.ChampSeasons.Add(champSeason); + dbContext.StandingConfigurations.Add(standingConfig); + dbContext.ResultConfigurations.Add(config); + champSeason.StandingConfiguration = standingConfig; + champSeason.ResultConfigurations = new[] { config }; + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(season.SeasonId, @event.EventId, standingConfig.StandingConfigId); + + test.LeagueId.Should().Be(season.LeagueId); + test.SeasonId.Should().Be(season.SeasonId); + test.EventId.Should().Be(@event.EventId); + test.ResultConfigs.Should().HaveCount(1); + test.ResultConfigs.First().Should().Be(champSeason.ResultConfigurations.First().ResultConfigId); + test.StandingConfigId.Should().Be(standingConfig.StandingConfigId); + } + + [Fact] + public async Task GetConfiguration_ShouldProvideConfiguration_WithMultipleResultConfigurations() + { + var season = await GetFirstSeasonAsync(); + var @event = season.Schedules.First().Events.First(); + var championship = await GetFirstChampionshipAsync(); + int configCount = 2; + var configs = accessMockHelper.ConfigurationBuilder(@event).CreateMany(configCount); + var champSeason = accessMockHelper.CreateChampSeason(championship, season); + var standingConfig = accessMockHelper.CreateStandingConfiguration(season.League); + dbContext.ChampSeasons.Add(champSeason); + dbContext.StandingConfigurations.Add(standingConfig); + dbContext.ResultConfigurations.AddRange(configs); + champSeason.StandingConfiguration = standingConfig; + champSeason.ResultConfigurations = configs.ToList(); + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(season.SeasonId, @event.EventId, standingConfig.StandingConfigId); + + test.ResultConfigs.Should().HaveCount(configCount); + test.ResultConfigs.First().Should().Be(champSeason.ResultConfigurations.First().ResultConfigId); + test.StandingConfigId.Should().Be(standingConfig.StandingConfigId); + } + + [Fact] + public async Task GetConfiguration_ShouldProvideConfiguration_WithChampSeason() + { + var season = await GetFirstSeasonAsync(); + var @event = season.Schedules.First().Events.First(); + var championship = await GetFirstChampionshipAsync(); + var config = accessMockHelper.CreateConfiguration(@event); + var champSeason = accessMockHelper.CreateChampSeason(championship, season); + var standingConfig = accessMockHelper.CreateStandingConfiguration(season.League); + dbContext.ChampSeasons.Add(champSeason); + dbContext.StandingConfigurations.Add(standingConfig); + dbContext.ResultConfigurations.Add(config); + champSeason.StandingConfiguration = standingConfig; + champSeason.ResultConfigurations = new[] { config }; + await dbContext.SaveChangesAsync(); + var sut = CreateSut(); + + var test = await sut.GetConfiguration(season.SeasonId, @event.EventId, standingConfig.StandingConfigId); + + test.ChampSeasonId.Should().Be(champSeason.ChampSeasonId); + test.Name.Should().Be(champSeason.Championship.Name); + test.DisplayName.Should().Be(champSeason.Championship.DisplayName); + } + + private StandingCalculationConfigurationProvider CreateSut() + { + return fixture.Create(); + } + + private async Task GetFirstSeasonAsync() + { + return await dbContext.Seasons + .Include(x => x.League) + .Include(x => x.Schedules) + .ThenInclude(x => x.Events) + .ThenInclude(x => x.ScoredEventResults) + .Include(x => x.ChampSeasons) + .FirstAsync(); + } + + private async Task GetFirstChampionshipAsync() + { + return await dbContext.Championships + .Include(x => x.ChampSeasons) + .FirstAsync(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/StandingCalculationDataProviderTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/StandingCalculationDataProviderTests.cs new file mode 100644 index 00000000..4f597606 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/StandingCalculationDataProviderTests.cs @@ -0,0 +1,233 @@ +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.Tests.ResultService.DataAccess; + +public sealed class StandingCalculationDataProviderTests : DataAccessTestsBase +{ + [Fact] + public async Task GetData_ShouldProvidePreviousResults_WithDefaultResultConfig() + { + var prevCount = 2; + var season = await GetFirstSeasonAsync(); + var events = season.Schedules.SelectMany(x => x.Events).OrderBy(x => x.Date); + AddMultipleScoredEventResults(events, null, prevCount + 1); + await dbContext.SaveChangesAsync(); + var config = CreateStandingConfiguration(season, events.ElementAt(prevCount)); + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().NotBeNull(); + test!.LeagueId.Should().Be(season.LeagueId); + test.SeasonId.Should().Be(season.SeasonId); + test.PreviousEventResults.Should().HaveCount(prevCount); + foreach (var (result, prevEvent) in test.PreviousEventResults.Zip(events.Take(prevCount))) + { + result.EventId.Should().Be(prevEvent.EventId); + result.SessionResults.Should().HaveCountGreaterThanOrEqualTo(prevEvent.Sessions.Count); + } + } + + [Fact] + public async Task GetData_ShouldProvideCurrentResult_WithDefaultResultConfig() + { + var prevCount = 2; + var season = await GetFirstSeasonAsync(); + var championship = await dbContext.Championships.FirstAsync(); + var events = season.Schedules.SelectMany(x => x.Events).OrderBy(x => x.Date); + AddMultipleScoredEventResults(events, null, prevCount + 1); + await dbContext.SaveChangesAsync(); + var @event = events.ElementAt(prevCount); + var config = CreateStandingConfiguration(season, @event); + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().NotBeNull(); + test!.EventId.Should().Be(@event.EventId); + var result = test.CurrentEventResult; + result.EventId.Should().Be(@event.EventId); + result.SessionResults.Should().HaveCountGreaterThanOrEqualTo(@event.Sessions.Count); + } + + [Fact] + public async Task GetData_ShouldProvidePreviousResults_WithSingleResultConfig() + { + var prevCount = 2; + var season = await GetFirstSeasonAsync(); + var championship = await dbContext.Championships.FirstAsync(); + var events = season.Schedules.SelectMany(x => x.Events).OrderBy(x => x.Date); + var champSeason = accessMockHelper.CreateChampSeason(championship, season); + var resultConfig = champSeason.ResultConfigurations.First(); + AddMultipleScoredEventResults(events, resultConfig, prevCount + 1); + await dbContext.SaveChangesAsync(); + var config = CreateStandingConfiguration(season, events.ElementAt(prevCount), champSeason); + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().NotBeNull(); + test!.LeagueId.Should().Be(season.LeagueId); + test.SeasonId.Should().Be(season.SeasonId); + test.PreviousEventResults.Should().HaveCount(prevCount); + foreach (var (result, prevEvent) in test.PreviousEventResults.Zip(events.Take(prevCount))) + { + result.EventId.Should().Be(prevEvent.EventId); + result.SessionResults.Should().HaveCountGreaterThanOrEqualTo(prevEvent.Sessions.Count); + } + } + + [Fact] + public async Task GetData_ShouldProvideCurrentResult_WithSingleResultConfig() + { + var prevCount = 2; + var season = await GetFirstSeasonAsync(); + var championship = await dbContext.Championships.FirstAsync(); + var events = season.Schedules.SelectMany(x => x.Events).OrderBy(x => x.Date); + var champSeason = accessMockHelper.CreateChampSeason(championship, season); + var resultConfig = champSeason.ResultConfigurations.First(); + AddMultipleScoredEventResults(events, resultConfig, prevCount + 1); + await dbContext.SaveChangesAsync(); + var @event = events.ElementAt(prevCount); + var config = CreateStandingConfiguration(season, @event, champSeason); + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().NotBeNull(); + test!.EventId.Should().Be(@event.EventId); + var result = test.CurrentEventResult; + result.EventId.Should().Be(@event.EventId); + result.SessionResults.Should().HaveCountGreaterThanOrEqualTo(@event.Sessions.Count); + } + + [Fact] + public async Task GetData_ShouldProvidePreviousResults_WithMultipleResultConfig() + { + var prevCount = 2; + var season = await GetFirstSeasonAsync(); + var championship = await dbContext.Championships.FirstAsync(); + var events = season.Schedules.SelectMany(x => x.Events).OrderBy(x => x.Date); + var champSeason = accessMockHelper.CreateChampSeason(championship, season); + var resultConfigs = champSeason.ResultConfigurations = accessMockHelper.ConfigurationBuilder(events.First()).CreateMany(2).ToList(); + AddMultipleScoredEventResults(events.Take(1), resultConfigs.First(), 1); + AddMultipleScoredEventResults(events.Skip(1), resultConfigs.Last(), prevCount); + await dbContext.SaveChangesAsync(); + var config = CreateStandingConfiguration(season, events.ElementAt(prevCount), champSeason); + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().NotBeNull(); + test!.LeagueId.Should().Be(season.LeagueId); + test.SeasonId.Should().Be(season.SeasonId); + test.PreviousEventResults.Should().HaveCount(prevCount); + foreach (var (result, prevEvent) in test.PreviousEventResults.Zip(events.Take(prevCount))) + { + result.EventId.Should().Be(prevEvent.EventId); + result.SessionResults.Should().HaveCountGreaterThanOrEqualTo(prevEvent.Sessions.Count); + } + } + + [Fact] + public async Task GetData_ShouldProvideCurrentResult_WithMultipleResultConfig() + { + var prevCount = 2; + var season = await GetFirstSeasonAsync(); + var championship = await dbContext.Championships.FirstAsync(); + var events = season.Schedules.SelectMany(x => x.Events).OrderBy(x => x.Date); + var champSeason = accessMockHelper.CreateChampSeason(championship, season); + var resultConfigs = champSeason.ResultConfigurations = accessMockHelper.ConfigurationBuilder(events.First()).CreateMany(2).ToList(); + AddMultipleScoredEventResults(events.Take(1), resultConfigs.First(), 1); + AddMultipleScoredEventResults(events.Skip(1), resultConfigs.Last(), prevCount); + await dbContext.SaveChangesAsync(); + var @event = events.ElementAt(prevCount); + var config = CreateStandingConfiguration(season, @event, champSeason); + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().NotBeNull(); + test!.EventId.Should().Be(@event.EventId); + var result = test.CurrentEventResult; + result.EventId.Should().Be(@event.EventId); + result.SessionResults.Should().HaveCountGreaterThanOrEqualTo(@event.Sessions.Count); + } + + [Fact] + public async Task GetData_ShouldReturnNull_WhenNoResultFound() + { + var season = await GetFirstSeasonAsync(); + var events = season.Schedules.SelectMany(x => x.Events).OrderBy(x => x.Date); + var @event = events.ElementAt(0); + var config = CreateStandingConfiguration(season, @event); + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().BeNull(); + } + + [Fact] + public async Task GetData_ShouldProvideOnlyPreviousResults_WhenNoCurrentEventResultFound() + { + var prevCount = 2; + var season = await GetFirstSeasonAsync(); + var championship = await dbContext.Championships.FirstAsync(); + var events = season.Schedules.SelectMany(x => x.Events).OrderBy(x => x.Date); + AddMultipleScoredEventResults(events, null, prevCount); + await dbContext.SaveChangesAsync(); + var @event = events.ElementAt(prevCount); + var config = CreateStandingConfiguration(season, @event); + var sut = CreateSut(); + + var test = await sut.GetData(config); + + test.Should().NotBeNull(); + test!.EventId.Should().Be(@event.EventId); + test.PreviousEventResults.Should().HaveCount(prevCount); + test.CurrentEventResult.EventId.Should().Be(@event.EventId); + test.CurrentEventResult.SessionResults.Should().BeEmpty(); + } + + private async Task GetFirstSeasonAsync() + { + return await dbContext.Seasons + .Include(x => x.League) + .Include(x => x.Schedules) + .ThenInclude(x => x.Events) + .ThenInclude(x => x.ScoredEventResults) + .FirstAsync(); + } + + private void AddMultipleScoredEventResults(IEnumerable events, ResultConfigurationEntity? config, int count) + { + foreach (var @event in events.Take(count)) + { + var result = accessMockHelper.CreateScoredResult(@event, config); + @event.ScoredEventResults.Add(result); + dbContext.ScoredEventResults.Add(result); + } + } + + private StandingCalculationConfiguration CreateStandingConfiguration(SeasonEntity season, EventEntity @event, + ChampSeasonEntity? champSeason = null) + { + return fixture.Build() + .With(x => x.LeagueId, season.LeagueId) + .With(x => x.SeasonId, season.SeasonId) + .With(x => x.EventId, @event.EventId) + .With(x => x.ResultConfigs, champSeason?.ResultConfigurations.Select(x => x.ResultConfigId) ?? Array.Empty()) + .With(x => x.WeeksCounted, 2) + .Create(); + } + + private StandingCalculationDataProvider CreateSut() + { + return fixture.Create(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/StandingCalculationResultStoreTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/StandingCalculationResultStoreTests.cs new file mode 100644 index 00000000..b761341c --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/DataAccess/StandingCalculationResultStoreTests.cs @@ -0,0 +1,59 @@ +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.Services.Tests.ResultService.DataAccess; +public sealed class StandingCalculationResultStoreTests : DataAccessTestsBase +{ + [Fact] + public async Task StoreCalculationResult_ShouldStoreResult_WithChampSeason() + { + var @event = await GetFirstEvent(); + var championship = await dbContext.Championships.FirstAsync(); + var champSeason = accessMockHelper.CreateChampSeason(championship, @event.Schedule.Season); + var standingConfig = accessMockHelper.CreateStandingConfiguration(@event.Schedule.Season.League); + champSeason.StandingConfiguration = standingConfig; + dbContext.ChampSeasons.Add(champSeason); + dbContext.StandingConfigurations.Add(standingConfig); + await dbContext.SaveChangesAsync(); + var result = GetCalculationResult(@event, standingConfig); + var sut = CreateSut(); + + await sut.StoreCalculationResult(result); + + var test = await dbContext.Standings + .Where(x => x.EventId == @event.EventId) + .Where(x => x.StandingConfigId == standingConfig.StandingConfigId) + .FirstOrDefaultAsync(); + test.Should().NotBeNull(); + test!.ChampSeasonId.Should().Be(champSeason.ChampSeasonId); + } + + private StandingCalculationResultStore CreateSut() + { + return new StandingCalculationResultStore(dbContext); + } + + private StandingCalculationResult GetCalculationResult(EventEntity @event, StandingConfigurationEntity? standingConfig) + { + return fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.SeasonId, @event.Schedule.SeasonId) + .With(x => x.EventId, @event.EventId) + .With(x => x.StandingConfigId, standingConfig?.StandingConfigId) + .With(x => x.ChampSeasonId, standingConfig?.ChampSeasons.FirstOrDefault(x => x.SeasonId == @event.Schedule.SeasonId)?.ChampSeasonId) + .Without(x => x.StandingRows) + .Create(); + } + + private async Task GetFirstEvent() + { + return await dbContext.Events + .Include(x => x.Schedule.Season) + .ThenInclude(x => x.League) + .FirstAsync(); + } +} + diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/Execution/ExecuteEventResultCalculationTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/Execution/ExecuteEventResultCalculationTests.cs new file mode 100644 index 00000000..625c2012 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/Execution/ExecuteEventResultCalculationTests.cs @@ -0,0 +1,221 @@ +using iRLeagueApiCore.Services.ResultService.Calculation; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Excecution; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueApiCore.Mocking.Extensions; +using Microsoft.Extensions.Logging; +using Xunit.Abstractions; + +namespace iRLeagueApiCore.Services.Tests.ResultService.Execution; + +[Collection("DbTestFixture")] +public sealed class ExecuteEventResultCalculationTests +{ + private readonly Fixture fixture; + private readonly ILogger logger; + private readonly Mock mockConfigurationProvider; + private readonly Mock mockDataProvider; + private readonly Mock mockResultStore; + private readonly Mock> mockCalculationServiceProvider; + private readonly Mock mockStandingQueue; + + public ExecuteEventResultCalculationTests(ITestOutputHelper testOutputHelper) + { + fixture = new(); + var mockLogger = new Mock>(); + mockLogger.Setup(x => x.BeginScope(It.IsAny())) + .Returns(() => Mock.Of()); + mockLogger.Setup(x => x.Log( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny(), + (Func)It.IsAny())) + .Callback(new InvocationAction(invocation => + { + var logLevel = (LogLevel)invocation.Arguments[0]; // The first two will always be whatever is specified in the setup above + var eventId = (EventId)invocation.Arguments[1]; // so I'm not sure you would ever want to actually use them + var state = invocation.Arguments[2]; + var exception = (Exception?)invocation.Arguments[3]; + var formatter = invocation.Arguments[4]; + + var invokeMethod = formatter.GetType().GetMethod("Invoke"); + var logMessage = (string?)invokeMethod?.Invoke(formatter, new[] { state, exception }); + + testOutputHelper.WriteLine("{0}: {1}", logLevel, logMessage); + })); + logger = mockLogger.Object; + mockConfigurationProvider = MockConfigurationProvider(fixture); + mockDataProvider = MockDataProvider(fixture); + mockResultStore = MockResultStore(); + mockCalculationServiceProvider = MockCalculationServiceProvider(fixture); + mockStandingQueue = MockStandingQueue(fixture); + fixture.Register(() => logger); + fixture.Register(() => mockConfigurationProvider.Object); + fixture.Register(() => mockDataProvider.Object); + fixture.Register(() => mockResultStore.Object); + fixture.Register(() => mockCalculationServiceProvider.Object); + fixture.Register(() => mockStandingQueue.Object); + } + + [Fact] + public async Task Execute_ShouldUseDefaultResultConfig_WhenProviderReturnsEmpty() + { + long eventId = fixture.Create(); + mockConfigurationProvider.Setup(x => x.GetResultConfigIds(It.Is(x => x == eventId), It.IsAny())) + .ReturnsAsync(() => Array.Empty()); + mockConfigurationProvider.Setup(x => x.GetConfiguration(It.Is(x => x == eventId), It.Is(x => x == null), It.IsAny())) + .ReturnsAsync((long eventId, long? resultConfigId, CancellationToken cancellationToken) => CreateConfiguration(fixture, eventId, resultConfigId)) + .Verifiable(); + var sut = CreateSut(); + + await sut.Execute(eventId); + + mockConfigurationProvider + .Verify(x => x.GetConfiguration(It.Is(x => x == eventId), It.Is(x => x == null), It.IsAny()), Times.Once); + } + + [Fact] + public async Task Execute_ShouldSkipResult_WhenDataProviderReturnsNull() + { + long eventId = fixture.Create(); + mockDataProvider.Setup(x => x.GetData(It.IsAny(), It.IsAny())) + .ReturnsAsync(() => null) + .Verifiable(); + var mockCalculationService = new Mock>(); + mockCalculationService.Setup(x => x.Calculate(It.IsAny())) + .ReturnsAsync(() => fixture.Create()) + .Verifiable(); + mockCalculationServiceProvider.Setup(x => x.GetCalculationService(It.IsAny())) + .Returns(mockCalculationService.Object); + var sut = CreateSut(); + + await sut.Execute(eventId); + + mockDataProvider.Verify(x => x.GetData(It.IsAny(), It.IsAny())); + mockCalculationService.Verify(x => x.Calculate(It.IsAny()), Times.Never); + } + + [Fact] + public async Task Execute_ShouldCalculateForEachResultConfig() + { + long eventId = fixture.Create(); + int resultConfigCount = 3; + var resultConfigIds = fixture.CreateMany(resultConfigCount); + mockConfigurationProvider.Setup(x => x.GetResultConfigIds(It.IsAny(), It.IsAny())) + .ReturnsAsync(() => resultConfigIds.ToList()); + var storedResults = new List(); + mockResultStore.Setup(x => x.StoreCalculationResult(It.IsAny(), It.IsAny())) + .Callback((EventCalculationResult result, CancellationToken cancellationToken) => storedResults.Add(result)); + var sut = CreateSut(); + + await sut.Execute(eventId); + + storedResults.Should().HaveCount(resultConfigCount); + foreach ((var result, var configId) in storedResults.Zip(resultConfigIds)) + { + result.ResultConfigId.Should().Be(configId); + } + } + + private ExecuteEventResultCalculation CreateSut() + { + return new ExecuteEventResultCalculation( + fixture.Create>(), + fixture.Create(), + fixture.Create(), + fixture.Create(), + fixture.Create>(), + fixture.Create()); + } + + private static Mock MockConfigurationProvider(Fixture fixture) + { + var mockProvider = new Mock(); + mockProvider.Setup(x => x.GetResultConfigIds(It.IsAny(), It.IsAny())) + .ReturnsAsync(() => fixture.CreateMany().ToList()) + .Verifiable(); + mockProvider.Setup(x => x.GetConfiguration(It.IsAny(), It.IsAny(), It.IsAny())) + .ReturnsAsync((long eventId, long? resultConfigId, CancellationToken cancellationToken) => CreateConfiguration(fixture, eventId, resultConfigId)) + .Verifiable(); + return mockProvider; + } + + private static EventCalculationConfiguration CreateConfiguration(Fixture fixture, long eventId, long? resultConfigurationId) + { + return fixture.Build() + .With(x => x.EventId, eventId) + .With(x => x.ResultConfigId, resultConfigurationId) + .Create(); + } + + private static Mock MockDataProvider(Fixture fixture) + { + var mockProvider = new Mock(); + mockProvider.Setup(x => x.GetData(It.IsAny(), It.IsAny())) + .ReturnsAsync((EventCalculationConfiguration config, CancellationToken cancellationToken) => CreateData(fixture, config)) + .Verifiable(); + + return mockProvider; + } + + private static EventCalculationData CreateData(Fixture fixture, EventCalculationConfiguration config) + { + var data = fixture.Build() + .With(x => x.EventId, config.EventId) + .Without(x => x.SessionResults) + .Create(); + data.SessionResults = fixture.Build() + .WithSequence(x => x.SessionId, config.SessionResultConfigurations.Select(x => x.SessionId)) + .CreateMany(config.SessionResultConfigurations.Count()); + return data; + } + + private static Mock MockResultStore() + { + var mockStore = new Mock(); + mockStore.Setup(x => x.StoreCalculationResult(It.IsAny(), It.IsAny())) + .Verifiable(); + + return mockStore; + } + + private static Mock MockStandingQueue(Fixture fixture) + { + var mockQueue = new Mock(); + mockQueue.Setup(x => x.QueueStandingCalculationAsync(It.IsAny())) + .Returns(Task.FromResult(0)); + return mockQueue; + } + + private static Mock> MockCalculationServiceProvider(Fixture fixture) + { + var mockServiceProvider = new Mock>(); + mockServiceProvider.Setup(x => x.GetCalculationService(It.IsAny())) + .Returns((EventCalculationConfiguration config) => MockCalculationService(fixture, config).Object) + .Verifiable(); + + return mockServiceProvider; + } + + private static Mock> MockCalculationService(Fixture fixture, EventCalculationConfiguration config) + { + var mockService = new Mock>(); + mockService.Setup(x => x.Calculate(It.IsAny())) + .ReturnsAsync((EventCalculationData data) => CreateEventCalculationResult(fixture, config, data)) + .Verifiable(); + + return mockService; + } + + private static EventCalculationResult CreateEventCalculationResult(Fixture fixture, EventCalculationConfiguration config, EventCalculationData data) + { + return new EventCalculationResult(data) + { + ResultConfigId = config.ResultConfigId, + Name = config.DisplayName, + SessionResults = data.SessionResults.Select(x => new SessionCalculationResult(x)), + }; + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/ResultService/IntegrationTests.cs b/test/iRLeagueApiCore.Services.Tests/ResultService/IntegrationTests.cs new file mode 100644 index 00000000..afa25360 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/ResultService/IntegrationTests.cs @@ -0,0 +1,206 @@ +using Aydsko.iRacingData.Stats; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Services.ResultService.DataAccess; +using iRLeagueApiCore.Services.ResultService.Excecution; +using iRLeagueApiCore.Services.ResultService.Models; +using iRLeagueDatabaseCore.Models; +using K4os.Hash.xxHash; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Serilog.Core; + +namespace iRLeagueApiCore.Services.Tests.ResultService; +public sealed class IntegrationTests : DataAccessTestsBase +{ + private readonly IServiceProvider services; + + public IntegrationTests() + { + var services = new ServiceCollection() as IServiceCollection; + services.AddScoped(x => dbContext); + services.AddLogging(); + services.AddBackgroundQueue(); + services.AddResultService(); + this.services = services.BuildServiceProvider(); + } + + [Fact] + public async Task CalculateSingleHeaderRace() + { + var schedule = await dbContext.Schedules + .FirstAsync(); + var @event = accessMockHelper.EventBuilder(schedule).Create(); + @event.Sessions = new[] + { + accessMockHelper.CreateSession(@event, Common.Enums.SessionType.Practice), + accessMockHelper.CreateSession(@event, Common.Enums.SessionType.Qualifying), + accessMockHelper.CreateSession(@event, Common.Enums.SessionType.Race), + }.ToList(); + var config = accessMockHelper.CreateConfiguration(@event); + var condition = fixture.Build() + .With(x => x.ColumnPropertyName, nameof(ResultRowCalculationResult.FinishPosition)) + .With(x => x.FilterValues, new[] {"3"}) + .With(x => x.Comparator, Common.Enums.ComparatorType.IsSmallerOrEqual) + .With(x => x.Action, Common.Enums.MatchedValueAction.Keep) + .Create(); + var filter = fixture.Build() + .With(x => x.Conditions, new[] + { + condition, + }) + .Without(x => x.ChampSeason) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Create(); + config.PointFilters.Add(filter); + + var members = await dbContext.LeagueMembers + .Take(5) + .ToListAsync(); + var result = accessMockHelper.CreateResult(@event, members); + @event.EventResult = result; + @event.ScoredEventResults.Clear(); + @event.ResultConfigs.Add(config); + dbContext.Events.Add(@event); + dbContext.FilterOptions.Add(filter); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + + var sut = services.GetRequiredService(); + await sut.Execute(@event.EventId); + + var testResult = await dbContext.ScoredSessionResults + .Where(x => x.ScoredEventResult.EventId == @event.EventId) + .OrderByDescending(x => x.SessionNr) + .Include(x => x.ScoredResultRows) + .ThenInclude(x => x.Member) + .FirstAsync(); + + var compareResult = result.SessionResults + .Last(); + testResult.ScoredResultRows.Should().HaveSameCount(members); + testResult.ScoredResultRows.Select(x => x.FinishPosition).Should() + .BeEquivalentTo(Enumerable.Range(1, 5)); + testResult.ScoredResultRows.Select(x => x.StartPosition).Should() + .BeEquivalentTo(Enumerable.Range(1, 5)); + testResult.ScoredResultRows.Select(x => x.PointsEligible).Should() + .BeEquivalentTo(compareResult.ResultRows.Select(x => x.FinishPosition <= 3)); + testResult.ScoredResultRows.Select(x => x.RacePoints).Should() + .BeEquivalentTo(testResult.ScoredResultRows.Select(x => x.PointsEligible ? x.RacePoints : 0.0)); + } + + [Fact] + public async Task CalculateMultiHeaderCombinedRace() + { + var schedule = await dbContext.Schedules + .FirstAsync(); + var @event = accessMockHelper.EventBuilder(schedule).Create(); + @event.Sessions = new[] + { + accessMockHelper.CreateSession(@event, Common.Enums.SessionType.Practice), + accessMockHelper.CreateSession(@event, Common.Enums.SessionType.Qualifying), + accessMockHelper.CreateSession(@event, Common.Enums.SessionType.Race), + accessMockHelper.CreateSession(@event, Common.Enums.SessionType.Race), + }.ToList(); + @event.Sessions + .Select((x, i) => new { Session = x, Index = i }) + .ToList() + .ForEach(x => x.Session.SessionNr = x.Index + 1); + var config = accessMockHelper.CreateConfiguration(@event); + var combinedScoring = fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Index, 999) + .With(x => x.IsCombinedResult, true) + .With(x => x.PointsRule, () => fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .Without(x => x.Scorings) + .Without(x => x.AutoPenalties) + .Without(x => x.League) + .Without(x => x.BonusPoints) + .Create()) + .Without(x => x.DependendScorings) + .Without(x => x.ExtScoringSource) + .Without(x => x.ResultConfiguration) + .Create(); + var condition = fixture.Build() + .With(x => x.ColumnPropertyName, nameof(ResultRowCalculationResult.FinishPosition)) + .With(x => x.FilterValues, new[] { "3" }) + .With(x => x.Comparator, Common.Enums.ComparatorType.IsSmallerOrEqual) + .With(x => x.Action, Common.Enums.MatchedValueAction.Keep) + .Create(); + var filter = fixture.Build() + .With(x => x.Conditions, new[] + { + condition, + }) + .Without(x => x.ChampSeason) + .Without(x => x.PointFilterResultConfig) + .Without(x => x.ResultFilterResultConfig) + .Create(); + config.Scorings.Add(combinedScoring); + config.PointFilters.Add(filter); + + var members = await dbContext.LeagueMembers + .Take(5) + .ToListAsync(); + var result = accessMockHelper.CreateResult(@event, members); + @event.EventResult = result; + @event.ScoredEventResults.Clear(); + @event.ResultConfigs.Add(config); + dbContext.Events.Add(@event); + dbContext.FilterOptions.Add(filter); + dbContext.ResultConfigurations.Add(config); + await dbContext.SaveChangesAsync(); + + var sut = services.GetRequiredService(); + await sut.Execute(@event.EventId); + + var testResult = await dbContext.ScoredSessionResults + .Where(x => x.ScoredEventResult.EventId == @event.EventId) + .OrderByDescending(x => x.SessionNr) + .Include(x => x.ScoredResultRows) + .ThenInclude(x => x.Member) + .FirstAsync(); + + var compareResult = result.SessionResults + .Last(); + testResult.SessionNr.Should().Be(999); + testResult.ScoredResultRows.Should().HaveSameCount(members); + testResult.ScoredResultRows.Select(x => x.FinishPosition).Should() + .BeEquivalentTo(compareResult.ResultRows.Select(x => x.FinishPosition)); + testResult.ScoredResultRows.Select(x => x.StartPosition).Should() + .BeEquivalentTo(compareResult.ResultRows.Select(x => x.StartPosition)); + testResult.ScoredResultRows.Select(x => x.PointsEligible).Should() + .BeEquivalentTo(compareResult.ResultRows.Select(x => x.FinishPosition <= 3)); + testResult.ScoredResultRows.Select(x => x.RacePoints).Should() + .BeEquivalentTo(testResult.ScoredResultRows.Select(x => x.PointsEligible ? x.RacePoints : 0.0)); + } + + private async Task GetFirstEventEntity() + { + return await dbContext.Events + .Include(x => x.EventResult) + .ThenInclude(x => x.SessionResults) + .ThenInclude(x => x.ResultRows) + .Include(x => x.Schedule.Season.League) + .Include(x => x.Sessions) + .ThenInclude(x => x.IncidentReviews) + .FirstAsync(); + } + + private EventCalculationConfiguration GetConfiguration(EventEntity @event) + { + return fixture.Build() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.EventId, @event.EventId) + .Without(x => x.SourceResultConfigId) + .Create(); + } + + private static ILogger CreateLogger() + { + return Mock.Of>(); + } +} diff --git a/test/iRLeagueApiCore.Services.Tests/_GlobalUsings.cs b/test/iRLeagueApiCore.Services.Tests/_GlobalUsings.cs new file mode 100644 index 00000000..b089d68b --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/_GlobalUsings.cs @@ -0,0 +1,4 @@ +global using AutoFixture; +global using FluentAssertions; +global using Moq; +global using Xunit; diff --git a/test/iRLeagueApiCore.Services.Tests/iRLeagueApiCore.Services.Tests.csproj b/test/iRLeagueApiCore.Services.Tests/iRLeagueApiCore.Services.Tests.csproj new file mode 100644 index 00000000..b0bdb566 --- /dev/null +++ b/test/iRLeagueApiCore.Services.Tests/iRLeagueApiCore.Services.Tests.csproj @@ -0,0 +1,27 @@ + + + + net6.0 + enable + enable + false + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/test/iRLeagueApiCore.UnitTests/Client/Endpoints/CustomEndpointTests.cs b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/CustomEndpointTests.cs new file mode 100644 index 00000000..37bc15a5 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/CustomEndpointTests.cs @@ -0,0 +1,15 @@ +using iRLeagueApiCore.Client.Endpoints; + +namespace iRLeagueApiCore.UnitTests.Client.Endpoints; + +public sealed class CustomEndpointTests +{ + [Fact] + public async Task ShouldCallCorrectRoute() + { + var route = "CustomEndpoint/parameter?queryParam=1"; + var expected = $"{EndpointsTests.BaseUrl}{route}"; + + await EndpointsTests.TestRequestUrl>(expected, x => new CustomEndpoint(x, new(), route), x => x.Get()); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/Endpoints/EndpointsTests.cs b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/EndpointsTests.cs new file mode 100644 index 00000000..d99c1ca1 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/EndpointsTests.cs @@ -0,0 +1,99 @@ +using iRLeagueApiCore.Client.Endpoints; +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.QueryBuilder; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System.Net; + +namespace iRLeagueApiCore.UnitTests.Client.Endpoints; + +public sealed class EndpointsTests +{ + public static string BaseUrl = "https://example.com/api/"; + + private static HttpClientWrapperFactory ClientWrapperFactory { get; } + + static EndpointsTests() + { + var mockLoggerFactory = new Mock(); + mockLoggerFactory.Setup(x => x.CreateLogger(It.IsAny())) + .Returns(Mock.Of()); + ClientWrapperFactory = new(mockLoggerFactory.Object, null); + } + + [Fact] + public void Endpoint_AddQueryParameter_ShouldAddQueryParameters() + { + var name = "param1"; + var value = "value1"; + var routeBuilder = new RouteBuilder(); + routeBuilder.AddEndpoint(BaseUrl); + var endpoint = new TestEndpoint(ClientWrapperFactory.Create(new(), Mock.Of()), routeBuilder); + + endpoint.AddQueryParameter(x => x.Add(name, value)); + var route = endpoint.RouteBuilder.Build(); + + route.Should().Be($"{BaseUrl}?{name}={value}"); + } + + public static async Task TestRequestUrl(string expectedUrl, Func endpoint, Func action) + { + var content = new StringContent(JsonConvert.SerializeObject(null)); + string requestUrl = ""; + var httpMessageHandler = MockHelpers.TestMessageHandler(x => + { + requestUrl = x.RequestUri!.AbsoluteUri; + return new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = content, + }; + }); + + var testClient = new HttpClient(httpMessageHandler) + { + BaseAddress = new Uri(BaseUrl) + }; + var testClientWrapper = ClientWrapperFactory.Create(testClient, Mock.Of()); + await action.Invoke(endpoint.Invoke(testClientWrapper)); + + requestUrl.Should().Be(expectedUrl); + } + + public static async Task TestRequest(string expectedUrl, Func endpoint, Func action, HttpMethod method) + { + var content = new StringContent(JsonConvert.SerializeObject(null)); + string requestUrl = ""; + HttpMethod? requestMethod = default; + var httpMessageHandler = MockHelpers.TestMessageHandler(x => + { + requestUrl = x.RequestUri?.AbsoluteUri ?? string.Empty; + requestMethod = x.Method; + return new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = content, + }; + }); + + var testClient = new HttpClient(httpMessageHandler) + { + BaseAddress = new Uri(BaseUrl) + }; + var testClientWrapper = ClientWrapperFactory.Create(testClient, Mock.Of()); + await action.Invoke(endpoint.Invoke(testClientWrapper)); + + requestUrl.Should().Be(expectedUrl); + requestMethod.Should().Be(method); + } + + private class TestEndpoint : EndpointBase + { + public new RouteBuilder RouteBuilder { get => base.RouteBuilder; } + + public TestEndpoint(HttpClientWrapper httpClient, RouteBuilder routeBuilder) : base(httpClient, routeBuilder) + { + } + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/Endpoints/LeaguesEndpointTests.cs b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/LeaguesEndpointTests.cs new file mode 100644 index 00000000..86311a17 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/LeaguesEndpointTests.cs @@ -0,0 +1,35 @@ +using iRLeagueApiCore.Client.Endpoints.Leagues; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.UnitTests.Client.Endpoints; + +public sealed class LeaguesEndpointTests +{ + private const string testLeagueName = "testLeague"; + private const long testLeagueId = 1; + + [Fact] + public async Task ShouldCallCorrectRequestUrlLeagues() + { + var shouldRequestUrl = EndpointsTests.BaseUrl + "Leagues"; + await EndpointsTests.TestRequestUrl(shouldRequestUrl, x => new LeaguesEndpoint(x, new RouteBuilder()), x => x.Get()); + } + + [Fact] + public async Task ShouldCallCorrectRequestUrlWithId() + { + var requestUrl = EndpointsTests.BaseUrl + $"Leagues/{testLeagueId}"; + await EndpointsTests.TestRequestUrl(requestUrl, + x => new LeaguesEndpoint(x, new RouteBuilder()), + x => x.WithId(1).Get()); + } + + [Fact] + public async Task ShouldCallCorrectRequestUrlWithName() + { + var requestUrl = EndpointsTests.BaseUrl + $"{testLeagueName}/Seasons"; + await EndpointsTests.TestRequestUrl(requestUrl, + x => new LeaguesEndpoint(x, new RouteBuilder()), + x => x.WithName(testLeagueName).Seasons().Get()); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/Endpoints/ResultsEndpointsTests.cs b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/ResultsEndpointsTests.cs new file mode 100644 index 00000000..c09590af --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/ResultsEndpointsTests.cs @@ -0,0 +1,28 @@ +using iRLeagueApiCore.Client.Endpoints.Leagues; + +namespace iRLeagueApiCore.UnitTests.Client.Endpoints; +public sealed class ResultsEndpointsTests +{ + public ResultsEndpointsTests() + { + } + + [Fact] + public async Task FetchEndpoint_ShouldFetchFromCorrectRoute() + { + string leagueName = "TestLeague"; + long eventId = 123; + int subSessionId = 12345; + var shouldRequestUrl = EndpointsTests.BaseUrl + leagueName + "/Events/" + eventId + "/Results/Fetch/" + subSessionId; + await EndpointsTests.TestRequest(shouldRequestUrl, + x => new LeaguesEndpoint(x, new()), + x => x.WithName(leagueName) + .Events() + .WithId(eventId) + .Results() + .Fetch() + .FromIracingSubSession(subSessionId) + .Post(), + HttpMethod.Post); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/Endpoints/SeasonsEndpointTests.cs b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/SeasonsEndpointTests.cs new file mode 100644 index 00000000..cd460af0 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/SeasonsEndpointTests.cs @@ -0,0 +1,28 @@ +using iRLeagueApiCore.Client.Endpoints.Leagues; +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.UnitTests.Client.Endpoints; + +public sealed class SeasonsEndpointTests +{ + private const string testLeagueName = "testLeague"; + private const long testSeasonId = 1; + + [Fact] + public async Task ShouldCallCorrectRequestSeasons() + { + var requestUrl = EndpointsTests.BaseUrl + $"{testLeagueName}/Seasons"; + await EndpointsTests.TestRequestUrl(requestUrl, + x => new LeaguesEndpoint(x, new RouteBuilder()), + x => x.WithName(testLeagueName).Seasons().Get()); + } + + [Fact] + public async Task ShouldCallCorrectRequestWithId() + { + var requestUrl = EndpointsTests.BaseUrl + $"{testLeagueName}/Seasons/{testSeasonId}"; + await EndpointsTests.TestRequestUrl(requestUrl, + x => new LeaguesEndpoint(x, new RouteBuilder()), + x => x.WithName(testLeagueName).Seasons().WithId(testSeasonId).Get()); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/Endpoints/Users/UsersEndpointTests.cs b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/Users/UsersEndpointTests.cs new file mode 100644 index 00000000..82db9c59 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Endpoints/Users/UsersEndpointTests.cs @@ -0,0 +1,88 @@ +using iRLeagueApiCore.Client.Endpoints.Users; +using iRLeagueApiCore.Client.QueryBuilder; +using iRLeagueApiCore.Common.Models.Users; + +namespace iRLeagueApiCore.UnitTests.Client.Endpoints.Users; + +public sealed class UsersEndpointTests +{ + private readonly string usersController = "Users"; + private readonly string searchEndpoint = "Search"; + private readonly string addRoleEndpoint = "AddRole"; + private readonly string removeRoleEndpoint = "RemoveRole"; + private readonly string testLeague = "TestLeague"; + private readonly string testUserId = "1234-56789"; + private readonly PutUserModel testPutUser = new(); + private static RouteBuilder BaseRouteBuilder => new(); + private RouteBuilder LeagueRouteBuilder => (RouteBuilder)(new RouteBuilder().AddEndpoint(testLeague)); + + [Fact] + public async void ShouldCallRequestGetAllUsers() + { + string shouldRequestUrl = $"{EndpointsTests.BaseUrl}{testLeague}/{usersController}"; + await EndpointsTests.TestRequest(shouldRequestUrl, + x => new UsersEndpoint(x, LeagueRouteBuilder), + x => x.Get(), + HttpMethod.Get); + } + + [Fact] + public async void ShouldCallRequestGetLeagueUser() + { + string shouldRequestUrl = $"{EndpointsTests.BaseUrl}{testLeague}/{usersController}/{testUserId}"; + await EndpointsTests.TestRequest(shouldRequestUrl, + x => new UsersEndpoint(x, LeagueRouteBuilder), + x => x.WithId(testUserId).Get(), + HttpMethod.Get); + } + + [Fact] + public async void ShouldCallRequestGetUser() + { + string shouldRequestUrl = $"{EndpointsTests.BaseUrl}{usersController}/{testUserId}"; + await EndpointsTests.TestRequest(shouldRequestUrl, + x => new UsersEndpoint(x, BaseRouteBuilder), + x => x.WithId(testUserId).Get(), + HttpMethod.Get); + } + + [Fact] + public async void ShouldCallRequestPutUser() + { + string shouldRequestUrl = $"{EndpointsTests.BaseUrl}{usersController}/{testUserId}"; + await EndpointsTests.TestRequest(shouldRequestUrl, + x => new UsersEndpoint(x, BaseRouteBuilder), + x => x.WithId(testUserId).Put(testPutUser), + HttpMethod.Put); + } + + [Fact] + public async void ShouldCallRequestSearch() + { + string shouldRequestUrl = $"{EndpointsTests.BaseUrl}{usersController}/{searchEndpoint}"; + await EndpointsTests.TestRequest(shouldRequestUrl, + x => new UsersEndpoint(x, BaseRouteBuilder), + x => x.Search().Post(new()), + HttpMethod.Post); + } + + [Fact] + public async void ShouldCallRequestAddRole() + { + string shouldRequestUrl = $"{EndpointsTests.BaseUrl}{testLeague}/{usersController}/{testUserId}/{addRoleEndpoint}"; + await EndpointsTests.TestRequest(shouldRequestUrl, + x => new UsersEndpoint(x, LeagueRouteBuilder), + x => x.WithId(testUserId).AddRole().Post(new()), + HttpMethod.Post); + } + + [Fact] + public async void ShouldCallRequestRemoveRole() + { + string shouldRequestUrl = $"{EndpointsTests.BaseUrl}{testLeague}/{usersController}/{testUserId}/{removeRoleEndpoint}"; + await EndpointsTests.TestRequest(shouldRequestUrl, + x => new UsersEndpoint(x, LeagueRouteBuilder), + x => x.WithId(testUserId).RemoveRole().Post(new()), + HttpMethod.Post); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/LeagueApiClientTests.cs b/test/iRLeagueApiCore.UnitTests/Client/LeagueApiClientTests.cs new file mode 100644 index 00000000..66dc9fb4 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/LeagueApiClientTests.cs @@ -0,0 +1,115 @@ +using iRLeagueApiCore.Client; +using iRLeagueApiCore.Client.Http; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System.Net; +using System.Net.Http.Headers; + +namespace iRLeagueApiCore.UnitTests.Client; + +public sealed class LeagueApiClientTests +{ + private const string baseUrl = "https://example.com/api"; + private const string testToken = "aslkgjwuipoht2io3ro2pqhuishgiag"; + + private ILogger Logger { get; } = new Mock>().Object; + + private static HttpClientWrapperFactory ClientWrapperFactory { get; } + + static LeagueApiClientTests() + { + var mockLoggerFactory = new Mock(); + mockLoggerFactory.Setup(x => x.CreateLogger(It.IsAny())) + .Returns(Mock.Of()); + ClientWrapperFactory = new(mockLoggerFactory.Object, null); + } + + [Fact] + public async Task ShouldSetAuthenticationToken() + { + var messageHandler = MockHelpers.TestMessageHandler(x => new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent(JsonConvert.SerializeObject(new + { + idToken = testToken, + accessToken = testToken, + expiration = DateTime.UtcNow.AddDays(1), + })), + }); + + string token = string.Empty; + var mockTokenStore = new Mock(); + mockTokenStore.Setup(x => x.SetAccessTokenAsync(It.IsAny())) + .Callback(x => token = x); + + var httpClient = new HttpClient(messageHandler); + httpClient.BaseAddress = new Uri(baseUrl); + + var apiClient = new LeagueApiClient(Logger, httpClient, ClientWrapperFactory, mockTokenStore.Object); + + var result = await apiClient.LogIn("testUser", "testPassword"); + + result.Success.Should().BeTrue(); + token.Should().Be(testToken); + } + + [Fact] + public async Task ShouldSendAuthenticatedRequest() + { + AuthenticationHeaderValue? authHeader = default; + var messageHandler = MockHelpers.TestMessageHandler(x => + { + authHeader = x.Headers.Authorization; + return new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent(JsonConvert.SerializeObject(default)), + }; + }); + var mockTokenStore = new Mock(); + mockTokenStore.Setup(x => x.GetAccessTokenAsync()) + .ReturnsAsync(testToken); + var httpClient = new HttpClient(messageHandler); + httpClient.BaseAddress = new Uri(baseUrl); + + var apiClient = new LeagueApiClient(Logger, httpClient, ClientWrapperFactory, mockTokenStore.Object); + await apiClient.Leagues().Get(); + + Assert.Equal("bearer", authHeader?.Scheme, ignoreCase: true); + Assert.Equal(testToken, authHeader?.Parameter); + } + + [Fact] + public async Task ShouldNotSendAuthenticatedRequestAfterLogOut() + { + AuthenticationHeaderValue? authHeader = default; + var messageHandler = MockHelpers.TestMessageHandler(x => + { + authHeader = x.Headers.Authorization; + return new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent(JsonConvert.SerializeObject(default)), + }; + }); + + string token = testToken; + var mockTokenStore = new Mock(); + mockTokenStore.Setup(x => x.SetAccessTokenAsync(It.IsAny())) + .Callback(x => token = x); + mockTokenStore.Setup(x => x.ClearTokensAsync()) + .Callback(() => token = string.Empty); + mockTokenStore.Setup(x => x.GetAccessTokenAsync()) + .ReturnsAsync(testToken); + var httpClient = new HttpClient(messageHandler); + httpClient.BaseAddress = new Uri(baseUrl); + + var apiClient = new LeagueApiClient(Logger, httpClient, ClientWrapperFactory, mockTokenStore.Object); + await apiClient.LogOut(); + await apiClient.Leagues().Get(); + + Assert.True(string.IsNullOrEmpty(token)); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/QueryBuilder/ParameterBuilderTests.cs b/test/iRLeagueApiCore.UnitTests/Client/QueryBuilder/ParameterBuilderTests.cs new file mode 100644 index 00000000..9c4cf760 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/QueryBuilder/ParameterBuilderTests.cs @@ -0,0 +1,56 @@ +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.UnitTests.Client.QueryBuilder; + +public sealed class ParameterBuilderTests +{ + [Fact] + public void ShouldBuildSingleParameter() + { + const string parameterName = "test"; + const string parameterValue = "value"; + + var test = new ParameterBuilder() + .Add(parameterName, parameterValue) + .Build(); + + Assert.Equal("test=value", test); + } + + [Fact] + public void ShouldBuildMultipleParameters() + { + const string parameterName1 = "test"; + const string parameterValue1 = "value"; + const string parameterName2 = "test2"; + const string parameterValue2 = "value2"; + const string parameterName3 = "test3"; + const string parameterValue3 = "value3"; + + var test = new ParameterBuilder() + .Add(parameterName1, parameterValue1) + .Add(parameterName2, parameterValue2) + .Add(parameterName3, parameterValue3) + .Build(); + + Assert.Equal("test=value&test2=value2&test3=value3", test); + } + + [Fact] + public void ShouldBuildArrayParameters() + { + const string parameterName = "test"; + var values = new string[] + { + "value1", + "value2", + "value3" + }; + + var test = new ParameterBuilder() + .AddArray(parameterName, values) + .Build(); + + Assert.Equal("test=value1&test=value2&test=value3", test); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/QueryBuilder/RouteBuilderTests.cs b/test/iRLeagueApiCore.UnitTests/Client/QueryBuilder/RouteBuilderTests.cs new file mode 100644 index 00000000..6120ca43 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/QueryBuilder/RouteBuilderTests.cs @@ -0,0 +1,63 @@ +using iRLeagueApiCore.Client.QueryBuilder; + +namespace iRLeagueApiCore.UnitTests.Client.QueryBuilder; + +public sealed class RouteBuilderTests +{ + [Fact] + public void ShouldBuildRouteWithNameAndValue() + { + var name = "test"; + var value = "value"; + + var test = new RouteBuilder() + .AddEndpoint(name) + .AddParameter(value) + .Build(); + + Assert.Equal("test/value", test); + } + + [Fact] + public void ShouldBuildRouteWithMulitpleNamesAndValues() + { + var name1 = "test1"; + var value1 = "value1"; + var name2 = "test2"; + var name3 = "test3"; + var value3 = "value3"; + + var test = new RouteBuilder() + .AddEndpoint(name1) + .AddParameter(value1) + .AddEndpoint(name2) + .AddEndpoint(name3) + .AddParameter(value3) + .Build(); + + Assert.Equal("test1/value1/test2/test3/value3", test); + } + + [Fact] + public void ShouldBuildRouteWithParameters() + { + var name = "test"; + var value = "value"; + + var parameter1 = "param1"; + var paramValue1 = "paramValue1"; + var parameter2 = "param2"; + var paramValue2 = "paramValue2"; + + var test = new RouteBuilder() + .AddEndpoint(name) + .AddParameter(value) + .WithParameters(param => param + .Add(parameter1, paramValue1) + .Add(parameter2, paramValue2) + ) + .Build(); + + Assert.Equal("test/value?param1=paramValue1¶m2=paramValue2", test); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/Results/HttpExtensionsTests.cs b/test/iRLeagueApiCore.UnitTests/Client/Results/HttpExtensionsTests.cs new file mode 100644 index 00000000..083d6f7e --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Results/HttpExtensionsTests.cs @@ -0,0 +1,275 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.Results; +using iRLeagueApiCore.Common.Responses; +using Microsoft.Extensions.Logging; +using Moq.Protected; +using Newtonsoft.Json; +using System.Net; + +namespace iRLeagueApiCore.UnitTests.Client.Results; + +public sealed class HttpExtensionsTests +{ + private const string testString = "TestMessage"; + private const long testValue = 42; + private const string testToken = "asgöahsgpasiakojsatlwetaet"; + + private HttpClientWrapperFactory ClientWrapperFactory { get; init; } + + public HttpExtensionsTests() + { + var mockLoggerFactory = new Mock(); + mockLoggerFactory.Setup(x => x.CreateLogger(It.IsAny())) + .Returns(Mock.Of()); + ClientWrapperFactory = new(mockLoggerFactory.Object, null); + } + + [Fact] + public async Task ShouldReturnActionResult() + { + var content = new StringContent(TestContent.AsJson()); + var testMessage = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = content + }; + + var result = await testMessage.ToClientActionResultAsync(default); + Assert.True(result.Success); + Assert.Equal("Success", result.Status); + Assert.Equal(testString, result.Content?.String); + Assert.Equal(testValue, result.Content?.Value); + } + + [Fact] + public async Task ShouldReturnNoContentActionResult() + { + var testMessge = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.NoContent, + Content = null + }; + + var result = await testMessge.ToClientActionResultAsync(default); + Assert.True(result.Success); + Assert.Equal("Success", result.Status); + Assert.Equal(HttpStatusCode.NoContent, result.HttpStatusCode); + Assert.Null(result.Content); + } + + [Fact] + public async Task ShouldReturnBadRequestActionResult() + { + var response = new BadRequestResponse() + { + Status = "Bad Request", + Errors = new ValidationError[] { new ValidationError() { Error = "TestError", Property = "String", Value = 42 } }, + }; + var content = new StringContent(JsonConvert.SerializeObject(response)); + var testMessage = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.BadRequest, + Content = content + }; + + var result = await testMessage.ToClientActionResultAsync(default); + Assert.False(result.Success); + Assert.Equal(HttpStatusCode.BadRequest, result.HttpStatusCode); + Assert.Equal("Bad Request", result.Status); + Assert.Null(result.Content); + Assert.Single(result.Errors); + var error = Assert.IsType(result.Errors.First()); + Assert.Equal("TestError", error.Error); + Assert.Equal("String", error.Property); + } + + [Fact] + public async Task ShouldReturnForbiddenActionResult() + { + var testMessage = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.Forbidden, + Content = default + }; + + var result = await testMessage.ToClientActionResultAsync(default); + Assert.False(result.Success); + Assert.Equal(HttpStatusCode.Forbidden, result.HttpStatusCode); + Assert.Equal("Forbidden", result.Status); + Assert.Null(result.Content); + } + + [Fact] + public async Task ShouldReturnInternalServerErrorResult() + { + var testMessage = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.InternalServerError, + Content = default, + }; + + var result = await testMessage.ToClientActionResultAsync(default); + Assert.False(result.Success); + Assert.Equal(HttpStatusCode.InternalServerError, result.HttpStatusCode); + Assert.Equal("Internal server Error", result.Status); + Assert.Null(result.Content); + } + + [Fact] + public async Task ShouldNotThrowOnWrongContentType() + { + var content = new StringContent(TestContent.AsJson()); + var testMessage = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = content, + }; + + var result = await testMessage.ToClientActionResultAsync(default); + } + + [Fact] + public async Task ShouldUnwrapHttpRequest() + { + var content = new StringContent(TestContent.AsJson()); + var request = Task.FromResult(new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = content, + }); + + var result = await request.AsClientActionResultAsync(default); + Assert.True(result.Success); + Assert.Equal("Success", result.Status); + Assert.Equal(testString, result.Content?.String); + Assert.Equal(testValue, result.Content?.Value); + } + + [Fact] + public async Task ShouldAddJWTHeader() + { + var mockMessageHandler = new Mock(); + var content = new StringContent(TestContent.AsJson()); + mockMessageHandler.Protected() + .Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()) + .ReturnsAsync(new HttpResponseMessage + { + StatusCode = HttpStatusCode.Unauthorized, + Content = null + }); + mockMessageHandler.Protected() + .Setup>("SendAsync", ItExpr.Is(x => + x.Headers.Authorization != null && x.Headers.Authorization.Parameter == testToken), ItExpr.IsAny()) + .ReturnsAsync(new HttpResponseMessage + { + StatusCode = HttpStatusCode.OK, + Content = content + }); + var mockTokenProvider = new Mock(); + mockTokenProvider.Setup(x => x.GetAccessTokenAsync()) + .ReturnsAsync(testToken); + var client = new HttpClient(mockMessageHandler.Object); + var wrapper = ClientWrapperFactory.Create(client, mockTokenProvider.Object); + + var result = await wrapper.SendRequest(new HttpRequestMessage(HttpMethod.Get, "https://example.com"), default); + Assert.True(result.IsSuccessStatusCode); + } + + [Fact] + public async Task ShouldWrapHttpGetRequest() + { + var mockMessageHandler = new Mock(); + var content = new StringContent(TestContent.AsJson()); + mockMessageHandler.Protected() + .Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()) + .ReturnsAsync(new HttpResponseMessage + { + StatusCode = HttpStatusCode.OK, + Content = content + }); + var mockTokenProvider = new Mock(); + var client = new HttpClient(mockMessageHandler.Object); + var wrapper = ClientWrapperFactory.Create(client, mockTokenProvider.Object); + + var result = await wrapper.GetAsClientActionResult("https://example.com"); + Assert.True(result.Success); + } + + [Fact] + public async Task ShouldWrapHttpPostRequest() + { + var mockMessageHandler = new Mock(); + var content = new StringContent(TestContent.AsJson()); + mockMessageHandler.Protected() + .Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()) + .ReturnsAsync(new HttpResponseMessage + { + StatusCode = HttpStatusCode.OK, + Content = content + }); + var mockTokenProvider = new Mock(); + var client = new HttpClient(mockMessageHandler.Object); + var wrapper = ClientWrapperFactory.Create(client, mockTokenProvider.Object); + var model = new TestContent(); + + var result = await wrapper.PostAsClientActionResult("https://example.com", model); + Assert.True(result.Success); + } + + [Fact] + public async Task ShouldWrapHttpPutRequest() + { + var mockMessageHandler = new Mock(); + var content = new StringContent(TestContent.AsJson()); + mockMessageHandler.Protected() + .Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()) + .ReturnsAsync(new HttpResponseMessage + { + StatusCode = HttpStatusCode.OK, + Content = content + }); + var mockTokenProvider = new Mock(); + var client = new HttpClient(mockMessageHandler.Object); + var wrapper = ClientWrapperFactory.Create(client, mockTokenProvider.Object); + var model = new TestContent(); + + var result = await wrapper.PutAsClientActionResult("https://example.com", model); + Assert.True(result.Success); + } + + [Fact] + public async Task ShouldWrapHttpDeleteRequest() + { + var mockMessageHandler = new Mock(); + var content = new StringContent(TestContent.AsJson()); + mockMessageHandler.Protected() + .Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()) + .ReturnsAsync(new HttpResponseMessage + { + StatusCode = HttpStatusCode.OK, + Content = content + }); + var mockTokenProvider = new Mock(); + var client = new HttpClient(mockMessageHandler.Object); + var wrapper = ClientWrapperFactory.Create(client, mockTokenProvider.Object); + + var result = await wrapper.DeleteAsClientActionResult("https://example.com"); + Assert.True(result.Success); + } + + private class TestContent + { + public string String { get; set; } = testString; + public long Value { get; set; } = testValue; + + public static string AsJson() + { + return JsonConvert.SerializeObject(new TestContent()); + } + } + + private class WrongContent + { + public string WrongString { get; set; } = string.Empty; + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/Services/LeagueApiClientConfigurationTests.cs b/test/iRLeagueApiCore.UnitTests/Client/Services/LeagueApiClientConfigurationTests.cs new file mode 100644 index 00000000..f689a75c --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Services/LeagueApiClientConfigurationTests.cs @@ -0,0 +1,67 @@ +using iRLeagueApiCore.Client.Http; +using iRLeagueApiCore.Client.Service; +using Microsoft.Extensions.DependencyInjection; + +namespace iRLeagueApiCore.UnitTests.Client.Services; +public sealed class LeagueApiClientConfigurationTests +{ + private readonly Fixture fixture = new(); + private readonly IServiceCollection services = new ServiceCollection(); + + [Fact] + public void ShouldRegisterNewTokenStore() + { + var testTokenStore1 = Mock.Of(); + services.AddScoped(sp => testTokenStore1); + var sut = CreateSut(); + + sut.UseTokenStore(); + + var tokenStore = services.BuildServiceProvider().GetRequiredService(); + tokenStore.Should().NotBeSameAs(testTokenStore1); + tokenStore.Should().BeOfType(); + } + + [Fact] + public void ShouldRegisterNewTokenStoreInstance() + { + var testTokenStore1 = Mock.Of(); + var testTokenStore2 = new TestTokenStore(); + services.AddScoped(sp => testTokenStore1); + var sut = CreateSut(); + + sut.UseTokenStore(sp => testTokenStore2); + + var tokenStore = services.BuildServiceProvider().GetRequiredService(); + tokenStore.Should().NotBeSameAs(testTokenStore1); + tokenStore.Should().BeSameAs(testTokenStore2); + } + + [Fact] + public void ShouldSetBaseAddress() + { + var testAddress = fixture.Create(); + var sut = CreateSut(); + + sut.UseBaseAddress(testAddress.ToString()); + + sut.BaseAddress.Should().Be(testAddress.ToString()); + } + + [Fact] + public void ShouldRegisterDefaultTokenStore() + { + services.AddScoped(); + var sut = CreateSut(); + + sut.UseDefaultTokenStore(); + + var tokenProvider = services.BuildServiceProvider().GetRequiredService(); + tokenProvider.GetType().Name.Should().Be("DefaultTokenStore"); + } + + private LeagueApiClientConfiguration CreateSut() + { + return new(services); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/Services/ServiceExtensionsTests.cs b/test/iRLeagueApiCore.UnitTests/Client/Services/ServiceExtensionsTests.cs new file mode 100644 index 00000000..fad3b350 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Services/ServiceExtensionsTests.cs @@ -0,0 +1,55 @@ +using iRLeagueApiCore.Client; +using iRLeagueApiCore.Client.Http; +using Microsoft.Extensions.DependencyInjection; + +namespace iRLeagueApiCore.UnitTests.Client.Services; +public sealed class ServiceExtensionsTests +{ + private const string defaultBaseAddress = "https://irleaguemanager.net/api/"; + private readonly IServiceCollection services = new ServiceCollection(); + private readonly Fixture fixture = new(); + + [Fact] + public void ShouldAddServices_WithDefaultConfiguration() + { + services.AddLeagueApiClient(); + + var provider = services.BuildServiceProvider(); + var tokenStore = provider.GetRequiredService(); + var apiClient = provider.GetRequiredService(); + + tokenStore.GetType().Name.Should().Be("DefaultTokenStore"); + apiClient.BaseAddress.Should().Be(defaultBaseAddress); + } + + [Fact] + public void ShouldAddServices_WithDifferentBaseAddress() + { + var baseUri = fixture.Create(); + + services.AddLeagueApiClient(config => config.BaseAddress = baseUri.ToString()); + var apiClient = services.BuildServiceProvider().GetRequiredService(); + + apiClient.BaseAddress.Should().Be(baseUri); + } + + [Fact] + public void ShouldAddServices_WithDifferentTokenStore1() + { + services.AddLeagueApiClient(config => config.UseTokenStore()); + + var tokenStore = services.BuildServiceProvider().GetRequiredService(); + + tokenStore.Should().BeOfType(); + } + + [Fact] + public void ShouldAddServices_WithDifferentTokenStore2() + { + services.AddLeagueApiClient(config => config.UseTokenStore(sp => new TestTokenStore())); + + var tokenStore = services.BuildServiceProvider().GetRequiredService(); + + tokenStore.Should().BeOfType(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Client/Services/TestTokenStore.cs b/test/iRLeagueApiCore.UnitTests/Client/Services/TestTokenStore.cs new file mode 100644 index 00000000..93a463d7 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Client/Services/TestTokenStore.cs @@ -0,0 +1,63 @@ +using iRLeagueApiCore.Client.Http; + +namespace iRLeagueApiCore.UnitTests.Client.Services; + +public class TestTokenStore : ITokenStore +{ + private readonly ITokenStore mockStore = Mock.Of(); + + public bool IsLoggedIn => mockStore.IsLoggedIn; + + public DateTime AccessTokenExpires => mockStore.AccessTokenExpires; + + public event EventHandler TokenChanged + { + add + { + mockStore.TokenChanged += value; + } + + remove + { + mockStore.TokenChanged -= value; + } + } + + public event EventHandler TokenExpired + { + add + { + mockStore.TokenExpired += value; + } + + remove + { + mockStore.TokenExpired -= value; + } + } + + public Task ClearTokensAsync() + { + return mockStore.ClearTokensAsync(); + } + + public Task GetAccessTokenAsync() + { + return mockStore.GetAccessTokenAsync(); + } + + public Task GetIdTokenAsync() + { + return mockStore.GetIdTokenAsync(); + } + + public Task SetAccessTokenAsync(string token) + { + return mockStore.SetAccessTokenAsync(token); + } + + public Task SetIdTokenAsync(string token) + { + return mockStore.SetIdTokenAsync(token); + } +} \ No newline at end of file diff --git a/test/iRLeagueApiCore.UnitTests/Data/iracing-result.json b/test/iRLeagueApiCore.UnitTests/Data/iracing-result.json new file mode 100644 index 00000000..4e5898c7 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Data/iracing-result.json @@ -0,0 +1,2417 @@ +{ + "subsession_id": 52220090, + "season_id": 0, + "season_name": "Hosted iRacing", + "season_short_name": "Hosted iRacing", + "season_year": 2000, + "season_quarter": 1, + "series_id": 0, + "series_name": "Hosted iRacing", + "series_short_name": "Hosted iRacing", + "race_week_num": 0, + "session_id": 191247994, + "license_category_id": 2, + "license_category": "Road", + "private_session_id": 3125639, + "host_id": 354091, + "session_name": "Hosted Liga", + "league_id": 2432, + "league_name": "Hosted Liga", + "league_season_id": 86256, + "league_season_name": "Saison", + "restrict_results": false, + "start_time": "2022-11-10T19:01:33Z", + "end_time": "2022-11-10T21:02:47Z", + "num_laps_for_qual_average": 1, + "num_laps_for_solo_average": 1, + "corners_per_lap": 17, + "caution_type": 2, + "event_type": 5, + "event_type_name": "Race", + "driver_changes": false, + "min_team_drivers": 1, + "max_team_drivers": 1, + "driver_change_rule": 0, + "driver_change_param1": -1, + "driver_change_param2": -1, + "max_weeks": 13, + "points_type": "race", + "event_strength_of_field": 2193, + "event_average_lap": 1060052, + "event_laps_complete": 12, + "num_cautions": 0, + "num_caution_laps": 0, + "num_lead_changes": 0, + "official_session": false, + "heat_info_id": 111542, + "special_event_type": -1, + "damage_model": 0, + "can_protest": false, + "cooldown_minutes": 30, + "limit_minutes": 10080, + "track": { + "track_id": 266, + "track_name": "Autodromo Internazionale Enzo e Dino Ferrari", + "config_name": "Grand Prix", + "category_id": 2, + "category": "Road" + }, + "weather": { + "version": 0, + "type": 1, + "temp_units": 0, + "temp_value": 73, + "rel_humidity": 65, + "fog": 0, + "wind_dir": 4, + "wind_units": 0, + "wind_value": 8, + "skies": 0, + "weather_var_initial": 0, + "weather_var_ongoing": 0, + "allow_fog": false, + "track_water": 0, + "precip_option": 0, + "time_of_day": 4, + "simulated_start_utc_time": "2023-02-01T09:00:00Z", + "simulated_start_utc_offset": 60 + }, + "track_state": { + "leave_marbles": true, + "practice_rubber": 20, + "qualify_rubber": -1, + "warmup_rubber": -1, + "race_rubber": -1, + "practice_grip_compound": -1, + "qualify_grip_compound": -1, + "warmup_grip_compound": -1, + "race_grip_compound": -1 + }, + "session_results": [ + { + "simsession_number": 0, + "simsession_type": 6, + "simsession_type_name": "Race", + "simsession_subtype": 0, + "simsession_name": "FEATURE", + "results": [ + { + "cust_id": 1, + "display_name": "Member 1", + "finish_position": 0, + "finish_position_in_class": 0, + "laps_lead": 12, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 0, + "class_interval": 0, + "average_lap": 1060052, + "best_lap_num": 9, + "best_lap_time": 1052853, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 0, + "qual_lap_time": -1, + "starting_position": 0, + "starting_position_in_class": 0, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 213, + "old_cpi": 36.193985, + "oldi_rating": 2733, + "old_ttrating": 1350, + "new_license_level": 18, + "new_sub_level": 213, + "new_cpi": 36.193985, + "newi_rating": 2733, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 8, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "number_font": 10, + "number_color1": "fc00d2", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "606", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "111111", + "color2": "5481fc", + "color3": "ffffff" + }, + "helmet": { + "pattern": 22, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 2, + "display_name": "Member 2", + "finish_position": 1, + "finish_position_in_class": 1, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 133931, + "class_interval": 133931, + "average_lap": 1071208, + "best_lap_num": 9, + "best_lap_time": 1057227, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 1, + "qual_lap_time": -1, + "starting_position": 6, + "starting_position_in_class": 6, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 15, + "old_sub_level": 381, + "old_cpi": 56.448128, + "oldi_rating": 4213, + "old_ttrating": 1944, + "new_license_level": 15, + "new_sub_level": 381, + "new_cpi": 56.448128, + "newi_rating": 4213, + "new_ttrating": 1944, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 9, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 4, + "color1": "0e1b7c", + "color2": "ffffff", + "color3": "971414", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "79", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 21, + "color1": "ffffff", + "color2": "122186", + "color3": "920505" + }, + "helmet": { + "pattern": 59, + "color1": "8f171b", + "color2": "447acc", + "color3": "0e1b7c", + "face_type": 0, + "helmet_type": 0 + }, + "watched": true, + "friend": true, + "ai": false + }, + { + "cust_id": 3, + "display_name": "Member 3", + "finish_position": 2, + "finish_position_in_class": 2, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 219650, + "class_interval": 219650, + "average_lap": 1078349, + "best_lap_num": 10, + "best_lap_time": 1064499, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 2, + "qual_lap_time": -1, + "starting_position": 9, + "starting_position_in_class": 9, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 12, + "old_sub_level": 464, + "old_cpi": 50.46664, + "oldi_rating": 4663, + "old_ttrating": 1350, + "new_license_level": 12, + "new_sub_level": 464, + "new_cpi": 50.46664, + "newi_rating": 4663, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 15, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "13", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 8, + "color1": "000000", + "color2": "ebed21", + "color3": "21291f" + }, + "helmet": { + "pattern": 45, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 4, + "display_name": "Member 4", + "finish_position": 3, + "finish_position_in_class": 3, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 222737, + "class_interval": 222737, + "average_lap": 1078611, + "best_lap_num": 8, + "best_lap_time": 1057673, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 3, + "qual_lap_time": -1, + "starting_position": 3, + "starting_position_in_class": 3, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 36, + "club_name": "UK and I", + "club_shortname": "UK and I", + "division": -1, + "old_license_level": 16, + "old_sub_level": 452, + "old_cpi": 68.076324, + "oldi_rating": 5154, + "old_ttrating": 2078, + "new_license_level": 16, + "new_sub_level": 452, + "new_cpi": 68.076324, + "newi_rating": 5154, + "new_ttrating": 2078, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 10, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "18", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "8d0617", + "color2": "cccccc", + "color3": "3e13c4" + }, + "helmet": { + "pattern": 49, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 420, + "display_name": "New Member Guy", + "finish_position": 4, + "finish_position_in_class": 4, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 311398, + "class_interval": 311398, + "average_lap": 1085984, + "best_lap_num": 6, + "best_lap_time": 1062794, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 4, + "qual_lap_time": -1, + "starting_position": 23, + "starting_position_in_class": 23, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 272, + "old_cpi": 53.206207, + "oldi_rating": 2666, + "old_ttrating": 1265, + "new_license_level": 18, + "new_sub_level": 272, + "new_cpi": 53.206207, + "newi_rating": 2666, + "new_ttrating": 1265, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 13, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "3", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 9, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000" + }, + "helmet": { + "pattern": 6, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + } + ] + }, + { + "simsession_number": -1, + "simsession_type": 3, + "simsession_type_name": "Open Practice", + "simsession_subtype": 0, + "simsession_name": "WARMUP", + "results": [ + { + "cust_id": 1, + "display_name": "Member 1", + "finish_position": 0, + "finish_position_in_class": 0, + "laps_lead": 12, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 0, + "class_interval": 0, + "average_lap": 1060052, + "best_lap_num": 9, + "best_lap_time": 1052853, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 0, + "qual_lap_time": -1, + "starting_position": 0, + "starting_position_in_class": 0, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 213, + "old_cpi": 36.193985, + "oldi_rating": 2733, + "old_ttrating": 1350, + "new_license_level": 18, + "new_sub_level": 213, + "new_cpi": 36.193985, + "newi_rating": 2733, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 8, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "number_font": 10, + "number_color1": "fc00d2", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "606", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "111111", + "color2": "5481fc", + "color3": "ffffff" + }, + "helmet": { + "pattern": 22, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 2, + "display_name": "Member 2", + "finish_position": 1, + "finish_position_in_class": 1, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 133931, + "class_interval": 133931, + "average_lap": 1071208, + "best_lap_num": 9, + "best_lap_time": 1057227, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 1, + "qual_lap_time": -1, + "starting_position": 6, + "starting_position_in_class": 6, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 15, + "old_sub_level": 381, + "old_cpi": 56.448128, + "oldi_rating": 4213, + "old_ttrating": 1944, + "new_license_level": 15, + "new_sub_level": 381, + "new_cpi": 56.448128, + "newi_rating": 4213, + "new_ttrating": 1944, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 9, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 4, + "color1": "0e1b7c", + "color2": "ffffff", + "color3": "971414", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "79", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 21, + "color1": "ffffff", + "color2": "122186", + "color3": "920505" + }, + "helmet": { + "pattern": 59, + "color1": "8f171b", + "color2": "447acc", + "color3": "0e1b7c", + "face_type": 0, + "helmet_type": 0 + }, + "watched": true, + "friend": true, + "ai": false + }, + { + "cust_id": 3, + "display_name": "Member 3", + "finish_position": 2, + "finish_position_in_class": 2, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 219650, + "class_interval": 219650, + "average_lap": 1078349, + "best_lap_num": 10, + "best_lap_time": 1064499, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 2, + "qual_lap_time": -1, + "starting_position": 9, + "starting_position_in_class": 9, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 12, + "old_sub_level": 464, + "old_cpi": 50.46664, + "oldi_rating": 4663, + "old_ttrating": 1350, + "new_license_level": 12, + "new_sub_level": 464, + "new_cpi": 50.46664, + "newi_rating": 4663, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 15, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "13", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 8, + "color1": "000000", + "color2": "ebed21", + "color3": "21291f" + }, + "helmet": { + "pattern": 45, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 4, + "display_name": "Member 4", + "finish_position": 3, + "finish_position_in_class": 3, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 222737, + "class_interval": 222737, + "average_lap": 1078611, + "best_lap_num": 8, + "best_lap_time": 1057673, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 3, + "qual_lap_time": -1, + "starting_position": 3, + "starting_position_in_class": 3, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 36, + "club_name": "UK and I", + "club_shortname": "UK and I", + "division": -1, + "old_license_level": 16, + "old_sub_level": 452, + "old_cpi": 68.076324, + "oldi_rating": 5154, + "old_ttrating": 2078, + "new_license_level": 16, + "new_sub_level": 452, + "new_cpi": 68.076324, + "newi_rating": 5154, + "new_ttrating": 2078, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 10, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "18", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "8d0617", + "color2": "cccccc", + "color3": "3e13c4" + }, + "helmet": { + "pattern": 49, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 420, + "display_name": "New Member Guy", + "finish_position": 4, + "finish_position_in_class": 4, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 311398, + "class_interval": 311398, + "average_lap": 1085984, + "best_lap_num": 6, + "best_lap_time": 1062794, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 4, + "qual_lap_time": -1, + "starting_position": 23, + "starting_position_in_class": 23, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 272, + "old_cpi": 53.206207, + "oldi_rating": 2666, + "old_ttrating": 1265, + "new_license_level": 18, + "new_sub_level": 272, + "new_cpi": 53.206207, + "newi_rating": 2666, + "new_ttrating": 1265, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 13, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "3", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 9, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000" + }, + "helmet": { + "pattern": 6, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + } + ] + }, + { + "simsession_number": -2, + "simsession_type": 6, + "simsession_type_name": "Race", + "simsession_subtype": 0, + "simsession_name": "HEAT 1", + "results": [ + { + "cust_id": 1, + "display_name": "Member 1", + "finish_position": 0, + "finish_position_in_class": 0, + "laps_lead": 12, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 0, + "class_interval": 0, + "average_lap": 1060052, + "best_lap_num": 9, + "best_lap_time": 1052853, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 0, + "qual_lap_time": -1, + "starting_position": 0, + "starting_position_in_class": 0, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 213, + "old_cpi": 36.193985, + "oldi_rating": 2733, + "old_ttrating": 1350, + "new_license_level": 18, + "new_sub_level": 213, + "new_cpi": 36.193985, + "newi_rating": 2733, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 8, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "number_font": 10, + "number_color1": "fc00d2", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "606", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "111111", + "color2": "5481fc", + "color3": "ffffff" + }, + "helmet": { + "pattern": 22, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 2, + "display_name": "Member 2", + "finish_position": 1, + "finish_position_in_class": 1, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 133931, + "class_interval": 133931, + "average_lap": 1071208, + "best_lap_num": 9, + "best_lap_time": 1057227, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 1, + "qual_lap_time": -1, + "starting_position": 6, + "starting_position_in_class": 6, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 15, + "old_sub_level": 381, + "old_cpi": 56.448128, + "oldi_rating": 4213, + "old_ttrating": 1944, + "new_license_level": 15, + "new_sub_level": 381, + "new_cpi": 56.448128, + "newi_rating": 4213, + "new_ttrating": 1944, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 9, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 4, + "color1": "0e1b7c", + "color2": "ffffff", + "color3": "971414", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "79", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 21, + "color1": "ffffff", + "color2": "122186", + "color3": "920505" + }, + "helmet": { + "pattern": 59, + "color1": "8f171b", + "color2": "447acc", + "color3": "0e1b7c", + "face_type": 0, + "helmet_type": 0 + }, + "watched": true, + "friend": true, + "ai": false + }, + { + "cust_id": 3, + "display_name": "Member 3", + "finish_position": 2, + "finish_position_in_class": 2, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 219650, + "class_interval": 219650, + "average_lap": 1078349, + "best_lap_num": 10, + "best_lap_time": 1064499, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 2, + "qual_lap_time": -1, + "starting_position": 9, + "starting_position_in_class": 9, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 12, + "old_sub_level": 464, + "old_cpi": 50.46664, + "oldi_rating": 4663, + "old_ttrating": 1350, + "new_license_level": 12, + "new_sub_level": 464, + "new_cpi": 50.46664, + "newi_rating": 4663, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 15, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "13", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 8, + "color1": "000000", + "color2": "ebed21", + "color3": "21291f" + }, + "helmet": { + "pattern": 45, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 4, + "display_name": "Member 4", + "finish_position": 3, + "finish_position_in_class": 3, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 222737, + "class_interval": 222737, + "average_lap": 1078611, + "best_lap_num": 8, + "best_lap_time": 1057673, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 3, + "qual_lap_time": -1, + "starting_position": 3, + "starting_position_in_class": 3, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 36, + "club_name": "UK and I", + "club_shortname": "UK and I", + "division": -1, + "old_license_level": 16, + "old_sub_level": 452, + "old_cpi": 68.076324, + "oldi_rating": 5154, + "old_ttrating": 2078, + "new_license_level": 16, + "new_sub_level": 452, + "new_cpi": 68.076324, + "newi_rating": 5154, + "new_ttrating": 2078, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 10, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "18", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "8d0617", + "color2": "cccccc", + "color3": "3e13c4" + }, + "helmet": { + "pattern": 49, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 420, + "display_name": "New Member Guy", + "finish_position": 4, + "finish_position_in_class": 4, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 311398, + "class_interval": 311398, + "average_lap": 1085984, + "best_lap_num": 6, + "best_lap_time": 1062794, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 4, + "qual_lap_time": -1, + "starting_position": 23, + "starting_position_in_class": 23, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 272, + "old_cpi": 53.206207, + "oldi_rating": 2666, + "old_ttrating": 1265, + "new_license_level": 18, + "new_sub_level": 272, + "new_cpi": 53.206207, + "newi_rating": 2666, + "new_ttrating": 1265, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 13, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "3", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 9, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000" + }, + "helmet": { + "pattern": 6, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + } + ] + }, + { + "simsession_number": -3, + "simsession_type": 4, + "simsession_type_name": "Lone Qualifying", + "simsession_subtype": 0, + "simsession_name": "QUALIFY", + "results": [ + { + "cust_id": 1, + "display_name": "Member 1", + "finish_position": 0, + "finish_position_in_class": 0, + "laps_lead": 12, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 0, + "class_interval": 0, + "average_lap": 1060052, + "best_lap_num": 9, + "best_lap_time": 1052853, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 0, + "qual_lap_time": -1, + "starting_position": 0, + "starting_position_in_class": 0, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 213, + "old_cpi": 36.193985, + "oldi_rating": 2733, + "old_ttrating": 1350, + "new_license_level": 18, + "new_sub_level": 213, + "new_cpi": 36.193985, + "newi_rating": 2733, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 8, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "number_font": 10, + "number_color1": "fc00d2", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "606", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "111111", + "color2": "5481fc", + "color3": "ffffff" + }, + "helmet": { + "pattern": 22, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 2, + "display_name": "Member 2", + "finish_position": 1, + "finish_position_in_class": 1, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 133931, + "class_interval": 133931, + "average_lap": 1071208, + "best_lap_num": 9, + "best_lap_time": 1057227, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 1, + "qual_lap_time": -1, + "starting_position": 6, + "starting_position_in_class": 6, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 15, + "old_sub_level": 381, + "old_cpi": 56.448128, + "oldi_rating": 4213, + "old_ttrating": 1944, + "new_license_level": 15, + "new_sub_level": 381, + "new_cpi": 56.448128, + "newi_rating": 4213, + "new_ttrating": 1944, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 9, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 4, + "color1": "0e1b7c", + "color2": "ffffff", + "color3": "971414", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "79", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 21, + "color1": "ffffff", + "color2": "122186", + "color3": "920505" + }, + "helmet": { + "pattern": 59, + "color1": "8f171b", + "color2": "447acc", + "color3": "0e1b7c", + "face_type": 0, + "helmet_type": 0 + }, + "watched": true, + "friend": true, + "ai": false + }, + { + "cust_id": 3, + "display_name": "Member 3", + "finish_position": 2, + "finish_position_in_class": 2, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 219650, + "class_interval": 219650, + "average_lap": 1078349, + "best_lap_num": 10, + "best_lap_time": 1064499, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 2, + "qual_lap_time": -1, + "starting_position": 9, + "starting_position_in_class": 9, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 12, + "old_sub_level": 464, + "old_cpi": 50.46664, + "oldi_rating": 4663, + "old_ttrating": 1350, + "new_license_level": 12, + "new_sub_level": 464, + "new_cpi": 50.46664, + "newi_rating": 4663, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 15, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "13", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 8, + "color1": "000000", + "color2": "ebed21", + "color3": "21291f" + }, + "helmet": { + "pattern": 45, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 4, + "display_name": "Member 4", + "finish_position": 3, + "finish_position_in_class": 3, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 222737, + "class_interval": 222737, + "average_lap": 1078611, + "best_lap_num": 8, + "best_lap_time": 1057673, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 3, + "qual_lap_time": -1, + "starting_position": 3, + "starting_position_in_class": 3, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 36, + "club_name": "UK and I", + "club_shortname": "UK and I", + "division": -1, + "old_license_level": 16, + "old_sub_level": 452, + "old_cpi": 68.076324, + "oldi_rating": 5154, + "old_ttrating": 2078, + "new_license_level": 16, + "new_sub_level": 452, + "new_cpi": 68.076324, + "newi_rating": 5154, + "new_ttrating": 2078, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 10, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "18", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "8d0617", + "color2": "cccccc", + "color3": "3e13c4" + }, + "helmet": { + "pattern": 49, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 420, + "display_name": "New Member Guy", + "finish_position": 4, + "finish_position_in_class": 4, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 311398, + "class_interval": 311398, + "average_lap": 1085984, + "best_lap_num": 6, + "best_lap_time": 1062794, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 4, + "qual_lap_time": -1, + "starting_position": 23, + "starting_position_in_class": 23, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 272, + "old_cpi": 53.206207, + "oldi_rating": 2666, + "old_ttrating": 1265, + "new_license_level": 18, + "new_sub_level": 272, + "new_cpi": 53.206207, + "newi_rating": 2666, + "new_ttrating": 1265, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 13, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "3", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 9, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000" + }, + "helmet": { + "pattern": 6, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + } + ] + }, + { + "simsession_number": -4, + "simsession_type": 3, + "simsession_type_name": "Open Practice", + "simsession_subtype": 0, + "simsession_name": "PRACTICE", + "results": [ + { + "cust_id": 1, + "display_name": "Member 1", + "finish_position": 0, + "finish_position_in_class": 0, + "laps_lead": 12, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 0, + "class_interval": 0, + "average_lap": 1060052, + "best_lap_num": 9, + "best_lap_time": 1052853, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 0, + "qual_lap_time": -1, + "starting_position": 0, + "starting_position_in_class": 0, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 213, + "old_cpi": 36.193985, + "oldi_rating": 2733, + "old_ttrating": 1350, + "new_license_level": 18, + "new_sub_level": 213, + "new_cpi": 36.193985, + "newi_rating": 2733, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 8, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "number_font": 10, + "number_color1": "fc00d2", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "606", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "111111", + "color2": "5481fc", + "color3": "ffffff" + }, + "helmet": { + "pattern": 22, + "color1": "ff0000", + "color2": "000000", + "color3": "fffc00", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 2, + "display_name": "Member 2", + "finish_position": 1, + "finish_position_in_class": 1, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 133931, + "class_interval": 133931, + "average_lap": 1071208, + "best_lap_num": 9, + "best_lap_time": 1057227, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 1, + "qual_lap_time": -1, + "starting_position": 6, + "starting_position_in_class": 6, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 15, + "old_sub_level": 381, + "old_cpi": 56.448128, + "oldi_rating": 4213, + "old_ttrating": 1944, + "new_license_level": 15, + "new_sub_level": 381, + "new_cpi": 56.448128, + "newi_rating": 4213, + "new_ttrating": 1944, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 9, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 4, + "color1": "0e1b7c", + "color2": "ffffff", + "color3": "971414", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "79", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 21, + "color1": "ffffff", + "color2": "122186", + "color3": "920505" + }, + "helmet": { + "pattern": 59, + "color1": "8f171b", + "color2": "447acc", + "color3": "0e1b7c", + "face_type": 0, + "helmet_type": 0 + }, + "watched": true, + "friend": true, + "ai": false + }, + { + "cust_id": 3, + "display_name": "Member 3", + "finish_position": 2, + "finish_position_in_class": 2, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 219650, + "class_interval": 219650, + "average_lap": 1078349, + "best_lap_num": 10, + "best_lap_time": 1064499, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 2, + "qual_lap_time": -1, + "starting_position": 9, + "starting_position_in_class": 9, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 12, + "old_sub_level": 464, + "old_cpi": 50.46664, + "oldi_rating": 4663, + "old_ttrating": 1350, + "new_license_level": 12, + "new_sub_level": 464, + "new_cpi": 50.46664, + "newi_rating": 4663, + "new_ttrating": 1350, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 15, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "13", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 8, + "color1": "000000", + "color2": "ebed21", + "color3": "21291f" + }, + "helmet": { + "pattern": 45, + "color1": "000000", + "color2": "43462f", + "color3": "b4ba53", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 4, + "display_name": "Member 4", + "finish_position": 3, + "finish_position_in_class": 3, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 222737, + "class_interval": 222737, + "average_lap": 1078611, + "best_lap_num": 8, + "best_lap_time": 1057673, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 3, + "qual_lap_time": -1, + "starting_position": 3, + "starting_position_in_class": 3, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 36, + "club_name": "UK and I", + "club_shortname": "UK and I", + "division": -1, + "old_license_level": 16, + "old_sub_level": 452, + "old_cpi": 68.076324, + "oldi_rating": 5154, + "old_ttrating": 2078, + "new_license_level": 16, + "new_sub_level": 452, + "new_cpi": 68.076324, + "newi_rating": 5154, + "new_ttrating": 2078, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 10, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "18", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 1, + "color1": "8d0617", + "color2": "cccccc", + "color3": "3e13c4" + }, + "helmet": { + "pattern": 49, + "color1": "feef1b", + "color2": "ffffff", + "color3": "fe2725", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + }, + { + "cust_id": 420, + "display_name": "New Member Guy", + "finish_position": 4, + "finish_position_in_class": 4, + "laps_lead": 0, + "laps_complete": 12, + "opt_laps_complete": 0, + "interval": 311398, + "class_interval": 311398, + "average_lap": 1085984, + "best_lap_num": 6, + "best_lap_time": 1062794, + "best_nlaps_num": -1, + "best_nlaps_time": -1, + "best_qual_lap_at": "1970-01-01T00:00:00Z", + "best_qual_lap_num": -1, + "best_qual_lap_time": -1, + "reason_out_id": 0, + "reason_out": "Running", + "champ_points": 0, + "drop_race": false, + "club_points": 0, + "position": 4, + "qual_lap_time": -1, + "starting_position": 23, + "starting_position_in_class": 23, + "car_class_id": 3188, + "car_class_name": "iRacing Formula iR-04", + "car_class_short_name": "Formula iR-04", + "club_id": 42, + "club_name": "DE-AT-CH", + "club_shortname": "DE-AT-CH", + "division": -1, + "old_license_level": 18, + "old_sub_level": 272, + "old_cpi": 53.206207, + "oldi_rating": 2666, + "old_ttrating": 1265, + "new_license_level": 18, + "new_sub_level": 272, + "new_cpi": 53.206207, + "newi_rating": 2666, + "new_ttrating": 1265, + "multiplier": 1, + "license_change_oval": -1, + "license_change_road": -1, + "incidents": 13, + "max_pct_fuel_fill": -1, + "weight_penalty_kg": -1, + "league_points": 0, + "league_agg_points": 0, + "car_id": 148, + "car_name": "iRacing Formula iR-04", + "aggregate_champ_points": 0, + "livery": { + "car_id": 148, + "pattern": 1, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "number_font": 0, + "number_color1": "ffffff", + "number_color2": "777777", + "number_color3": "000000", + "number_slant": 0, + "sponsor1": 0, + "sponsor2": 0, + "car_number": "3", + "wheel_color": null, + "rim_type": -1 + }, + "suit": { + "pattern": 9, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000" + }, + "helmet": { + "pattern": 6, + "color1": "ffffff", + "color2": "1a4b9b", + "color3": "dff000", + "face_type": 0, + "helmet_type": 0 + }, + "watched": false, + "friend": false, + "ai": false + } + ] + } + ], + "race_summary": { + "subsession_id": 52220090, + "average_lap": 1060052, + "laps_complete": 12, + "num_cautions": 0, + "num_caution_laps": 0, + "num_lead_changes": 0, + "field_strength": 2193, + "heat_info_id": 111542, + "num_opt_laps": 0, + "has_opt_path": false, + "special_event_type": 0, + "special_event_type_text": "Not a special event" + }, + "car_classes": [ + { + "car_class_id": 3188, + "cars_in_class": [ + { + "car_id": 148 + } + ], + "name": "iRacing Formula iR-04", + "short_name": "Formula iR-04" + } + ], + "results_restricted": false, + "associated_subsession_ids": [ + 52220090 + ] +} \ No newline at end of file diff --git a/test/iRLeagueApiCore.UnitTests/Extensions/EnumerableExtensions.cs b/test/iRLeagueApiCore.UnitTests/Extensions/EnumerableExtensions.cs new file mode 100644 index 00000000..bb0d5f21 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Extensions/EnumerableExtensions.cs @@ -0,0 +1,15 @@ +namespace iRLeagueApiCore.UnitTests.Extensions; + +public static class EnumerableExtensions +{ + public static T Random(this IEnumerable list, Random random) + { + return list.ElementAt(random.Next(list.Count())); + } + + public static IEnumerable Shuffle(this IEnumerable list, Random? random = default) + { + random ??= new(); + return list.OrderBy(x => random.Next()); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Fixtures/AddContexts.cs b/test/iRLeagueApiCore.UnitTests/Fixtures/AddContexts.cs new file mode 100644 index 00000000..a6644b59 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Fixtures/AddContexts.cs @@ -0,0 +1,89 @@ +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Server.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.Security.Claims; + +namespace iRLeagueApiCore.UnitTests.Fixtures; + +public static class AddContexts +{ + public static ClaimsPrincipal User => new ClaimsPrincipal(new ClaimsIdentity(new Claim[] + { + new Claim(ClaimTypes.Name, "unitTestUser"), + new Claim(ClaimTypes.NameIdentifier, "1"), + new Claim(ClaimTypes.Role, UserRoles.User), + new Claim("custom-claim", "example claim value"), + }, "mock")); + + /// + /// Add the default HttpContext to the provided controller + /// + /// type of ApiController + /// Controller to add context + /// Controller with added context + public static T AddMemberControllerContext(T controller) where T : Controller + { + var user = User; + var identity = (ClaimsIdentity?)user.Identity; + identity?.AddClaim(new Claim(ClaimTypes.Role, $"{"TestLeague".ToLower()}:{LeagueRoles.Member}")); + controller.ControllerContext = new ControllerContext() + { + HttpContext = new DefaultHttpContext() { User = user } + }; + + return controller; + } + + public static T AddLeagueAdminControllerContext(T controller, string leagueName) where T : Controller + { + var user = User; + var identity = (ClaimsIdentity?)user.Identity; + identity?.AddClaim(new Claim(ClaimTypes.Role, $"{leagueName.ToLower()}:{LeagueRoles.Admin}")); + controller.ControllerContext = new ControllerContext() + { + HttpContext = new DefaultHttpContext() { User = user } + }; + + return controller; + } + + public static T AddAdminControllerContext(T controller) where T : Controller + { + var user = User; + var identity = (ClaimsIdentity?)user.Identity; + identity?.AddClaim(new Claim(ClaimTypes.Role, UserRoles.Admin)); + controller.ControllerContext = new ControllerContext() + { + HttpContext = new DefaultHttpContext() { User = user } + }; + + return controller; + } + + public static T AddControllerContext(T controller, IEnumerable roles) where T : Controller + { + var user = User; + var identity = (ClaimsIdentity?)user.Identity; + foreach (var role in roles.Where(x => string.IsNullOrEmpty(x) == false)) + { + identity?.AddClaim(new Claim(ClaimTypes.Role, role)); + } + controller.ControllerContext = new ControllerContext() + { + HttpContext = new DefaultHttpContext() { User = user } + }; + + return controller; + } + + public static T AddControllerContextWithoutLeagueRole(T controller) where T : Controller + { + controller.ControllerContext = new ControllerContext() + { + HttpContext = new DefaultHttpContext() { User = User } + }; + + return controller; + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Fixtures/DbTestFixture.cs b/test/iRLeagueApiCore.UnitTests/Fixtures/DbTestFixture.cs new file mode 100644 index 00000000..995ab205 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Fixtures/DbTestFixture.cs @@ -0,0 +1,439 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Server.Models; +using iRLeagueApiCore.UnitTests.Extensions; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; + +namespace iRLeagueApiCore.UnitTests.Fixtures; + +public sealed class DbTestFixture : DataAccessTestsBase +{ + public static string ClientUserName => "TestClient"; + public static string ClientGuid => "6a6a6e09-f4b7-4ccb-a8ae-f2fc85d897dd"; + public LeagueDbContext DbContext => dbContext; + + public DbTestFixture() + { + } + + public LeagueDbContext CreateDbContext() + { + var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + return dbContext; + } + + public void Populate(LeagueDbContext context, Random random) + { + // Create random users + var users = new List(); + for (int i = 0; i < 10; i++) + { + var user = LeagueUser.Empty; + user.Id = Guid.NewGuid().ToString(); + user.Name = GetRandomName(random); + users.Add(user); + } + // Populate Tracks + for (int i = 0; i < 2; i++) + { + var group = new TrackGroupEntity() + { + TrackName = $"Group{i}", + Location = "Testlocation" + }; + for (int j = 0; j < 3; j++) + { + var config = new TrackConfigEntity() + { + ConfigName = $"Config{i}", + ConfigType = ConfigType.Road, + Turns = j * 3, + LengthKm = j * 1.0, + HasNightLighting = false + }; + group.TrackConfigs.Add(config); + } + context.TrackGroups.Add(group); + } + // create models + var league1 = new LeagueEntity() + { + Name = "TestLeague", + NameFull = "League for unit testing" + }; + var season1 = new SeasonEntity() + { + SeasonName = "Season One", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + League = league1 + }; + var season2 = new SeasonEntity() + { + SeasonName = "Season Two", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + League = league1 + }; + var schedule1 = new ScheduleEntity() + { + Name = "S1 Schedule", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + var schedule2 = new ScheduleEntity() + { + Name = "S2 Schedule 1", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + var schedule3 = new ScheduleEntity() + { + Name = "S2 Schedule 2", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + // Create events on schedule1 + for (int i = 0; i < 5; i++) + { + var @event = new EventEntity() + { + Name = $"S1 Event {i + 1}", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + Track = context.TrackGroups + .SelectMany(x => x.TrackConfigs) + .Skip(i) + .FirstOrDefault(), + }; + var session = new SessionEntity() + { + Name = "Race", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + SessionType = SessionType.Race, + Laps = random.Next(22) + 10, + Duration = TimeSpan.FromMinutes(random.Next(20) + 10), + }; + @event.Sessions.Add(session); + schedule1.Events.Add(@event); + } + for (int i = 0; i < 2; i++) + { + var @event = new EventEntity() + { + Name = $"S2 Event {i + 1}", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + Track = context.TrackGroups + .SelectMany(x => x.TrackConfigs) + .Skip(i) + .FirstOrDefault(), + }; + var session = new SessionEntity() + { + Name = "Race", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + SessionType = SessionType.Race, + Duration = TimeSpan.FromMinutes(random.Next(20) + 10), + }; + @event.Sessions.Add(session); + schedule2.Events.Add(@event); + } + context.Leagues.Add(league1); + league1.Seasons.Add(season1); + league1.Seasons.Add(season2); + season1.Schedules.Add(schedule1); + season2.Schedules.Add(schedule2); + season2.Schedules.Add(schedule3); + + // create league2 + var league2 = new LeagueEntity() + { + Name = "TestLeague2", + NameFull = "Second League for unit testing" + }; + var l2season1 = new SeasonEntity() + { + SeasonName = "L2 Season One", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid, + League = league1 + }; + var l2schedule1 = new ScheduleEntity() + { + Name = "L2S1 Schedule 1", + CreatedOn = DateTime.Now, + CreatedByUserName = ClientUserName, + CreatedByUserId = ClientGuid, + LastModifiedOn = DateTime.Now, + LastModifiedByUserName = ClientUserName, + LastModifiedByUserId = ClientGuid + }; + + context.Leagues.Add(league2); + league2.Seasons.Add(l2season1); + l2season1.Schedules.Add(l2schedule1); + + GenerateMembers(context, random); + + // assign members to league + var members = context.Members + .Local + .ToList(); + var leagues = context.Leagues + .Local + .ToList(); + foreach (var member in members) + { + foreach (var league in leagues) + { + var leagueMember = new LeagueMemberEntity() + { + Member = member, + }; + league.LeagueMembers.Add(leagueMember); + } + } + + // create results + var resultConfig = new ResultConfigurationEntity() + { + Name = "Resultconfig 1", + DisplayName = "Overall", + ResultsPerTeam = random.Next(1, 10), + }; + var scoring = new ScoringEntity() + { + Name = "Scoring 1", + ShowResults = true + }; + var pointRule = new PointRuleEntity() + { + Name = "Pointrule 1", + BonusPoints = new BonusPointModel[] + { + new() { Type = BonusPointType.Position, Value = 1, Points = 5 }, + new() { Type = BonusPointType.Position, Value = 2, Points = 3 }, + new() { Type = BonusPointType.Position, Value = 3, Points = 1 }, + }, + FinalSortOptions = new SortOptions[] { SortOptions.TotalPtsAsc, SortOptions.PenPtsDesc }, + MaxPoints = 30, + PointDropOff = 1, + PointsPerPlace = new int[] { 5, 4, 3, 2, 1 }, + PointsSortOptions = new SortOptions[] { SortOptions.PosAsc, SortOptions.IntvlAsc }, + }; + resultConfig.Scorings.Add(scoring); + league1.ResultConfigs.Add(resultConfig); + league1.PointRules.Add(pointRule); + + foreach (var @event in league1.Seasons + .SelectMany(x => x.Schedules) + .SelectMany(x => x.Events) + .SkipLast(1)) + { + var eventResult = new EventResultEntity(); + var scoredResult = new ScoredEventResultEntity() + { + Name = resultConfig.DisplayName, + }; + foreach (var session in @event.Sessions) + { + var sessionResult = new SessionResultEntity(); + sessionResult.Session = session; + eventResult.SessionResults.Add(sessionResult); + var scoredSessionResult = new ScoredSessionResultEntity(); + scoredSessionResult.Name = session.Name; + scoredResult.ScoredSessionResults.Add(scoredSessionResult); + for (int i = 0; i < 10; i++) + { + var resultRow = new ResultRowEntity() + { + StartPosition = i + 1, + FinishPosition = i + 1, + Member = members.ElementAt(i), + QualifyingTime = GetTimeSpan(random), + FastestLapTime = GetTimeSpan(random), + AvgLapTime = GetTimeSpan(random), + Interval = GetTimeSpan(random), + }; + sessionResult.ResultRows.Add(resultRow); + var scoredResultRow = new ScoredResultRowEntity(resultRow) + { + FinalPosition = i + 1, + RacePoints = 10 - i, + TotalPoints = 10 - i + }; + scoredSessionResult.ScoredResultRows.Add(scoredResultRow); + } + } + @event.EventResult = eventResult; + @event.ScoredEventResults.Add(scoredResult); + } + + // Create reviews + for (int i = 0; i < 3; i++) + { + var cat = new VoteCategoryEntity() + { + Index = i, + Text = $"Cat {i + 1}", + DefaultPenalty = i + 1, + }; + league1.VoteCategories.Add(cat); + } + foreach (var session in league1.Seasons + .SelectMany(x => x.Schedules) + .SelectMany(x => x.Events) + .SelectMany(x => x.Sessions)) + { + var involvedMembers = new[] + { + members.Random(random), + members.Random(random), + members.Random(random), + }.Distinct().ToList(); + var review = CreateVersion(new IncidentReviewEntity() + { + AuthorName = GetRandomName(random), + AuthorUserId = Guid.NewGuid().ToString(), + Corner = random.Next(1, 12).ToString(), + FullDescription = "Full Description", + IncidentKind = "Incident Kind", + IncidentNr = random.Next(1, 12).ToString(), + InvolvedMembers = involvedMembers, + OnLap = random.Next(1, 12).ToString(), + TimeStamp = TimeSpan.FromMinutes(1), + ResultLongText = "Long text for much more details on the result", + Comments = new[] { RandomComment(random, users.Random(random), involvedMembers), RandomComment(random, users.Random(random), involvedMembers) }.ToList(), + AcceptedReviewVotes = new[] {new AcceptedReviewVoteEntity() + { + MemberAtFault = involvedMembers.Random(random), + Description = "Description", + } }.ToList(), + }, users.Random(random)); + session.IncidentReviews.Add(review); + } + } + + private static TimeSpan GetTimeSpan(Random random) + { + return new TimeSpan(0, 1, 2, 34, 567); + } + private void GenerateMembers(LeagueDbContext context, Random random) + { + var minMemberCount = 50; + var maxMemberCount = 100; + + var memberCount = random.Next(maxMemberCount - minMemberCount + 1) + minMemberCount; + + for (int i = 0; i < memberCount; i++) + { + var member = new MemberEntity() + { + Firstname = GetRandomName(random), + Lastname = GetRandomName(random), + IRacingId = GetRandomIracingId(random) + }; + context.Members.Add(member); + } + } + + private static string GetRandomName(Random random) + { + var minLen = 3; + var len = random.Next(10) + minLen; + char[] name = new char[len]; + char[] characters = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ßÄÜÖäüö".ToCharArray(); + + for (int i = 0; i < len; i++) + { + var offset = random.Next(characters.Length); + name[i] = characters[offset]; + } + return new string(name); + } + + private string GetRandomIracingId(Random random) + { + return fixture.Create().ToString(); + } + + private static ReviewCommentEntity RandomComment(Random random, LeagueUser user, IEnumerable involvedMembers) + { + var comment = CreateVersion(new ReviewCommentEntity() + { + AuthorName = user.Name, + AuthorUserId = user.Id, + Date = DateTime.Now, + Text = "Random Comment Text: " + GetRandomName(random), + ReviewCommentVotes = new[] { new ReviewCommentVoteEntity() + { + MemberAtFault = involvedMembers.Random(random), + Description = "Description", + } }.ToList(), + }, user); + return comment; + } + + private static T CreateVersion(T entity, LeagueUser user) where T : IVersionEntity + { + entity.Version = 1; + entity.CreatedByUserId = user.Id; + entity.CreatedByUserName = user.Name; + entity.CreatedOn = DateTime.Now; + entity.LastModifiedByUserId = user.Id; + entity.LastModifiedByUserName = user.Name; + entity.LastModifiedOn = DateTime.Now; + return entity; + } + + public void Dispose() + { + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Fixtures/IdentityFixture.cs b/test/iRLeagueApiCore.UnitTests/Fixtures/IdentityFixture.cs new file mode 100644 index 00000000..dfe6aa39 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Fixtures/IdentityFixture.cs @@ -0,0 +1,116 @@ +using FluentValidation; +using FluentValidation.Results; +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Server.Authentication; +using MediatR; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.AspNetCore.Identity.Test; +using static Microsoft.AspNetCore.Identity.Test.MockHelpers; +using System.Data; + +namespace iRLeagueApiCore.UnitTests.Fixtures; + +public sealed class IdentityFixture +{ + public readonly string testLeague = "TestLeague"; + public readonly ApplicationUser validUser = new ApplicationUser() + { + UserName = "TestUser" + }; + public readonly string testRole = LeagueRoles.Organizer; + public string testLeagueRoleName => LeagueRoles.GetLeagueRoleName(testLeague, testRole) ?? string.Empty; + public IdentityRole testLeagueRole => new IdentityRole(testLeagueRoleName); + public readonly string[] inRoles = new string[] + { + LeagueRoles.Member, + LeagueRoles.Steward + }; + public UserManager UserManager { get; private set; } = default!; + public RoleManager RoleManager { get; private set; } = default!; + public IUserRoleStore UserRoleStore { get; private set; } = default!; + public IUserStore UserStore { get; private set; } = default!; + public IRoleStore RoleStore { get; private set; } = default!; + public List Users { get; private set; } = default!; + public Dictionary Roles { get; private set; } = default!; + public Dictionary> UserRoles { get; private set; } = default!; + + public IdentityFixture() + { + } + + [Fact] + public async Task TestDefaultSetup() + { + var testUserManager = GetDefaultMockUserManager().Object; + var testRoleManager = GetDefaultMockRoleManager().Object; + var testValidator = GetDefaultValidator().Object; + Assert.NotNull(await testUserManager.FindByNameAsync(validUser.UserName)); + Assert.True(await testRoleManager.RoleExistsAsync(testLeagueRoleName)); + Assert.True(testValidator.Validate(Unit.Value).IsValid); + } + + public Mock> GetDefaultMockUserManager() + { + var mockUserManager = MockHelpers.MockUserManager(); + mockUserManager.Setup(x => x.FindByNameAsync(It.Is(x => x == validUser.UserName))) + .ReturnsAsync(validUser); + return mockUserManager; + } + + public Mock> GetDefaultMockRoleManager() + { + var mockRoleManager = MockHelpers.MockRoleManager(); + mockRoleManager.Setup(x => x.RoleExistsAsync(It.Is(x => x == testLeagueRoleName))) + .ReturnsAsync(true); + return mockRoleManager; + } + + public Mock> GetDefaultValidator() + { + var mockValidator = MockHelpers.MockValidator(); + mockValidator.SetReturnsDefault(new ValidationResult()); + mockValidator.SetReturnsDefault(Task.FromResult(new ValidationResult())); + return mockValidator; + } + + public ValidationResult GetSuccessResult() + { + return new ValidationResult(); + } + + public ValidationResult GetFailedResult() + { + return new ValidationResult(new ValidationFailure[] + { + new ValidationFailure("Property1", "Message1"), + new ValidationFailure("Property2", "Message2") + }); + } + + [Fact] + public void Setup() + { + Users = new(); + Roles = new(); + UserRoles = new(); + UserStore = TestUserStore(Users); + RoleStore = TestRoleStore(Roles); + UserRoleStore = TestUserRoleStore(UserStore, RoleStore, UserRoles); + UserManager = TestUserManager(UserRoleStore); + RoleManager = TestRoleManager(RoleStore); + } + + public async Task DisposeAsync() + { + await Task.CompletedTask; + } +} + +public static class IndentiyFixtureExtensions +{ + public static IEnumerable ToEnumerable(this T single) + { + return new T[] { single }; + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Fixtures/MockHelpers.cs b/test/iRLeagueApiCore.UnitTests/Fixtures/MockHelpers.cs new file mode 100644 index 00000000..443d2fb5 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Fixtures/MockHelpers.cs @@ -0,0 +1,445 @@ +// From https://github.com/dotnet/aspnetcore/blob/main/src/Identity/test/Shared/MockHelpers.cs + +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using FluentValidation; +using iRLeagueApiCore.Services.ResultService.Extensions; +using MediatR; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Moq.Protected; +using System.Linq.Expressions; +using System.Text; + +namespace Microsoft.AspNetCore.Identity.Test; + +public static class MockHelpers +{ + public static StringBuilder LogMessage = new StringBuilder(); + + public static Mock> MockUserManager() where TUser : class + { + var store = new Mock>(); + var mgr = new Mock>(store.Object, null, null, null, null, null, null, null, null); + mgr.Object.UserValidators.Add(new UserValidator()); + mgr.Object.PasswordValidators.Add(new PasswordValidator()); + return mgr; + } + + public static Mock> MockRoleManager(IRoleStore? store = null) where TRole : class + { + store ??= new Mock>().Object; + var roles = new List>(); + roles.Add(new RoleValidator()); + return new Mock>(store, roles, MockLookupNormalizer(), + new IdentityErrorDescriber(), null); + } + + public static UserManager TestUserManager(IUserStore? store = null) where TUser : class + { + store ??= new Mock>().Object; + var options = new Mock>(); + var idOptions = new IdentityOptions(); + idOptions.Lockout.AllowedForNewUsers = false; + options.Setup(o => o.Value).Returns(idOptions); + var userValidators = new List>(); + var validator = new Mock>(); + userValidators.Add(validator.Object); + var pwdValidators = new List> + { + new PasswordValidator() + }; + var userManager = new UserManager(store, options.Object, new PasswordHasher(), + userValidators, pwdValidators, MockLookupNormalizer(), + new IdentityErrorDescriber(), null, + new Mock>>().Object); + validator.Setup(v => v.ValidateAsync(userManager, It.IsAny())) + .Returns(Task.FromResult(IdentityResult.Success)).Verifiable(); + return userManager; + } + + public static IUserStore TestUserStore(List? users = null) where T : IdentityUser + { + var userStoreList = users ?? new(); + var normalizer = MockLookupNormalizer(); + userStoreList.ForEach(x => x.NormalizedUserName = normalizer.NormalizeName(x.UserName)); + var store = new Mock>(); + store.Setup(x => x.FindByIdAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((string id, CancellationToken cancellationToken) => + userStoreList.FirstOrDefault(x => x.Id == id)!); + store.Setup(x => x.CreateAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((T user, CancellationToken cancellationToken) => + { + var normalizedName = normalizer.NormalizeName(user.UserName); + if (userStoreList.Any(x => x.UserName == user.UserName || x.NormalizedUserName == normalizedName)) + { + return IdentityResult.Failed(new[] { new IdentityErrorDescriber().DuplicateUserName(user.UserName) }); + } + userStoreList.Add(user); + return IdentityResult.Success; + }); + store.Setup(x => x.GetUserNameAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((T User, CancellationToken cancellationToken) => User.UserName); + store.Setup(x => x.SetNormalizedUserNameAsync(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback((T user, string normalizedName, CancellationToken cancellationToken) => + { + var storeUser = userStoreList.FirstOrDefault(x => x == user); + if (storeUser is null) + { + return; + } + storeUser.NormalizedUserName = normalizedName; + }); + store.Setup(x => x.UpdateAsync(It.IsAny(), It.IsAny())) + .Returns(async (T user, CancellationToken cancellationToken) => + { + var storeUserIndex = userStoreList.FindIndex(x => x.Id == user.Id); + if (storeUserIndex == -1) + { + return await store.Object.CreateAsync(user, cancellationToken); + } + userStoreList[storeUserIndex] = user; + return IdentityResult.Success; + }); + return store.Object; + } + + public static IUserRoleStore TestUserRoleStore( + IUserStore? userStore = null, + IRoleStore? roleStore = null, + IDictionary>? userRoles = null) + where TUser : IdentityUser where TRole : IdentityRole + { + userStore ??= TestUserStore(); + roleStore ??= TestRoleStore(); + userRoles ??= new Dictionary>(); + return new UserRoleStore(userStore, roleStore, userRoles); + } + + public static RoleManager TestRoleManager(IRoleStore? store = null) where TRole : class + { + store ??= new Mock>().Object; + var roles = new List> + { + new RoleValidator() + }; + return new RoleManager(store, roles, + MockLookupNormalizer(), + new IdentityErrorDescriber(), + null); + } + + public static IRoleStore TestRoleStore(IDictionary? roles = null) where TRole : IdentityRole + { + var roleStoreDict = roles ?? new Dictionary(); + var normalizer = MockLookupNormalizer(); + roleStoreDict.ForEach(x => x.Value.NormalizedName = normalizer.NormalizeName(x.Value.Name)); + var store = new Mock>(); + store.Setup(x => x.FindByIdAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((string id, CancellationToken cancellationToken) => roleStoreDict.GetOrDefault(id)!); + store.Setup(x => x.FindByNameAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((string name, CancellationToken cancellationToken) => roleStoreDict.FirstOrDefault(x => x.Value.NormalizedName == name).Value!); + store.Setup(x => x.CreateAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((TRole role, CancellationToken cancellationToken) => + { + var errorDescriber = new IdentityErrorDescriber(); + if (roleStoreDict.Any(x => x.Value.Name == role.Name)) + { + return IdentityResult.Failed(errorDescriber.DuplicateRoleName(role.Name)); + } + role.NormalizedName = normalizer.NormalizeName(role.Name); + roleStoreDict.Add(role.Id, role); + return IdentityResult.Success; + }); + store.Setup(x => x.UpdateAsync(It.IsAny(), It.IsAny())) + .Returns(async (TRole role, CancellationToken cancellationToken) => + { + if (roleStoreDict.ContainsKey(role.Id) == false) + { + return await store.Object.CreateAsync(role, cancellationToken); + } + roleStoreDict[role.Id] = role; + return IdentityResult.Success; + }); + store.Setup(x => x.DeleteAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((TRole role, CancellationToken cancellationToken) => + { + if (roleStoreDict.ContainsKey(role.Id)) + { + roleStoreDict.Remove(role.Id); + } + return IdentityResult.Success; + }); + store.Setup(x => x.GetRoleIdAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((TRole role, CancellationToken cancellationToken) => role.Id); + store.Setup(x => x.GetRoleNameAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((TRole role, CancellationToken cancellationToken) => role.Name); + store.Setup(x => x.GetNormalizedRoleNameAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync((TRole role, CancellationToken cancellationToken) => role.NormalizedName); + return store.Object; + } + + public static ILookupNormalizer MockLookupNormalizer() + { + var normalizerFunc = new Func(i => + { + return Convert.ToBase64String(Encoding.UTF8.GetBytes(i)).ToUpperInvariant(); + }); + var lookupNormalizer = new Mock(); + lookupNormalizer.Setup(i => i.NormalizeName(It.IsAny())).Returns(normalizerFunc); + lookupNormalizer.Setup(i => i.NormalizeEmail(It.IsAny())).Returns(normalizerFunc); + return lookupNormalizer.Object; + } + + public static Mock> MockValidator() + { + return new Mock>(); + } + + public static IValidator TestValidator() + { + var mockValidator = MockValidator(); + mockValidator.Setup(x => x.Validate(It.IsAny())) + .Returns(new FluentValidation.Results.ValidationResult()).Verifiable(); + mockValidator.Setup(x => x.ValidateAsync(It.IsAny(), default)) + .ReturnsAsync(new FluentValidation.Results.ValidationResult()).Verifiable(); + return mockValidator.Object; + } + + public static IEnumerable> TestValidators() + { + return new IValidator[] { TestValidator() }; + } + + /// + /// Get a test mediator that returns the given result for specified reuqest type + /// + /// Request type + /// Result type + /// Predicate to check if request contains correct information. Returns true by default + /// Result that should be returned from + /// If set a call to will throw the provided Exception instead + /// Configured + public static IMediator TestMediator(Expression>? match = default, + TResult? result = default, Exception? throws = default) + where TRequest : IRequest + { + match ??= x => true; + var mockMediator = new Mock(); + mockMediator.Setup(x => x.Send(It.Is(match), default)) + .ReturnsAsync(() => + { + if (throws != null) + { + throw throws; + } + return result; + }) + .Verifiable(); + return mockMediator.Object; + } + + public static HttpMessageHandler TestMessageHandler(Func result) + { + var mockHttpMessageHandler = new Mock(); + mockHttpMessageHandler.Protected() + .Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()) + .ReturnsAsync((HttpRequestMessage message, CancellationToken cancellationToken) => + { + return result.Invoke(message); + }); + return mockHttpMessageHandler.Object; + } + + public class UserRoleStore : IUserRoleStore, IUserStore, IRoleStore where TUser : IdentityUser where TRole : IdentityRole + { + private readonly IUserStore userStore; + private readonly IRoleStore roleStore; + + private readonly IDictionary> userRolesStore; + + public UserRoleStore(IUserStore userStore, IRoleStore roleStore, IDictionary> userRoles) + { + this.userStore = userStore; + this.roleStore = roleStore; + userRolesStore = userRoles; + } + + public async Task AddToRoleAsync(TUser user, string roleName, CancellationToken cancellationToken) + { + var userRoles = userRolesStore.GetOrDefault(user); + if (userRoles is null) + { + userRoles = new(); + userRolesStore.Add(user, userRoles); + } + if (userRoles.Any(x => x.Name == roleName)) + { + // user already in role + return; + } + var role = await roleStore.FindByNameAsync(roleName, cancellationToken); + if (role is null) + { + // role does not exist + return; + } + userRoles.Add(role); + } + + public Task CreateAsync(TUser user, CancellationToken cancellationToken) + { + return userStore.CreateAsync(user, cancellationToken); + } + + public Task CreateAsync(TRole role, CancellationToken cancellationToken) + { + return roleStore.CreateAsync(role, cancellationToken); + } + + public Task DeleteAsync(TUser user, CancellationToken cancellationToken) + { + return userStore.DeleteAsync(user, cancellationToken); + } + + public Task DeleteAsync(TRole role, CancellationToken cancellationToken) + { + return roleStore.DeleteAsync(role, cancellationToken); + } + + public void Dispose() + { + userStore.Dispose(); + } + + public Task FindByIdAsync(string userId, CancellationToken cancellationToken) + { + return userStore.FindByIdAsync(userId, cancellationToken); + } + + public Task FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken) + { + return userStore.FindByNameAsync(normalizedUserName, cancellationToken); + } + + public Task GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken) + { + return roleStore.GetNormalizedRoleNameAsync(role, cancellationToken); + } + + public Task GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken) + { + return userStore.GetNormalizedUserNameAsync(user, cancellationToken); + } + + public Task GetRoleIdAsync(TRole role, CancellationToken cancellationToken) + { + return roleStore.GetRoleIdAsync(role, cancellationToken); + } + + public Task GetRoleNameAsync(TRole role, CancellationToken cancellationToken) + { + return roleStore.GetRoleNameAsync(role, cancellationToken); + } + + public async Task> GetRolesAsync(TUser user, CancellationToken cancellationToken) + { + var userRoles = userRolesStore.GetOrDefault(user); + if (userRoles is null) + { + return new List(); + } + return await Task.FromResult(userRoles.Select(x => x.Name).ToList()); + } + + public Task GetUserIdAsync(TUser user, CancellationToken cancellationToken) + { + return userStore.GetUserIdAsync(user, cancellationToken); + } + + public Task GetUserNameAsync(TUser user, CancellationToken cancellationToken) + { + return userStore.GetUserNameAsync(user, cancellationToken); + } + + public async Task> GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken) + { + var role = await roleStore.FindByNameAsync(roleName, cancellationToken); + if (role is null) + { + return new List(); + } + return userRolesStore + .Where(x => x.Value.Contains(role)) + .Select(x => x.Key) + .ToList(); + } + + public async Task IsInRoleAsync(TUser user, string roleName, CancellationToken cancellationToken) + { + var userRoles = userRolesStore.GetOrDefault(user); + var role = await roleStore.FindByNameAsync(roleName, cancellationToken); + if (userRoles is null || role is null) + { + return false; + } + return userRoles.Contains(role); + } + + public async Task RemoveFromRoleAsync(TUser user, string roleName, CancellationToken cancellationToken) + { + var userRoles = userRolesStore.GetOrDefault(user); + var role = await roleStore.FindByNameAsync(roleName, cancellationToken); + if (userRoles is null || role is null) + { + return; + } + if (userRoles.Contains(role) == false) + { + return; + } + userRoles.Remove(role); + } + + public Task SetNormalizedRoleNameAsync(TRole role, string normalizedName, CancellationToken cancellationToken) + { + return roleStore.SetNormalizedRoleNameAsync(role, normalizedName, cancellationToken); + } + + public Task SetNormalizedUserNameAsync(TUser user, string normalizedName, CancellationToken cancellationToken) + { + return userStore.SetNormalizedUserNameAsync(user, normalizedName, cancellationToken); + } + + public Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken) + { + return roleStore.SetRoleNameAsync(role, roleName, cancellationToken); + } + + public Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken) + { + return userStore.SetUserNameAsync(user, userName, cancellationToken); + } + + public Task UpdateAsync(TUser user, CancellationToken cancellationToken) + { + return userStore.UpdateAsync(user, cancellationToken); + } + + public Task UpdateAsync(TRole role, CancellationToken cancellationToken) + { + return roleStore.UpdateAsync(role, cancellationToken); + } + + Task IRoleStore.FindByIdAsync(string roleId, CancellationToken cancellationToken) + { + return roleStore.FindByIdAsync(roleId, cancellationToken); + } + + Task IRoleStore.FindByNameAsync(string normalizedRoleName, CancellationToken cancellationToken) + { + return roleStore.FindByNameAsync(normalizedRoleName, cancellationToken); + } + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Controllers/AdminControllerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Controllers/AdminControllerTests.cs new file mode 100644 index 00000000..5fef196b --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Controllers/AdminControllerTests.cs @@ -0,0 +1,88 @@ +using FluentValidation; +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Users; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Controllers; +using iRLeagueApiCore.Server.Handlers.Admin; +using iRLeagueApiCore.UnitTests.Fixtures; +using MediatR; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace iRLeagueApiCore.UnitTests.Server.Controllers; + +public sealed class AdminControllerTests +{ + readonly ILogger _mockLogger = new Mock>().Object; + ApplicationUser MockUser { get; } + + const string TestUserName = "TestRoleUser"; + const string TestRoleName = LeagueRoles.Member; + const string TestLeagueName = "TestLeague"; + string TestLeagueRoleName = LeagueRoles.GetLeagueRoleName(TestLeagueName, TestRoleName) ?? string.Empty; + + public AdminControllerTests() + { + var userMock = new Mock(); + userMock.SetupAllProperties(); + MockUser = userMock.Object; + MockUser.UserName = TestUserName; + } + + private static ValidationException ValdiationFailed() + { + return new ValidationException("Test validation failed"); + } + + [Fact] + public async void ListUsersRequestValid() + { + var userList = new List() + { + new AdminUserModel() { UserName = TestUserName, Roles = new string[] { "Role1", "Role2" } } + }; + var mediator = MockHelpers.TestMediator>(result: userList); + var controller = AddContexts.AddAdminControllerContext(new AdminController(_mockLogger, mediator)); + var result = await controller.ListUsers(TestLeagueName); + + var okResult = Assert.IsType(result.Result); + var usersResult = Assert.IsAssignableFrom>(okResult.Value); + Assert.Equal(TestUserName, usersResult.First().UserName); + } + + [Fact] + public async void ListUsersValidationFailed() + { + var mediator = MockHelpers.TestMediator>(throws: ValdiationFailed()); + var controller = AddContexts.AddAdminControllerContext(new AdminController(_mockLogger, mediator)); + var result = await controller.ListUsers(TestLeagueName); + + Assert.IsType(result.Result); + } + + [Fact] + public async void GiveRoleRequestValid() + { + const string roleName = "TestRole"; + var mediator = MockHelpers.TestMediator(); + var controller = AddContexts.AddAdminControllerContext(new AdminController(_mockLogger, mediator)); + var result = await controller.GiveRole(TestLeagueName, new UserRoleModel { UserName = TestUserName, RoleName = roleName }); + + Assert.IsType(result); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async void GiveRoleValidationFailed() + { + const string roleName = "TestRole"; + var mediator = MockHelpers.TestMediator(throws: ValdiationFailed()); + var controller = AddContexts.AddAdminControllerContext(new AdminController(_mockLogger, mediator)); + var result = await controller.GiveRole(TestLeagueName, new UserRoleModel { UserName = TestUserName, RoleName = roleName }); + + Assert.IsType(result); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Controllers/LeaguesControllerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Controllers/LeaguesControllerTests.cs new file mode 100644 index 00000000..7ee25b24 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Controllers/LeaguesControllerTests.cs @@ -0,0 +1,183 @@ +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Server.Controllers; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.UnitTests.Fixtures; +using MediatR; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Logging; +using Xunit.Abstractions; + +namespace iRLeagueApiCore.UnitTests.Server.Controllers; + +public sealed class LeaguesControllerTests : DataAccessTestsBase +{ + ILogger MockLogger { get; } + + private const string testFullName = "Full Name"; + private const long testLeagueId = 1; + + public LeaguesControllerTests() + { + MockLogger = new Mock>().Object; + } + + private LeaguesController CreateController(IMediator mediator) + { + return AddContexts.AddAdminControllerContext(new LeaguesController(MockLogger, mediator)); + } + + private LeagueModel DefaultGetModel() + { + return new LeagueModel() + { + Id = testLeagueId, + Name = testLeagueName, + NameFull = testFullName, + }; + } + + private PostLeagueModel DefaultPostModel() + { + return new PostLeagueModel() + { + Name = testLeagueName, + NameFull = testFullName + }; + } + + private PutLeagueModel DefaultPutModel() + { + return new PutLeagueModel() + { + NameFull = testFullName, + }; + } + + [Fact] + public async Task GetAll() + { + var expectedResult = new LeagueModel[] { DefaultGetModel() }; + var mediator = MockHelpers.TestMediator>(result: expectedResult); + var controller = CreateController(mediator); + var result = await controller.GetAll(); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task Get() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator( + x => x.LeagueId == testLeagueId, expectedResult); + var controller = CreateController(mediator); + var result = await controller.Get(testLeagueId); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task Post() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator( + x => x.Model.Name == testLeagueName, expectedResult); + var controller = CreateController(mediator); + var result = await controller.Post(DefaultPostModel()); + var createdResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, createdResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task Put() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator( + x => x.LeagueId == testLeagueId, expectedResult); + var controller = CreateController(mediator); + var result = await controller.Put(testLeagueId, DefaultPutModel()); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task Delete() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator( + x => x.LeagueId == testLeagueId); + var controller = CreateController(mediator); + var result = await controller.Delete(testLeagueId); + Assert.IsType(result); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Theory] + [InlineData(LeagueRoles.Owner, true)] + [InlineData(LeagueRoles.Admin, true)] + [InlineData(LeagueRoles.Organizer, true)] + [InlineData(LeagueRoles.Steward, false)] + [InlineData(LeagueRoles.Member, false)] + [InlineData("", false)] + public async Task Get_ShouldSetIncludeDetails(string leagueRole, bool includeDetails) + { + var testModel = new LeagueModel() + { + SubscriptionStatus = includeDetails ? Common.Enums.SubscriptionStatus.FreeTrial : null, + SubscriptionExpires = includeDetails ? DateTime.UtcNow : null, + }; + var mediator = MockHelpers.TestMediator( + x => x.IncludeSubscriptionDetails == includeDetails, + result: testModel); + var controller = AddContexts.AddControllerContext( + new LeaguesController(MockLogger, mediator), + new[] { LeagueRoles.GetLeagueRoleName(testLeagueName, leagueRole)! }); + var routeValuesMock = new Mock(); + routeValuesMock.SetupGet(x => x.RouteValues).Returns(new RouteValueDictionary(new Dictionary() { { "leagueName", testLeagueName } })); + controller.HttpContext.Features.Set(routeValuesMock.Object); + var result = (await controller.Get(testLeagueId)).Result.Should().BeOfType().Subject; + var resultModel = result!.Value.Should().BeOfType().Subject; + result.Value.Should().NotBeNull(); + } + + [Theory] + [InlineData(LeagueRoles.Owner, true)] + [InlineData(LeagueRoles.Admin, true)] + [InlineData(LeagueRoles.Organizer, true)] + [InlineData(LeagueRoles.Steward, false)] + [InlineData(LeagueRoles.Member, false)] + [InlineData("", false)] + public async Task GetByName_ShouldSetIncludeDetails(string leagueRole, bool includeDetails) + { + var testModel = new LeagueModel() + { + SubscriptionStatus = includeDetails ? Common.Enums.SubscriptionStatus.FreeTrial : null, + SubscriptionExpires = includeDetails ? DateTime.UtcNow : null, + }; + var mediator = MockHelpers.TestMediator( + x => x.IncludeSubscriptionDetails == includeDetails, + result: testModel); + var controller = AddContexts.AddControllerContext( + new LeaguesController(MockLogger, mediator), + new[] { LeagueRoles.GetLeagueRoleName(testLeagueName, leagueRole)! }); + var routeValuesMock = new Mock(); + routeValuesMock.SetupGet(x => x.RouteValues).Returns(new RouteValueDictionary(new Dictionary() { { "leagueName", testLeagueName } })); + controller.HttpContext.Features.Set(routeValuesMock.Object); + var result = (await controller.GetByName(testLeagueName)).Result.Should().BeOfType().Subject; + result.Value.Should().NotBeNull(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Controllers/ResultControllerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Controllers/ResultControllerTests.cs new file mode 100644 index 00000000..c6a6efd2 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Controllers/ResultControllerTests.cs @@ -0,0 +1,17 @@ +using iRLeagueApiCore.Server.Controllers; +using iRLeagueApiCore.UnitTests.Fixtures; +using Microsoft.Extensions.Logging; + +namespace iRLeagueApiCore.UnitTests.Server.Controllers; + +public sealed class ResultDbTestFixture : IClassFixture +{ + private DbTestFixture Fixture { get; } + + ILogger MockLogger => new Mock>().Object; + + public ResultDbTestFixture(DbTestFixture fixture) + { + Fixture = fixture; + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Controllers/ScheduleControllerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Controllers/ScheduleControllerTests.cs new file mode 100644 index 00000000..7f39e9ee --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Controllers/ScheduleControllerTests.cs @@ -0,0 +1,117 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Controllers; +using iRLeagueApiCore.Server.Handlers.Schedules; +using iRLeagueApiCore.UnitTests.Fixtures; +using MediatR; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace iRLeagueApiCore.UnitTests.Server.Controllers; + +public sealed class ScheduleControllerTests +{ + private readonly ILogger logger; + + const string testLeagueName = "TestLeague"; + const long testLeagueId = 1; + const long testSeasonÍd = 1; + const long testScheduleId = 1; + const string testScheduleName = "Schedule 1"; + + public ScheduleControllerTests() + { + logger = Mock.Of>(); + } + + private static ScheduleModel DefaultGetModel() + { + return new ScheduleModel() + { + LeagueId = testLeagueId, + ScheduleId = testScheduleId, + Name = testScheduleName + }; + } + + private static PostScheduleModel DefaultPostModel() + { + return new PostScheduleModel(); + } + + private static PutScheduleModel DefaultPutModel() + { + return new PutScheduleModel(); + } + + [Fact] + public async Task GetSchedulesValid() + { + var expectedResult = new ScheduleModel[] { DefaultGetModel() }; + var mediator = MockHelpers.TestMediator>(result: expectedResult); + var controller = AddContexts.AddMemberControllerContext(new SchedulesController(logger, mediator)); + + var result = await controller.GetAll(testLeagueName); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task GetScheduleValid() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator(x => + x.ScheduleId == testScheduleId, expectedResult); + var controller = AddContexts.AddMemberControllerContext(new SchedulesController(logger, mediator)); + + var result = await controller.Get(testLeagueName, testScheduleId); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task PostScheduleValid() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator(result: expectedResult); + var controller = AddContexts.AddMemberControllerContext(new SchedulesController(logger, mediator)); + + var result = await controller.Post(testLeagueName, testSeasonÍd, DefaultPostModel()); + var createdResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, createdResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task PutScheduleValid() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator(x => + x.ScheduleId == testScheduleId, expectedResult); + var controller = AddContexts.AddMemberControllerContext(new SchedulesController(logger, mediator)); + + var result = await controller.Put(testLeagueName, testScheduleId, DefaultPutModel()); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task DeleteScheduleValid() + { + var mediator = MockHelpers.TestMediator(x => + x.ScheduleId == testScheduleId); + var controller = AddContexts.AddMemberControllerContext(new SchedulesController(logger, mediator)); + + var result = await controller.Delete(testLeagueName, testScheduleId); + Assert.IsType(result); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Controllers/ScoringControllerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Controllers/ScoringControllerTests.cs new file mode 100644 index 00000000..09beb4a6 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Controllers/ScoringControllerTests.cs @@ -0,0 +1,97 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Controllers; +using iRLeagueApiCore.Server.Exceptions; +using iRLeagueApiCore.Server.Handlers.Scorings; +using iRLeagueApiCore.UnitTests.Fixtures; +using MediatR; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace iRLeagueApiCore.UnitTests.Server.Controllers; + +public sealed class ScoringControllerTests +{ + private readonly ILogger logger; + + const string testLeagueName = "TestLeague"; + const long testLeagueId = 1; + const long testScoringId = 1; + + public ScoringControllerTests() + { + logger = Mock.Of>(); + } + + private static ScoringModel DefaultGetModel() + { + return new ScoringModel() + { + Id = testScoringId, + LeagueId = testLeagueId, + }; + } + + private static PutScoringModel DefaultPutModel() + { + return new PutScoringModel(); + } + + [Fact] + public async Task GetScoringsValid() + { + var expectedResult = new ScoringModel[] { DefaultGetModel() }; + var mediator = MockHelpers.TestMediator>(result: expectedResult); + var controller = AddContexts.AddMemberControllerContext(new ScoringsController(logger, mediator)); + + var result = await controller.Get(testLeagueName); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task GetScoringValid() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator(x => + x.ScoringId == testScoringId, expectedResult); + var controller = AddContexts.AddMemberControllerContext(new ScoringsController(logger, mediator)); + + var result = await controller.Get(testLeagueName, testScoringId); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task PutScoringValid() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator(x => + x.ScoringId == testScoringId, expectedResult); + var controller = AddContexts.AddMemberControllerContext(new ScoringsController(logger, mediator)); + + var result = await controller.Put(testLeagueName, testScoringId, DefaultPutModel()); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task DeleteScoringValid() + { + var mediator = MockHelpers.TestMediator(x => + x.ScoringId == testScoringId); + var controller = AddContexts.AddMemberControllerContext(new ScoringsController(logger, mediator)); + + var result = await controller.Delete(testLeagueName, testScoringId); + Assert.IsType(result); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Controllers/SeasonControllerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Controllers/SeasonControllerTests.cs new file mode 100644 index 00000000..1c57f845 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Controllers/SeasonControllerTests.cs @@ -0,0 +1,128 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Controllers; +using iRLeagueApiCore.Server.Exceptions; +using iRLeagueApiCore.Server.Handlers.Seasons; +using iRLeagueApiCore.UnitTests.Fixtures; +using MediatR; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace iRLeagueApiCore.UnitTests.Server.Controllers; + +public sealed class SeasonDbTestFixture +{ + private readonly ILogger logger; + + const string testLeagueName = "TestLeague"; + const long testLeagueId = 1; + const long testSeasonId = 1; + const string testSeasonName = "Season 1"; + + public SeasonDbTestFixture() + { + logger = Mock.Of>(); + } + + private static SeasonModel DefaultGetModel() + { + return new SeasonModel() + { + LeagueId = testLeagueId, + SeasonId = testSeasonId, + SeasonName = testSeasonName + }; + } + + private static PostSeasonModel DefaultPostModel() + { + return new PostSeasonModel(); + } + + private static PutSeasonModel DefaultPutModel() + { + return new PutSeasonModel(); + } + + private static ResourceNotFoundException NotFound() + { + return new ResourceNotFoundException(); + } + + private static ValidationException ValidationFailed() + { + return new ValidationException("Test validation failed"); + } + + [Fact] + public async Task GetSeasonsValid() + { + var expectedResult = new SeasonModel[] { DefaultGetModel() }; + var mediator = MockHelpers.TestMediator>(result: expectedResult); + var controller = AddContexts.AddMemberControllerContext(new SeasonsController(logger, mediator)); + + var result = await controller.GetAll(testLeagueName); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task GetSeasonValid() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator(x => + x.SeasonId == testSeasonId, expectedResult); + var controller = AddContexts.AddMemberControllerContext(new SeasonsController(logger, mediator)); + + var result = await controller.Get(testLeagueName, testSeasonId); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task PostSeasonValid() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator(result: expectedResult); + var controller = AddContexts.AddMemberControllerContext(new SeasonsController(logger, mediator)); + + var result = await controller.Post(testLeagueName, DefaultPostModel()); + var createdResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, createdResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task PutSeasonValid() + { + var expectedResult = DefaultGetModel(); + var mediator = MockHelpers.TestMediator(x => + x.SeasonId == testSeasonId, expectedResult); + var controller = AddContexts.AddMemberControllerContext(new SeasonsController(logger, mediator)); + + var result = await controller.Put(testLeagueName, testSeasonId, DefaultPutModel()); + var okResult = Assert.IsType(result.Result); + Assert.Equal(expectedResult, okResult.Value); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } + + [Fact] + public async Task DeleteSeasonValid() + { + var mediator = MockHelpers.TestMediator(x => + x.SeasonId == testSeasonId); + var controller = AddContexts.AddMemberControllerContext(new SeasonsController(logger, mediator)); + + var result = await controller.Delete(testLeagueName, testSeasonId); + Assert.IsType(result); + var mediatorMock = Mock.Get(mediator); + mediatorMock.Verify(x => x.Send(It.IsAny(), default)); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Extensions/HttpContextExtensionsTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Extensions/HttpContextExtensionsTests.cs new file mode 100644 index 00000000..15271d8e --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Extensions/HttpContextExtensionsTests.cs @@ -0,0 +1,75 @@ +using FluentIdentityBuilder; +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Server.Extensions; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Routing; + +namespace iRLeagueApiCore.UnitTests.Server.Extensions; +public sealed class HttpContextExtensionsTests +{ + private readonly ClaimsPrincipalBuilder principalBuilder = new(); + + [Fact] + public void GetLeagueUser_ShouldReturnLeagueUser_WhenUserAndLeaguenNmeIsSet() + { + var httpContext = TestHttpContext(); + httpContext.GetRouteData().Values.Add("leagueName", "Testleague"); + httpContext.User = principalBuilder.StartBuild() + .WithIdentifier("TestId") + .WithName("Testuser") + .WithRole(LeagueRoles.GetLeagueRoleName("Testleague", LeagueRoles.Admin)) + .Create(); + + var leagueUser = httpContext.GetLeagueUser(); + + leagueUser.Should().NotBeNull(); + leagueUser!.Id.Should().Be("TestId"); + leagueUser.Name.Should().Be("Testuser"); + leagueUser.Roles.Should().Contain(x => x == LeagueRoles.Admin); + } + + [Fact] + public void GetLeagueUser_ShouldReturnUserWithoutRoles_WhenLeagueNameIsNotSet() + { + var httpContext = TestHttpContext(); + httpContext.User = principalBuilder.StartBuild() + .WithRole(LeagueRoles.GetLeagueRoleName("Testleague", LeagueRoles.Organizer)) + .Create(); + + var leagueUser = httpContext.GetLeagueUser(); + + leagueUser.Should().NotBeNull(); + leagueUser.Roles.Should().BeEmpty(); + } + + [Fact] + public void GetLeagueUser_ShouldReturnAdminUserAsAdmin_WhenLeagueNameIsNotSet() + { + var httpContext = TestHttpContext(); + httpContext.User = principalBuilder.StartBuild() + .WithRole("Admin") + .Create(); + + var leagueUser = httpContext.GetLeagueUser(); + + leagueUser.Should().NotBeNull(); + leagueUser.Roles.Should().Contain(x => x == "Admin"); + } + + private static HttpContext TestHttpContext(RouteData? routeData = default) + { + routeData ??= new RouteData(); + var context = new Mock(); + var features = new Mock(); + var iroutingFeature = new Mock(); + iroutingFeature.SetupProperty(x => x.RouteData, routeData); + var irouteValueFeature = new Mock(); + irouteValueFeature.SetupProperty(x => x.RouteValues, routeData.Values); + features.Setup(x => x.Get()).Returns(iroutingFeature.Object); + features.Setup(x => x.Get()).Returns(irouteValueFeature.Object); + context.SetupProperty(x => x.User); + context.SetupGet(x => x.Features).Returns(features.Object); + return context.Object; + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Filters/CheckLeagueSubscriptionAttributeTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Filters/CheckLeagueSubscriptionAttributeTests.cs new file mode 100644 index 00000000..bf02f201 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Filters/CheckLeagueSubscriptionAttributeTests.cs @@ -0,0 +1,392 @@ +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Server.Filters; +using iRLeagueApiCore.Server.Models; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Abstractions; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; +using Microsoft.AspNetCore.Routing; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Net.Http.Headers; +using System.Diagnostics.Contracts; +using System.Net; + +namespace iRLeagueApiCore.UnitTests.Server.Filters; +public sealed class CheckLeagueSubscriptionAttributeTests : DataAccessTestsBase +{ + [Fact] + public async Task Action_ShouldContinue_WhenRequiredAttributeMissing() + { + var league = await dbContext.Leagues.FirstAsync(); + var memoryCacheMock = MockMemoryCache(); + var actionContext = new ActionContext() + { + ActionDescriptor = new ActionDescriptor(), + HttpContext = new DefaultHttpContext(), + RouteData = new RouteData( + new RouteValueDictionary( + new Dictionary() { { "leagueName", league.Name } } + ) + ), + }; + var executingContext = new ActionExecutingContext( + actionContext, + new List(), + new Dictionary(), + null! + ); + bool hasInvokedNext = false; + var executedContext = new ActionExecutedContext( + actionContext, + new List(), + null! + ); + + var sut = new CheckLeagueSubscriptionAttribute(dbContext, memoryCacheMock.Object); + + await TestOnActionExecutionAsync(sut, + actionContext: actionContext, + executingContext: executingContext, + executedDelegate: () => { hasInvokedNext = true; return Task.FromResult(executedContext); }); + + executingContext.Result.Should().BeNull(); + hasInvokedNext.Should().BeTrue(); + } + + [Fact] + public async Task Action_ShouldSetResultAndCancel_WhenRequiredAttributeExists() + { + var league = await dbContext.Leagues.FirstAsync(); + var memoryCacheMock = MockMemoryCache(); + var actionContext = new ActionContext() + { + ActionDescriptor = new ActionDescriptor() + { + EndpointMetadata = new List() + { + new RequireSubscriptionAttribute(), + }, + }, + HttpContext = new DefaultHttpContext(), + RouteData = new RouteData( + new RouteValueDictionary( + new Dictionary() { { "leagueName", league.Name } } + ) + ), + }; + var executingContext = new ActionExecutingContext( + actionContext, + new List(), + new Dictionary(), + null! + ); + bool hasInvokedNext = false; + var executedContext = new ActionExecutedContext( + actionContext, + new List(), + null! + ); + + var sut = new CheckLeagueSubscriptionAttribute(dbContext, memoryCacheMock.Object); + + await TestOnActionExecutionAsync(sut, + actionContext: actionContext, + executingContext: executingContext, + executedDelegate: () => { hasInvokedNext = true; return Task.FromResult(executedContext); }); + + executingContext.Result.Should().NotBeNull(); + executingContext.Result.Should().BeOfType() + .Subject.StatusCode.Should().Be((int)HttpStatusCode.PaymentRequired); + hasInvokedNext.Should().BeFalse(); + } + + [Theory] + [InlineData(SubscriptionStatus.Expired, false)] + [InlineData(SubscriptionStatus.Unknown, false)] + [InlineData(SubscriptionStatus.FreeTrial, true)] + [InlineData(SubscriptionStatus.PaidPlan, true)] + [InlineData(SubscriptionStatus.Lifetime, true)] + public async Task Action_ShouldContinue_WhenSubscriptionNotExpired(SubscriptionStatus subscriptionStatus, bool invokeNext) + { + var league = await dbContext.Leagues.FirstAsync(); + league.Subscription = subscriptionStatus; + league.Expires = DateTime.UtcNow.AddDays(1); + await dbContext.SaveChangesAsync(); + + var memoryCacheMock = MockMemoryCache(); + var actionContext = new ActionContext() + { + ActionDescriptor = new ActionDescriptor() + { + EndpointMetadata = new List() + { + new RequireSubscriptionAttribute(), + }, + }, + HttpContext = new DefaultHttpContext(), + RouteData = new RouteData( + new RouteValueDictionary( + new Dictionary() { { "leagueName", league.Name } } + ) + ), + }; + bool hasInvokedNext = false; + var executedContext = new ActionExecutedContext( + actionContext, + new List(), + null! + ); + + var sut = new CheckLeagueSubscriptionAttribute(dbContext, memoryCacheMock.Object); + + await TestOnActionExecutionAsync(sut, + actionContext: actionContext, + executedDelegate: () => { hasInvokedNext = true; return Task.FromResult(executedContext); }); + + hasInvokedNext.Should().Be(invokeNext); + } + + [Theory] + [InlineData(SubscriptionStatus.Expired, false)] + [InlineData(SubscriptionStatus.Unknown, false)] + [InlineData(SubscriptionStatus.FreeTrial, false)] + [InlineData(SubscriptionStatus.PaidPlan, false)] + [InlineData(SubscriptionStatus.Lifetime, true)] + public async Task Action_ShouldNotContinue_WhenSubscriptionExpired(SubscriptionStatus subscriptionStatus, bool invokeNext) + { + var league = await dbContext.Leagues.FirstAsync(); + league.Subscription = subscriptionStatus; + league.Expires = DateTime.UtcNow.AddDays(-1); + await dbContext.SaveChangesAsync(); + + var memoryCacheMock = MockMemoryCache(); + var actionContext = new ActionContext() + { + ActionDescriptor = new ActionDescriptor() + { + EndpointMetadata = new List() + { + new RequireSubscriptionAttribute(), + }, + }, + HttpContext = new DefaultHttpContext(), + RouteData = new RouteData( + new RouteValueDictionary( + new Dictionary() { { "leagueName", league.Name } } + ) + ), + }; + bool hasInvokedNext = false; + var executedContext = new ActionExecutedContext( + actionContext, + new List(), + null! + ); + + var sut = new CheckLeagueSubscriptionAttribute(dbContext, memoryCacheMock.Object); + + await TestOnActionExecutionAsync(sut, + actionContext: actionContext, + executedDelegate: () => { hasInvokedNext = true; return Task.FromResult(executedContext); }); + + hasInvokedNext.Should().Be(invokeNext); + } + + [Theory] + [InlineData(SubscriptionStatus.Unknown)] + [InlineData(SubscriptionStatus.FreeTrial)] + [InlineData(SubscriptionStatus.PaidPlan)] + public async Task Action_ShouldSetLeagueToExpired_WhenSubscriptionExpired(SubscriptionStatus subscriptionStatus) + { + var league = await dbContext.Leagues.FirstAsync(); + league.Subscription = subscriptionStatus; + league.Expires = DateTime.UtcNow.AddDays(-1); + await dbContext.SaveChangesAsync(); + + var memoryCacheMock = MockMemoryCache(); + var actionContext = new ActionContext() + { + ActionDescriptor = new ActionDescriptor() + { + EndpointMetadata = new List() + { + new RequireSubscriptionAttribute(), + }, + }, + HttpContext = new DefaultHttpContext(), + RouteData = new RouteData( + new RouteValueDictionary( + new Dictionary() { { "leagueName", league.Name } } + ) + ), + }; + + var sut = new CheckLeagueSubscriptionAttribute(dbContext, memoryCacheMock.Object); + + await TestOnActionExecutionAsync(sut, + actionContext: actionContext); + + league.Subscription.Should().Be(SubscriptionStatus.Expired); + } + + [Fact] + public async Task Action_ShouldNotExpireLifetimeSubscription() + { + var league = await dbContext.Leagues.FirstAsync(); + league.Subscription = SubscriptionStatus.Lifetime; + league.Expires = DateTime.UtcNow.AddDays(-1); + await dbContext.SaveChangesAsync(); + + var memoryCacheMock = MockMemoryCache(); + var actionContext = new ActionContext() + { + ActionDescriptor = new ActionDescriptor() + { + EndpointMetadata = new List() + { + new RequireSubscriptionAttribute(), + }, + }, + HttpContext = new DefaultHttpContext(), + RouteData = new RouteData( + new RouteValueDictionary( + new Dictionary() { { "leagueName", league.Name } } + ) + ), + }; + + var sut = new CheckLeagueSubscriptionAttribute(dbContext, memoryCacheMock.Object); + + await TestOnActionExecutionAsync(sut, + actionContext: actionContext); + + league.Subscription.Should().Be(SubscriptionStatus.Lifetime); + } + + [Fact] + public async Task Action_ShouldSetLeagueOnMemoryCache() + { + var league = await dbContext.Leagues.FirstAsync(); + var memoryCacheMock = MockMemoryCache(); + var actionContext = new ActionContext() + { + ActionDescriptor = new ActionDescriptor() + { + EndpointMetadata = new List() + { + new RequireSubscriptionAttribute(), + }, + }, + HttpContext = new DefaultHttpContext(), + RouteData = new RouteData( + new RouteValueDictionary( + new Dictionary() { { "leagueName", league.Name } } + ) + ), + }; + + var sut = new CheckLeagueSubscriptionAttribute(dbContext, memoryCacheMock.Object); + + await TestOnActionExecutionAsync(sut, actionContext: actionContext); + + memoryCacheMock.Verify(x => x.CreateEntry(CacheKeys.GetLeagueNameKey(league.Name))); + } + + [Fact] + public async Task Action_ShouldGetEntryFromCache_WhenExists() + { + var league = new LeagueEntity() + { + Name = "Fake League", + Subscription = SubscriptionStatus.Lifetime, + }; + var memoryCacheMock = MockMemoryCache(); + memoryCacheMock.Object.Set(CacheKeys.GetLeagueNameKey(league.Name), league); + var actionContext = new ActionContext() + { + ActionDescriptor = new ActionDescriptor() + { + EndpointMetadata = new List() + { + new RequireSubscriptionAttribute(), + }, + }, + HttpContext = new DefaultHttpContext(), + RouteData = new RouteData( + new RouteValueDictionary( + new Dictionary() { { "leagueName", league.Name } } + ) + ), + }; + bool hasInvokedNext = false; + var executedContext = new ActionExecutedContext( + actionContext, + new List(), + null! + ); + + var sut = new CheckLeagueSubscriptionAttribute(dbContext, memoryCacheMock.Object); + + + await TestOnActionExecutionAsync(sut, + actionContext: actionContext, + executedDelegate: () => { hasInvokedNext = true; return Task.FromResult(executedContext); }); + + memoryCacheMock.Verify(x => x.TryGetValue(CacheKeys.GetLeagueNameKey(league.Name), out It.Ref.IsAny)); + hasInvokedNext.Should().BeTrue(); + } + + private static CheckLeagueSubscriptionAttribute CreateSut( + LeagueDbContext dbContext, + IMemoryCache memoryCache) + { + return new CheckLeagueSubscriptionAttribute(dbContext, memoryCache); + } + + private static async Task TestOnActionExecutionAsync( + CheckLeagueSubscriptionAttribute sut, + ActionContext actionContext = default!, + ActionExecutingContext executingContext = default!, + ActionExecutionDelegate executedDelegate = default!) + { + actionContext ??= new ActionContext() + { + ActionDescriptor = new ActionDescriptor(), + HttpContext = new DefaultHttpContext(), + RouteData = new RouteData(), + }; + executingContext ??= new ActionExecutingContext( + actionContext, + new List(), + new Dictionary(), + null! + ); + var executedContext = new ActionExecutedContext( + actionContext, + new List(), + null! + ); + executedDelegate ??= () => Task.FromResult(executedContext); + await sut.OnActionExecutionAsync(executingContext, executedDelegate); + } + + private static Mock MockMemoryCache() + { + var cache = new MemoryCache(new MemoryCacheOptions()); + var memoryCacheMock = new Mock(); + memoryCacheMock.Setup(x => x.CreateEntry(It.IsAny())) + .Returns((object key) => cache.CreateEntry(key)) + .Verifiable(); + memoryCacheMock.Setup(x => x.TryGetValue(It.IsAny(), out It.Ref.IsAny)) + .Returns((object key, out object value) => cache.TryGetValue(key, out value)) + .Verifiable(); + memoryCacheMock.Setup(x => x.Remove(It.IsAny())) + .Callback((object key) => cache.Remove(key)) + .Verifiable(); + return memoryCacheMock; + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Admin/GiveRoleRequestTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Admin/GiveRoleRequestTests.cs new file mode 100644 index 00000000..c62d981e --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Admin/GiveRoleRequestTests.cs @@ -0,0 +1,133 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Admin; +using iRLeagueApiCore.UnitTests.Fixtures; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Logging; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Admin; + +public sealed class GiveRoleRequestTests : IClassFixture +{ + private readonly IdentityFixture fixture; + private readonly ILogger logger; + + public GiveRoleRequestTests(IdentityFixture fixture) + { + this.fixture = fixture; + logger = Mock.Of>(); + } + + [Fact] + public async Task GiveRoleValid() + { + var validator = fixture.GetDefaultValidator().Object; + var roleManager = fixture.GetDefaultMockRoleManager().Object; + var roleAdded = false; + var mockUserManager = fixture.GetDefaultMockUserManager(); + mockUserManager.Setup(x => x.AddToRoleAsync(It.Is(x => x == fixture.validUser), It.Is(x => x == fixture.testLeagueRoleName))) + .ReturnsAsync(() => { roleAdded = true; return IdentityResult.Success; }); + var userManager = mockUserManager.Object; + + var request = new GiveRoleRequest(fixture.testLeague, + new UserRoleModel() { UserName = fixture.validUser.UserName, RoleName = fixture.testRole }); + request.User = fixture.validUser; + var handler = new GiveRoleHandler(logger, validator.ToEnumerable(), userManager, roleManager); + var result = await handler.Handle(request); + + Assert.True(roleAdded); + } + + [Fact] + public async Task GiveRoleValidationFailed() + { + var mockValidator = fixture.GetDefaultValidator(); + mockValidator.Setup(x => x.ValidateAsync(It.IsAny(), default)) + .ReturnsAsync(fixture.GetFailedResult()); + var validator = mockValidator.Object; + var roleManager = fixture.GetDefaultMockRoleManager().Object; + var userManager = fixture.GetDefaultMockUserManager().Object; + + var request = new GiveRoleRequest(fixture.testLeague, new UserRoleModel()); + var handler = new GiveRoleHandler(logger, validator.ToEnumerable(), userManager, roleManager); + await Assert.ThrowsAsync(async () => await handler.Handle(request)); + } + + [Fact] + public async Task CreateRole() + { + var roleCreated = false; + var roleAdded = false; + + var validator = fixture.GetDefaultValidator().Object; + var mockRoleManager = fixture.GetDefaultMockRoleManager(); + mockRoleManager.Setup(x => x.CreateAsync(It.Is(x => x.Name == fixture.testLeagueRoleName))) + .ReturnsAsync(() => { roleCreated = true; return IdentityResult.Success; }); + mockRoleManager.Setup(x => x.RoleExistsAsync(It.Is(x => x == fixture.testLeagueRoleName))) + .ReturnsAsync(false); + var roleManager = mockRoleManager.Object; + var mockUserManager = fixture.GetDefaultMockUserManager(); + mockUserManager.Setup(x => x.AddToRoleAsync(It.Is(x => x == fixture.validUser), It.Is(x => x == fixture.testLeagueRoleName))) + .ReturnsAsync(() => { roleAdded = true; return IdentityResult.Success; }); + var userManager = mockUserManager.Object; + + var request = new GiveRoleRequest(fixture.testLeague, + new UserRoleModel() { UserName = fixture.validUser.UserName, RoleName = fixture.testRole }); + request.User = fixture.validUser; + var handler = new GiveRoleHandler(logger, validator.ToEnumerable(), userManager, roleManager); + var result = await handler.Handle(request); + + Assert.True(roleAdded); + Assert.True(roleCreated); + } + + [Fact] + public async Task CreateRoleFailed() + { + var roleCreated = false; + var roleAdded = false; + + var validator = fixture.GetDefaultValidator().Object; + var mockRoleManager = fixture.GetDefaultMockRoleManager(); + mockRoleManager.Setup(x => x.CreateAsync(It.Is(x => x.Name == fixture.testLeagueRoleName))) + .ReturnsAsync(() => { roleCreated = false; return IdentityResult.Failed(); }); + mockRoleManager.Setup(x => x.RoleExistsAsync(It.Is(x => x == fixture.testLeagueRoleName))) + .ReturnsAsync(false); + var roleManager = mockRoleManager.Object; + var mockUserManager = fixture.GetDefaultMockUserManager(); + mockUserManager.Setup(x => x.AddToRoleAsync(It.Is(x => x == fixture.validUser), It.Is(x => x == fixture.testLeagueRoleName))) + .ReturnsAsync(() => { roleAdded = true; return IdentityResult.Success; }); + var userManager = mockUserManager.Object; + + var request = new GiveRoleRequest(fixture.testLeague, + new UserRoleModel() { UserName = fixture.validUser.UserName, RoleName = fixture.testRole }); + request.User = fixture.validUser; + var handler = new GiveRoleHandler(logger, validator.ToEnumerable(), userManager, roleManager); + await Assert.ThrowsAsync(async () => await handler.Handle(request)); + + Assert.False(roleAdded); + Assert.False(roleCreated); + } + + [Fact] + public async Task AddToRoleFailed() + { + var roleAdded = false; + + var validator = fixture.GetDefaultValidator().Object; + var roleManager = fixture.GetDefaultMockRoleManager().Object; + var mockUserManager = fixture.GetDefaultMockUserManager(); + mockUserManager.Setup(x => x.AddToRoleAsync(It.Is(x => x == fixture.validUser), It.Is(x => x == fixture.testLeagueRoleName))) + .ReturnsAsync(() => { roleAdded = false; return IdentityResult.Failed(); }); + var userManager = mockUserManager.Object; + + var request = new GiveRoleRequest(fixture.testLeague, + new UserRoleModel() { UserName = fixture.validUser.UserName, RoleName = fixture.testRole }); + request.User = fixture.validUser; + var handler = new GiveRoleHandler(logger, validator.ToEnumerable(), userManager, roleManager); + await Assert.ThrowsAsync(async () => await handler.Handle(request)); + + Assert.False(roleAdded); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Admin/ListUserHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Admin/ListUserHandlerTests.cs new file mode 100644 index 00000000..98d2a592 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Admin/ListUserHandlerTests.cs @@ -0,0 +1,76 @@ +using FluentValidation; +using FluentValidation.Results; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Admin; +using iRLeagueApiCore.UnitTests.Fixtures; +using Microsoft.Extensions.Logging; +using System.Diagnostics; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Admin; + +public sealed class ListUserDbTestFixture : IClassFixture +{ + private readonly IdentityFixture fixture; + private readonly ILogger logger; + + public ListUserDbTestFixture(IdentityFixture fixture) + { + this.fixture = fixture; + logger = Mock.Of>(); + } + + [Fact] + public async Task RequestValid() + { + var validator = fixture.GetDefaultValidator().Object; + var mockUserManager = fixture.GetDefaultMockUserManager(); + mockUserManager.Setup(x => x.GetUsersInRoleAsync(It.IsAny())) + .ReturnsAsync(new List()); + mockUserManager.Setup(x => x.GetUsersInRoleAsync(It.Is(x => x == fixture.testLeagueRoleName))) + .ReturnsAsync(new List() { fixture.validUser }); + var userManager = mockUserManager.Object; + var request = new ListUsersRequest(fixture.testLeague); + var handler = new ListUsersHandler(logger, new IValidator[] { validator }, + userManager); + + Debug.Assert((await userManager.GetUsersInRoleAsync(fixture.testLeagueRoleName)).Count == 1); + + var result = await handler.Handle(request, default); + Assert.NotNull(result); + Assert.Single(result); + Assert.Equal(fixture.validUser.UserName, result.First().UserName); + } + + [Fact] + public async Task RequestValidationFailed() + { + var mockValidator = fixture.GetDefaultValidator(); + mockValidator.Setup(x => x.ValidateAsync(It.IsAny(), default)) + .ReturnsAsync(new ValidationResult(new ValidationFailure[] { new ValidationFailure(nameof(ListUsersRequest.LeagueName), "") })); + var validator = mockValidator.Object; + + Debug.Assert((await validator.ValidateAsync(new ListUsersRequest(""))).IsValid == false); + + var handler = new ListUsersHandler(logger, new IValidator[] { validator }, fixture.GetDefaultMockUserManager().Object); + await Assert.ThrowsAsync(async () => await handler.Handle(new ListUsersRequest(""))); + } + + [Fact] + public async Task RequestEmptyUserList() + { + var validator = fixture.GetDefaultValidator().Object; + var mockUserManager = fixture.GetDefaultMockUserManager(); + mockUserManager.Setup(x => x.GetUsersInRoleAsync(It.IsAny())) + .ReturnsAsync(new List()); + var userManager = mockUserManager.Object; + var request = new ListUsersRequest(fixture.testLeague); + var handler = new ListUsersHandler(logger, new IValidator[] { validator }, + userManager); + + Debug.Assert((await userManager.GetUsersInRoleAsync(fixture.testLeagueRoleName)).Count == 0); + + var result = await handler.Handle(request, default); + Assert.NotNull(result); + Assert.Empty(result); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/AdminPanelTestsBase.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/AdminPanelTestsBase.cs new file mode 100644 index 00000000..2b85174f --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/AdminPanelTestsBase.cs @@ -0,0 +1,68 @@ +using AutoFixture.Dsl; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueDatabaseCore.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.AdminPanel; +public abstract class AdminPanelTestsBase + : HandlersTestsBase + where THandler : IRequestHandler + where TRequest : class, IRequest +{ + + protected Guid TestPaymentId => dbContext.Payments.IgnoreQueryFilters().First().Id; + protected string TestPlanId => dbContext.Subscriptions.IgnoreQueryFilters().First().PlanId; + + public override async Task InitializeAsync() + { + await base.InitializeAsync(); + var subscriptions = await CreateTestSubscriptions(); + dbContext.Subscriptions.AddRange(subscriptions); + var payments = await CreateTestPayments(subscriptions); + dbContext.Payments.AddRange(payments); + await dbContext.SaveChangesAsync(); + } + + private async Task> CreateTestPayments(IEnumerable subscriptions) + { + var league = await dbContext.Leagues.FirstAsync(); + var payment1 = PaymentEntityBuilder(league, subscriptions.First()) + .With(x => x.LastPaymentReceived, DateTime.UtcNow) + .With(x => x.LastPaymentReceived, DateTime.UtcNow.AddMonths(1)) + .Create(); + var payment2 = PaymentEntityBuilder(league, subscriptions.Last()) + .With(x => x.LastPaymentReceived, DateTime.UtcNow) + .With(x => x.LastPaymentReceived, DateTime.UtcNow.AddYears(1)) + .Create(); + return new[] { payment1, payment2 }; + } + + private async Task> CreateTestSubscriptions() + { + var monthlySub = SubscriptionEntityBuilder() + .With(x => x.Name, "Monthly") + .With(x => x.Interval, SubscriptionInterval.Monthly) + .Create(); + var yearlySub = SubscriptionEntityBuilder() + .With(x => x.Name, "Yealy") + .With(x => x.Interval, SubscriptionInterval.Yearly) + .Create(); + return await Task.FromResult(new[] { monthlySub, yearlySub }); + } + + protected IPostprocessComposer SubscriptionEntityBuilder() + { + return fixture.Build() + .Without(x => x.Payments); + } + + protected IPostprocessComposer PaymentEntityBuilder(LeagueEntity league, SubscriptionEntity? subscription) + { + return fixture.Build() + .With(x => x.League, league) + .With(x => x.LeagueId, league.Id) + .With(x => x.Subscription, subscription) + .With(x => x.PlanId, subscription?.PlanId); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/DeactivatePaymentHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/DeactivatePaymentHandlerTests.cs new file mode 100644 index 00000000..3d271989 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/DeactivatePaymentHandlerTests.cs @@ -0,0 +1,67 @@ +using FluentValidation; +using iRLeagueApiCore.Server.Handlers.AdminPanel; +using iRLeagueApiCore.Server.Models.Payments; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.AdminPanel; +public sealed class DeactivatePaymentHandlerTests + : AdminPanelTestsBase +{ + protected override DeactivatePaymentHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + protected override DeactivatePaymentRequest DefaultRequest() + { + return DefaultRequest(TestPaymentId); + } + + private static DeactivatePaymentRequest DefaultRequest(Guid id) + { + return new(id); + } + + protected override void DefaultAssertions(DeactivatePaymentRequest request, PaymentModel result, LeagueDbContext dbContext) + { + base.DefaultAssertions(request, result, dbContext); + result.Status.Should().Be(PaymentStatus.Inactive); + } + + [Fact] + public async Task Handle_ShouldHandleDefault() + { + await ShouldHandleDefault(); + } + + [Fact] + public async Task Handle_ShouldHandleValidationFailed() + { + await ShouldHandleValidationFailed(); + } + + [Fact] + public async Task Handle_ShouldHandleNotFound() + { + var id = Guid.NewGuid(); + var request = DefaultRequest(id); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public async Task Handle_ShouldSetLeagueSubscriptionExpired() + { + var request = DefaultRequest(TestPaymentId); + var sut = CreateTestHandler(dbContext, DefaultValidator()); + var league = await dbContext.Leagues.FirstAsync(x => x.Id == TestLeagueId); + league.Subscription = Common.Enums.SubscriptionStatus.PaidPlan; + await dbContext.SaveChangesAsync(); + + var test = await sut.Handle(request, default); + + league = await dbContext.Leagues.FirstAsync(x => x.Id == TestLeagueId); + league.Subscription.Should().Be(Common.Enums.SubscriptionStatus.Expired); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/GetAllPaymentHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/GetAllPaymentHandlerTests.cs new file mode 100644 index 00000000..2b848e44 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/GetAllPaymentHandlerTests.cs @@ -0,0 +1,69 @@ +using FluentValidation; +using iRLeagueApiCore.Server.Handlers.AdminPanel; +using iRLeagueApiCore.Server.Models.Payments; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.EntityFrameworkCore; +using System.Linq.Expressions; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.AdminPanel; +public sealed class GetAllPaymentHandlerTests + : AdminPanelTestsBase> +{ + protected override GetAllPaymentsHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + protected override GetAllPaymentsRequest DefaultRequest() + { + return DefaultRequest(null); + } + + private static GetAllPaymentsRequest DefaultRequest(long? leagueId) + { + return new GetAllPaymentsRequest(leagueId); + } + + protected override void DefaultAssertions(GetAllPaymentsRequest request, + IEnumerable result, LeagueDbContext dbContext) + { + base.DefaultAssertions(request, result, dbContext); + result.Should().HaveSameCount(dbContext.Payments); + } + + public override async Task InitializeAsync() + { + await base.InitializeAsync(); + var otherLeague = dbContext.Leagues.Skip(1).First(); + var paymentOnOtherLeague = PaymentEntityBuilder(otherLeague, null).Create(); + dbContext.Payments.Add(paymentOnOtherLeague); + await dbContext.SaveChangesAsync(); + } + + [Fact] + public async Task Handle_ShouldHandleDefault() + { + await ShouldHandleDefault(); + } + + [Fact] + public async Task Handle_ShouldHandleValidationFailed() + { + await ShouldHandleValidationFailed(); + } + + [Fact] + public async Task Handle_ShouldReturnOnlyPaymentsFromLeague_WhenLeagueIdSet() + { + var league = await dbContext.Leagues + .Include(x => x.Payments) + .FirstAsync(x => x.Id == TestLeagueId); + var request = DefaultRequest(TestLeagueId); + var sut = CreateTestHandler(dbContext, DefaultValidator()); + + var result = await sut.Handle(request, default); + + result.Should().HaveSameCount(league.Payments); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/GetPaymentHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/GetPaymentHandlerTests.cs new file mode 100644 index 00000000..78514308 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/GetPaymentHandlerTests.cs @@ -0,0 +1,64 @@ +using FluentValidation; +using iRLeagueApiCore.Server.Handlers.AdminPanel; +using iRLeagueApiCore.Server.Models.Payments; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.AdminPanel; +public sealed class GetPaymentHandlerTests + : AdminPanelTestsBase +{ + protected override GetPaymentRequest DefaultRequest() + { + return DefaultRequest(TestPaymentId); + } + + private GetPaymentRequest DefaultRequest(Guid paymentId) + { + return new(paymentId); + } + + protected override GetPaymentHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetPaymentHandler(logger, dbContext, new[] { validator }); + } + + protected override void DefaultAssertions(GetPaymentRequest request, PaymentModel result, LeagueDbContext dbContext) + { + base.DefaultAssertions(request, result, dbContext); + var payment = dbContext.Payments + .Include(x => x.Subscription) + .IgnoreQueryFilters() + .First(x => x.Id == request.Id); + result.Should().NotBeNull(); + result.Id.Should().Be(request.Id); + result.Interval.Should().Be(payment.Subscription!.Interval); + result.Status.Should().Be(payment.Status); + result.SubscriptionId.Should().Be(payment.SubscriptionId); + result.LastPayment.Should().Be(payment.LastPaymentReceived); + result.NextPayment.Should().Be(payment.NextPaymentDue); + result.UserId.Should().Be(payment.UserId); + } + + [Fact] + public async Task Handle_ShouldHandleDefault() + { + await ShouldHandleDefault(); + } + + [Fact] + public async Task Handle_ShouldHandleValidationFailed() + { + await ShouldHandleValidationFailed(); + } + + [Fact] + public async Task Handle_ShouldHandleNotFound() + { + var id = Guid.NewGuid(); + var request = DefaultRequest(id); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/PostPaymentHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/PostPaymentHandlerTests.cs new file mode 100644 index 00000000..1de4cb9f --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/PostPaymentHandlerTests.cs @@ -0,0 +1,108 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Server.Handlers.AdminPanel; +using iRLeagueApiCore.Server.Models.Payments; +using iRLeagueApiCore.UnitTests.Server.Handlers.AdminPanel; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.AdminPanel; + +public sealed class PostPaymentHandlerTests + : AdminPanelTestsBase +{ + protected override PostPaymentHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + public static IEnumerable GetSetPaymentStatusData() + { + yield return new object?[] { DateTime.UtcNow, DateTime.UtcNow.AddDays(1), PaymentStatus.Active }; + yield return new object?[] { DateTime.UtcNow, null, PaymentStatus.Active }; + yield return new object?[] { DateTime.UtcNow.AddDays(-2), DateTime.UtcNow.AddDays(-1), PaymentStatus.Inactive }; + } + + protected override PostPaymentRequest DefaultRequest() + { + var model = fixture.Build() + .With(x => x.PlanId, dbContext.Subscriptions.Last().PlanId) + .Create(); + return new(TestLeagueId, model); + } + + private static PostPaymentRequest DefaultRequest(long leagueId, PostPaymentModel model) + { + return new(leagueId, model); + } + + protected override void DefaultAssertions(PostPaymentRequest request, PaymentModel result, LeagueDbContext dbContext) + { + base.DefaultAssertions(request, result, dbContext); + var payment = dbContext.Payments + .Include(x => x.Subscription) + .First(x => x.Id == result.Id); + payment.Subscription.Should().NotBeNull(); + + result.LeagueId.Should().Be(request.LeagueId); + result.PlanId.Should().Be(request.Model.PlanId); + result.Interval.Should().Be(payment.Subscription!.Interval); + } + + [Fact] + public async Task Handle_ShouldHandleDefault() + { + await ShouldHandleDefault(); + } + + [Fact] + public async Task Handle_ShouldHandleValidationFailed() + { + await ShouldHandleValidationFailed(); + } + + [Theory] + [MemberData(nameof(GetSetPaymentStatusData))] + + public async Task Handle_ShouldSetPaymentStatus(DateTime received, DateTime? due, PaymentStatus expected) + { + var model = fixture.Build() + .With(x => x.Received, received) + .With(x => x.NextDue, due) + .Create(); + var request = DefaultRequest(TestLeagueId, model); + var sut = CreateTestHandler(dbContext, DefaultValidator()); + + var test = await sut.Handle(request, default); + + test.Status.Should().Be(expected); + } + + [Theory] + [InlineData(SubscriptionStatus.Expired, SubscriptionStatus.PaidPlan)] + [InlineData(SubscriptionStatus.Unknown, SubscriptionStatus.PaidPlan)] + [InlineData(SubscriptionStatus.FreeTrial, SubscriptionStatus.PaidPlan)] + [InlineData(SubscriptionStatus.PaidPlan, SubscriptionStatus.PaidPlan)] + [InlineData(SubscriptionStatus.Lifetime, SubscriptionStatus.Lifetime)] + public async Task Handle_ShouldSetLeagueSubscriptionStatus(SubscriptionStatus before, SubscriptionStatus after) + { + var model = fixture.Build() + .With(x => x.Received, DateTime.UtcNow) + .With(x => x.NextDue, DateTime.UtcNow.AddMonths(1)) + .Create(); + var request = DefaultRequest(TestLeagueId, model); + var league = await dbContext.Leagues.FirstAsync(x => x.Id == request.LeagueId); + league.Subscription = before; + await dbContext.SaveChangesAsync(); + var sut = CreateTestHandler(dbContext, DefaultValidator()); + + var test = await sut.Handle(request, default); + + league = await dbContext.Leagues.FirstAsync(x => x.Id == request.LeagueId); + league.Subscription.Should().Be(after); + if (after != SubscriptionStatus.Lifetime) + { + league.Expires.Should().Be(request.Model.NextDue); + } + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/SetLeagueSubscriptionHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/SetLeagueSubscriptionHandlerTests.cs new file mode 100644 index 00000000..3f71728f --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/AdminPanel/SetLeagueSubscriptionHandlerTests.cs @@ -0,0 +1,61 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.AdminPanel; +using iRLeagueApiCore.Server.Models.Payments; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.AdminPanel; +public sealed class SetLeagueSubscriptionHandlerTests + : AdminPanelTestsBase +{ + private readonly DateTime testDateTime; + + public SetLeagueSubscriptionHandlerTests() + { + testDateTime = fixture.Create(); + } + + protected override SetLeagueSubscriptionHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + protected override SetLeagueSubscriptionRequest DefaultRequest() + { + return DefaultRequest(TestLeagueId); + } + + private SetLeagueSubscriptionRequest DefaultRequest(long leagueId) + { + var model = new SetLeagueSubscriptionModel(Common.Enums.SubscriptionStatus.PaidPlan, testDateTime); + return new(leagueId, model); + } + + protected override void DefaultAssertions(SetLeagueSubscriptionRequest request, LeagueModel result, LeagueDbContext dbContext) + { + base.DefaultAssertions(request, result, dbContext); + result.SubscriptionStatus.Should().Be(request.Model.Status); + result.SubscriptionExpires.Should().Be(request.Model.Expires); + } + + [Fact] + public async Task Handle_ShouldHandleDefault() + { + await ShouldHandleDefault(); + } + + [Fact] + public async Task Handle_ShouldHandleValidationFailed() + { + await ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0)] + [InlineData(-42)] + public async Task Handle_ShouldHandleNotFound(long leagueId) + { + var request = DefaultRequest(leagueId); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/ChampionshipHandlersTestsBase.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/ChampionshipHandlersTestsBase.cs new file mode 100644 index 00000000..8b6a91c4 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/ChampionshipHandlersTestsBase.cs @@ -0,0 +1,84 @@ +using iRLeagueApiCore.Common.Models; +using iRLeagueDatabaseCore.Models; +using MediatR; +using Xunit.Sdk; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Championships; +public abstract class ChampionshipHandlersTestsBase : HandlersTestsBase + where THandler : IRequestHandler + where TRequest : class, IRequest +{ + protected long TestChampionshipId => dbContext.Championships.First().ChampionshipId; + protected long TestChampSeasonId => dbContext.ChampSeasons.First().ChampSeasonId; + + public override async Task InitializeAsync() + { + await base.InitializeAsync(); + + var league = dbContext.Leagues.First(); + var championships = dbContext.Championships; + + var season = dbContext.Seasons.First(); + foreach (var championship in championships) + { + var champSeason = accessMockHelper.CreateChampSeason(championship, season, nResultConfigs: 2); + dbContext.ChampSeasons.Add(champSeason); + } + var season2 = accessMockHelper.CreateSeason(league); + dbContext.Seasons.Add(season2); + + await dbContext.SaveChangesAsync(); + } + + protected void CompareChampionshipEntity(ChampionshipEntity test, ChampionshipEntity expected) + { + test.Name.Should().Be(expected.Name); + test.DisplayName.Should().Be(expected.DisplayName); + } + + protected void CompareChampSeasonEntity(ChampSeasonEntity test, ChampSeasonEntity expected) + { + test.ChampionshipId.Should().Be(expected.ChampionshipId); + test.SeasonId.Should().Be(expected.SeasonId); + CompareStandingConfigurationEntity(test.StandingConfiguration, expected.StandingConfiguration); + test.ResultConfigurations.Should().HaveSameCount(expected.ResultConfigurations); + test.ResultConfigurations.Zip(expected.ResultConfigurations) + .ToList() + .ForEach(x => CompareResultConfigurationEntity(x.First, x.Second)); + } + + protected void CompareStandingConfigurationEntity(StandingConfigurationEntity test, StandingConfigurationEntity expected) + { + test.ResultKind.Should().Be(expected.ResultKind); + test.UseCombinedResult.Should().Be(expected.UseCombinedResult); + test.WeeksCounted.Should().Be(expected.WeeksCounted); + } + + protected void CompareResultConfigurationEntity(ResultConfigurationEntity test, ResultConfigurationEntity expected) + { + test.PointFilters.Should().HaveSameCount(expected.PointFilters); + test.PointFilters.Zip(expected.PointFilters) + .ToList() + .ForEach(x => CompareFilterOptionEntity(x.First, x.Second)); + test.ResultFilters.Should().HaveSameCount(expected.ResultFilters); + test.ResultFilters.Zip(expected.ResultFilters) + .ToList() + .ForEach(x => CompareFilterOptionEntity(x.First, x.Second)); + } + + protected void CompareFilterOptionEntity(FilterOptionEntity test, FilterOptionEntity expected) + { + test.Conditions.Should().HaveSameCount(expected.Conditions); + test.Conditions.Zip(expected.Conditions) + .ToList() + .ForEach(x => CompareFilterConditionEntity(x.First, x.Second)); + } + + protected void CompareFilterConditionEntity(FilterConditionModel test, FilterConditionModel expected) + { + test.FilterType.Should().Be(expected.FilterType); + test.FilterValues.Should().BeEquivalentTo(expected.FilterValues); + test.Comparator.Should().Be(expected.Comparator); + test.Action.Should().Be(expected.Action); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/DeleteChampSeasonHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/DeleteChampSeasonHandlerTests.cs new file mode 100644 index 00000000..2edcbbcf --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/DeleteChampSeasonHandlerTests.cs @@ -0,0 +1,40 @@ +using FluentValidation; +using iRLeagueApiCore.Server.Handlers.Championships; +using iRLeagueDatabaseCore.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Championships; +public sealed class DeleteChampSeasonHandlerTests : + ChampionshipHandlersTestsBase +{ + protected override DeleteChampSeasonHandler CreateTestHandler(LeagueDbContext dbContext, + IValidator validator) + { + return new DeleteChampSeasonHandler(logger, dbContext, new[] { validator }); + } + + protected override DeleteChampSeasonRequest DefaultRequest() + { + return DefaultRequest(TestChampSeasonId); + } + + private DeleteChampSeasonRequest DefaultRequest(long champSeasonId) + { + return new DeleteChampSeasonRequest(champSeasonId); + } + + protected override void DefaultAssertions(DeleteChampSeasonRequest request, Unit result, LeagueDbContext dbContext) + { + var test = dbContext.ChampSeasons.FirstOrDefault(x => x.ChampSeasonId == request.ChampSeasonId); + test.Should().NotBeNull(); + test!.IsActive.Should().BeFalse(); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public async Task HandleDefault() + { + await ShouldHandleDefault(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/PostChampSeasonHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/PostChampSeasonHandlerTests.cs new file mode 100644 index 00000000..28ffe09d --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/PostChampSeasonHandlerTests.cs @@ -0,0 +1,85 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Championships; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Championships; +public sealed class PostChampSeasonHandlerTests : ChampionshipHandlersTestsBase +{ + protected override PostChampSeasonHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PostChampSeasonHandler(logger, dbContext, new[] { validator }); + } + + protected override PostChampSeasonRequest DefaultRequest() + { + return DefaultRequest(TestChampionshipId, TestSeasonId); + } + + private PostChampSeasonRequest DefaultRequest(long championshipId, long seasonId) + { + return new(championshipId, seasonId, DefaultUser(), new()); + } + + [Fact] + public async Task HandleDefault() + { + await ShouldHandleDefault(); + } + + [Fact] + public async Task Handle_ShouldCopySettings_WhenPreviousSeasonExists() + { + var request = DefaultRequest(TestChampionshipId, (await dbContext.Seasons.Skip(1).FirstAsync()).SeasonId); + var champSeasonQuery = dbContext.ChampSeasons + .Include(x => x.Championship) + .Include(x => x.ResultConfigurations) + .ThenInclude(x => x.Scorings) + .ThenInclude(x => x.PointsRule) + .Include(x => x.ResultConfigurations) + .ThenInclude(x => x.PointFilters) + .Include(x => x.ResultConfigurations) + .ThenInclude(x => x.ResultFilters) + .Include(x => x.StandingConfiguration); + var prevChampSeason = await champSeasonQuery + .Where(x => x.ChampionshipId == TestChampionshipId) + .FirstAsync(); + await HandleSpecialAsync(request, async (request, model, context) => + { + var postChampSeason = await champSeasonQuery + .Where(x => x.ChampSeasonId == model.ChampSeasonId) + .FirstAsync(); + postChampSeason.ChampionshipId.Should().Be(prevChampSeason.ChampionshipId); + CompareStandingConfigurationEntity(postChampSeason.StandingConfiguration, prevChampSeason.StandingConfiguration); + postChampSeason.ResultConfigurations.Should().HaveSameCount(prevChampSeason.ResultConfigurations); + postChampSeason.ResultConfigurations.Zip(prevChampSeason.ResultConfigurations) + .ToList() + .ForEach(x => CompareResultConfigurationEntity(x.First, x.Second)); + }, + async (request, context) => + { + var existingChampSeason = await champSeasonQuery + .Where(x => x.ChampionshipId == request.ChampionshipId) + .Where(x => x.SeasonId == request.SeasonId) + .FirstOrDefaultAsync(); + existingChampSeason.Should().BeNull(); + }); + } + + [Fact] + public async Task Handle_ShouldActivateExistingSeason_WhenInactive() + { + var champSeason = await dbContext.ChampSeasons.FirstAsync(); + champSeason.IsActive = false; + await dbContext.SaveChangesAsync(); + + var request = DefaultRequest(champSeason.ChampionshipId, champSeason.SeasonId); + await HandleSpecialAsync(request, async (request, model, context) => + { + var test = await context.ChampSeasons.FirstAsync(); + test.IsActive.Should().BeTrue(); + }); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/PutChampSeasonHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/PutChampSeasonHandlerTests.cs new file mode 100644 index 00000000..80c64908 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Championships/PutChampSeasonHandlerTests.cs @@ -0,0 +1,47 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Championships; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Championships; +public sealed class PutChampSeasonHandlerTests : ChampionshipHandlersTestsBase +{ + protected override PutChampSeasonHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + protected override PutChampSeasonRequest DefaultRequest() + { + throw new NotImplementedException(); + } + + [Fact] + public async Task ShouldSetDefaultResultConfig() + { + var champSeason = await dbContext.ChampSeasons + .Include(x => x.DefaultResultConfig) + .Include(x => x.ResultConfigurations) + .FirstAsync(); + var defaultResultConfig = champSeason.ResultConfigurations.Last(); + champSeason.DefaultResultConfig?.ResultConfigId.Should().NotBe(defaultResultConfig.ResultConfigId); + var request = new PutChampSeasonRequest(champSeason.ChampSeasonId, DefaultUser(), new() + { + DefaultResultConfig = new() { LeagueId = champSeason.LeagueId, ResultConfigId = defaultResultConfig.ResultConfigId }, + ResultConfigs = champSeason.ResultConfigurations.Select(x => new ResultConfigInfoModel() { ResultConfigId = x.ResultConfigId, Name = x.Name }).ToArray(), + }); + var sut = CreateSut(); + + var test = await sut.Handle(request, default); + + test.DefaultResultConfig.Should().NotBeNull(); + test.DefaultResultConfig!.ResultConfigId.Should().Be(defaultResultConfig.ResultConfigId); + } + + private PutChampSeasonHandler CreateSut() + { + return CreateTestHandler(dbContext, MockHelpers.TestValidator()); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/HandlersTestsBase.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/HandlersTestsBase.cs new file mode 100644 index 00000000..6af6bdad --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/HandlersTestsBase.cs @@ -0,0 +1,171 @@ +using FluentIdentityBuilder; +using FluentValidation; +using FluentValidation.Results; +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Server.Exceptions; +using iRLeagueApiCore.Server.Models; +using iRLeagueApiCore.UnitTests.Extensions; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using MediatR; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using System.Security.Claims; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers; + +public abstract class HandlersTestsBase : DataAccessTestsBase + where THandler : IRequestHandler + where TRequest : class, IRequest +{ + protected readonly ILogger logger; + + public HandlersTestsBase() + { + logger = Mock.Of>(); + } + + protected abstract TRequest DefaultRequest(); + + protected abstract THandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator); + + protected ValidationResult ValidationFailed() + { + return new ValidationResult(new ValidationFailure[] { new ValidationFailure("Property", "Error") }); + } + + protected virtual IValidator DefaultValidator() + { + return MockHelpers.TestValidator(); + } + + protected virtual void DefaultPreTestAssertions(TRequest request, LeagueDbContext dbContext) + { + } + + protected virtual void DefaultAssertions(TRequest request, TResult result, LeagueDbContext dbContext) + { + result.Should().NotBeNull(); + } + + protected virtual void AssertVersion(IVersionEntity expected, IVersionModel result) + { + result.CreatedByUserId.Should().Be(expected.CreatedByUserId); + result.CreatedByUserName.Should().Be(expected.CreatedByUserName); + result.CreatedOn.Should().Be(expected.CreatedOn); + result.LastModifiedByUserId.Should().Be(expected.LastModifiedByUserId); + result.LastModifiedByUserName.Should().Be(expected.LastModifiedByUserName); + result.LastModifiedOn.Should().Be(expected.LastModifiedOn); + } + + protected virtual void AssertCreated(LeagueUser user, DateTime time, IVersionModel result) + { + result.CreatedByUserId.Should().Be(user.Id); + result.CreatedByUserName.Should().Be(user.Name); + result.CreatedOn.Should().BeCloseTo(time, TimeSpan.FromSeconds(10)); + result.LastModifiedByUserId.Should().Be(user.Id); + result.LastModifiedByUserName.Should().Be(user.Name); + result.LastModifiedOn.Should().BeCloseTo(time, TimeSpan.FromSeconds(10)); + } + + protected virtual void AssertChanged(LeagueUser user, DateTime time, IVersionModel result) + { + result.LastModifiedByUserId.Should().Be(user.Id); + result.LastModifiedByUserName.Should().Be(user.Name); + result.LastModifiedOn.Should().BeCloseTo(time, TimeSpan.FromSeconds(10)); + } + + protected virtual ClaimsPrincipal DefaultPrincipal(string leagueName = testLeagueName, string userName = testUserName, + string userId = testUserId, IEnumerable? roles = default) + { + roles ??= testLeagueRoles; + var builder = StaticIdentityBuilders.BuildPrincipal() + .WithName(userName) + .WithIdentifier(userId); + foreach (var role in roles) + { + builder.WithRole(LeagueRoles.GetLeagueRoleName(leagueName, role)); + } + return builder.Create(); + } + + protected virtual LeagueUser DefaultUser(string leagueName = testLeagueName, string userName = testUserName, + string userId = testUserId, IEnumerable? roles = default) + { + return new LeagueUser(leagueName, DefaultPrincipal(leagueName, userName, userId, roles)); + } + + /// + /// Run the method and perform default assertions + /// Assertions can be modified by overriding + /// + /// Result of the handle method + public virtual async Task ShouldHandleDefault() + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + + var request = DefaultRequest(); + var handler = CreateTestHandler(dbContext, MockHelpers.TestValidator()); + + DefaultPreTestAssertions(request, dbContext); + var result = await handler.Handle(request, default); + DefaultAssertions(request, result, dbContext); + + return result; + } + + /// + /// Run the method and assert throwing + /// + /// Request for a not existing resource + public async Task HandleNotFoundRequestAsync(TRequest? request = null) + { + request ??= DefaultRequest(); + var act = async () => await HandleSpecialAsync(request, null); + await act.Should() + .ThrowAsync(); + } + + /// + /// Run the method and perform the provided assertions + /// + /// Request for a not existing resource + /// Assertions to be performed + /// + public virtual async Task HandleSpecialAsync(TRequest request, Action? assertions, + Action? preTestAssertions = default) + { + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + + var handler = CreateTestHandler(dbContext, MockHelpers.TestValidator()); + + preTestAssertions?.Invoke(request, dbContext); + var result = await handler.Handle(request, default); + assertions?.Invoke(request, result, dbContext); + + return result; + } + + /// + /// Run the method and assert throwing + /// (); + mockValidator.Setup(x => x.Validate(It.IsAny())) + .Returns(ValidationFailed()); + mockValidator.Setup(x => x.ValidateAsync(It.IsAny(), default)) + .ReturnsAsync(ValidationFailed()); + + var request = DefaultRequest(); + var handler = CreateTestHandler(dbContext, mockValidator.Object); + + var act = async () => await handler.Handle(request, default); + await act.Should() + .ThrowAsync(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/DeleteLeagueHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/DeleteLeagueHandlerTests.cs new file mode 100644 index 00000000..c218c2cb --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/DeleteLeagueHandlerTests.cs @@ -0,0 +1,60 @@ +using FluentValidation; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using MediatR; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Leagues; + +public sealed class DeleteLeagueDbTestFixture : HandlersTestsBase +{ + public DeleteLeagueDbTestFixture() : base() + { + } + + protected override DeleteLeagueHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new DeleteLeagueHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override DeleteLeagueRequest DefaultRequest() + { + return DefaultRequest(dbContext.Leagues.First().Id); + } + + protected override void DefaultPreTestAssertions(DeleteLeagueRequest request, LeagueDbContext dbContext) + { + Assert.Contains(dbContext.Leagues, x => x.Id == request.LeagueId); + } + + protected override void DefaultAssertions(DeleteLeagueRequest request, Unit result, LeagueDbContext dbContext) + { + Assert.DoesNotContain(dbContext.Leagues, x => x.Id == request.LeagueId); + } + + private DeleteLeagueRequest DefaultRequest(long leagueId) + { + return new DeleteLeagueRequest(leagueId); + } + + [Fact] + public async override Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public async override Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0)] + [InlineData(-42)] + public async Task HandleNotFoundAsync(long leagueId) + { + var request = DefaultRequest(leagueId); + await base.HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/GetLeagueHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/GetLeagueHandlerTests.cs new file mode 100644 index 00000000..413179a1 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/GetLeagueHandlerTests.cs @@ -0,0 +1,57 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Leagues; + +public sealed class GetLeagueDbTestFixture : HandlersTestsBase +{ + public GetLeagueDbTestFixture() : base() + { + } + + protected override GetLeagueHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetLeagueHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override GetLeagueRequest DefaultRequest() + { + return DefaultRequest(dbContext.Leagues.First().Id); + } + + private GetLeagueRequest DefaultRequest(long leagueId) + { + return new GetLeagueRequest(leagueId, false); + } + + protected override void DefaultAssertions(GetLeagueRequest request, LeagueModel result, LeagueDbContext dbContext) + { + var entity = dbContext.Leagues.First(x => x.Id == request.LeagueId); + result.IsInitialized.Should().Be(entity.IsInitialized); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0)] + [InlineData(-42)] + public async Task HandleNotFoundAsync(long leagueId) + { + var request = DefaultRequest(leagueId); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/GetLeaguesHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/GetLeaguesHandlerTests.cs new file mode 100644 index 00000000..a99b9ebd --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/GetLeaguesHandlerTests.cs @@ -0,0 +1,65 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity.Test; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Leagues; + +public sealed class GetLeaguesDbTestFixture : HandlersTestsBase> +{ + public GetLeaguesDbTestFixture() : base() + { + } + + protected override GetLeaguesHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetLeaguesHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override GetLeaguesRequest DefaultRequest() + { + return new GetLeaguesRequest(Array.Empty()); + } + + [Fact] + public override async Task> ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Fact] + public async Task ShouldReturnPublicListedLeaguesOnly() + { + var privateLeague = accessMockHelper.CreateLeague(); + privateLeague.LeaguePublic = Common.Enums.LeaguePublicSetting.PublicHidden; + dbContext.Leagues.Add(privateLeague); + await dbContext.SaveChangesAsync(); + var sut = CreateTestHandler(dbContext, MockHelpers.TestValidator()); + + var test = await sut.Handle(DefaultRequest(), default); + + test.Should().AllSatisfy(x => x.Id.Should().NotBe(privateLeague.Id)); + } + + [Fact] + public async Task ShouldReturnHiddenLeague_IfUserIsMember() + { + var privateLeague = accessMockHelper.CreateLeague(); + privateLeague.LeaguePublic = Common.Enums.LeaguePublicSetting.PublicHidden; + dbContext.Leagues.Add(privateLeague); + await dbContext.SaveChangesAsync(); + var sut = CreateTestHandler(dbContext, MockHelpers.TestValidator()); + + var test = await sut.Handle(new GetLeaguesRequest(new[] { privateLeague.Name }), default); + + test.Should().Contain(x => x.Name == privateLeague.Name); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/PostInitializeLeagueHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/PostInitializeLeagueHandlerTests.cs new file mode 100644 index 00000000..3469c600 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/PostInitializeLeagueHandlerTests.cs @@ -0,0 +1,38 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Leagues; +public sealed class PostInitializeLeagueHandlerTests : HandlersTestsBase +{ + protected override PostInitializeLeagueHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + protected override PostIntitializeLeagueRequest DefaultRequest() + { + return DefaultRequest(TestLeagueId); + } + + private PostIntitializeLeagueRequest DefaultRequest(long leagueId) + { + return new(leagueId); + } + + [Fact] + public async Task ShouldSetInitializedTrue() + { + var testLeague = await dbContext.Leagues.FirstAsync(); + testLeague.IsInitialized = false; + await dbContext.SaveChangesAsync(); + var request = DefaultRequest(testLeague.Id); + var sut = CreateTestHandler(dbContext, DefaultValidator()); + + await sut.Handle(request, default); + + testLeague.IsInitialized.Should().BeTrue(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/PostLeagueHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/PostLeagueHandlerTests.cs new file mode 100644 index 00000000..6e967b5c --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/PostLeagueHandlerTests.cs @@ -0,0 +1,135 @@ +using FluentValidation; +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.Server.Models; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.Test; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Leagues; + +public sealed class PostLeagueDbTestFixture : HandlersTestsBase +{ + private const string postLeagueName = "PostLeague"; + + private List Users { get; init; } + private Dictionary Roles { get; init; } + private Dictionary> UserRoles { get; init; } + private UserManager TestUserManager { get; init; } + private RoleManager TestRoleManager { get; init; } + + public PostLeagueDbTestFixture() : base() + { + Users = new() { new ApplicationUser() { UserName = testUserName, Id = testUserId } }; + Roles = new IdentityRole[] + { + new("Admin"), + new(LeagueRoles.GetLeagueRoleName(testLeagueName, LeagueRoles.Admin)), + new(LeagueRoles.GetLeagueRoleName(testLeagueName, LeagueRoles.Owner)) + }.ToDictionary(k => k.Id, v => v); + UserRoles = new(); + TestUserManager = GetTestUserManager(); + TestRoleManager = GetTestRoleManager(); + } + + protected override PostLeagueHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PostLeagueHandler(logger, dbContext, new IValidator[] { validator }, TestUserManager, TestRoleManager ); + } + + protected override PostLeagueRequest DefaultRequest() + { + var model = new PostLeagueModel() + { + Name = postLeagueName, + NameFull = "Full test league name" + }; + return CreateRequest(DefaultUser(), model); + } + + protected override void DefaultAssertions(PostLeagueRequest request, LeagueModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.Id.Should().NotBe(0); + result.Name.Should().Be(expected.Name); + result.NameFull.Should().Be(expected.NameFull); + AssertCreated(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + private PostLeagueRequest CreateRequest(LeagueUser user, PostLeagueModel model) + { + return new PostLeagueRequest(user, model); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + var result = await base.ShouldHandleDefault(); + return result; + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Fact] + public async Task ShouldCreateOwnerRole() + { + await base.ShouldHandleDefault(); + var ownerRole = TestRoleManager.FindByNameAsync(LeagueRoles.GetLeagueRoleName(postLeagueName, LeagueRoles.Owner)); + ownerRole.Should().NotBeNull(); + } + + [Fact] + public async Task ShouldAddUserToOwnerRole() + { + await base.ShouldHandleDefault(); + var user = await TestUserManager.FindByIdAsync(testUserId); + var isInRole = await TestUserManager.IsInRoleAsync(user, LeagueRoles.GetLeagueRoleName(postLeagueName, LeagueRoles.Owner)); + isInRole.Should().BeTrue(); + } + + [Fact] + public async Task ShouldNotCreateLeague_WhenUserRoleActionFails() + { + var nonExistingUser = fixture.Create(); + var request = CreateRequest(nonExistingUser, DefaultRequest().Model); + var handler = CreateTestHandler(dbContext, MockHelpers.TestValidator()); + var handle = () => handler.Handle(request); + await handle.Should().ThrowAsync(); + + // make sure league does not exist + var league = dbContext.Leagues.FirstOrDefault(x => x.Name == postLeagueName); + league.Should().BeNull(); + } + + private IRoleStore GetTestRoleStore() + { + return MockHelpers.TestRoleStore(Roles); + } + + private IUserRoleStore GetTestUserRoleStore() + { + var userStore = MockHelpers.TestUserStore(Users); + var roleStore = GetTestRoleStore(); + return MockHelpers.TestUserRoleStore(userStore, roleStore, UserRoles); + } + + private UserManager GetTestUserManager() + { + var userStore = GetTestUserRoleStore(); + return MockHelpers.TestUserManager(userStore); + } + + private RoleManager GetTestRoleManager() + { + var roleStore = GetTestRoleStore(); + return MockHelpers.TestRoleManager(roleStore); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/PutLeagueHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/PutLeagueHandlerTests.cs new file mode 100644 index 00000000..e41c30db --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Leagues/PutLeagueHandlerTests.cs @@ -0,0 +1,72 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Leagues; + +public sealed class PutLeagueDbTestFixture : HandlersTestsBase +{ + public PutLeagueDbTestFixture() : base() + { + } + + protected override PutLeagueHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PutLeagueHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override PutLeagueRequest DefaultRequest() + { + return DefaultRequest(dbContext.Leagues.First().Id); + } + + public PutLeagueRequest DefaultRequest(long leagueId) + { + var model = new PutLeagueModel() + { + NameFull = "Put league test", + EnableProtests = true, + ProtestCoolDownPeriod = fixture.Create(), + ProtestsClosedAfter = fixture.Create(), + ProtestsPublic = fixture.Create(), + }; + return new PutLeagueRequest(leagueId, DefaultUser(), model); + } + + protected override void DefaultAssertions(PutLeagueRequest request, LeagueModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.Id.Should().Be(request.LeagueId); + result.NameFull.Should().Be(expected.NameFull); + result.EnableProtests.Should().Be(request.Model.EnableProtests); + result.ProtestCoolDownPeriod.Should().Be(request.Model.ProtestCoolDownPeriod); + result.ProtestsClosedAfter.Should().Be(request.Model.ProtestsClosedAfter); + result.ProtestsPublic.Should().Be(request.Model.ProtestsPublic); + AssertChanged(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0)] + [InlineData(-42)] + public async Task HandleNotFoundAsync(long leagueId) + { + var request = DefaultRequest(leagueId); + await base.HandleNotFoundRequestAsync(request); + } + + [Fact] + public async override Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/DeleteResultConfigHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/DeleteResultConfigHandlerTests.cs new file mode 100644 index 00000000..93b1dd75 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/DeleteResultConfigHandlerTests.cs @@ -0,0 +1,63 @@ +using FluentValidation; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; + +public sealed class DeleteResultConfigHandlerTests : ResultHandlersTestsBase +{ + public DeleteResultConfigHandlerTests() : base() + { + } + + protected override DeleteResultConfigHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new DeleteResultConfigHandler(logger, dbContext, new IValidator[] { validator }); + } + + private DeleteResultConfigRequest DefaultRequest(long resultConfigId) + { + return new DeleteResultConfigRequest(resultConfigId); + } + + protected override DeleteResultConfigRequest DefaultRequest() + { + return DefaultRequest(TestResultConfigId); + } + + protected override void DefaultAssertions(DeleteResultConfigRequest request, MediatR.Unit result, LeagueDbContext dbContext) + { + var deletedResultConfig = dbContext.ResultConfigurations + .Where(x => x.ResultConfigId == request.ResultConfigId) + .FirstOrDefault(); + deletedResultConfig.Should().BeNull(); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task HandleNotFoundAsync(long? leagueId, long? resultId) + { + leagueId ??= TestLeagueId; + resultId ??= TestResultId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(resultId.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetLatestResultHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetLatestResultHandlerTests.cs new file mode 100644 index 00000000..125b6e45 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetLatestResultHandlerTests.cs @@ -0,0 +1,68 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; +public sealed class GetLatestResultHandlerTests : ResultHandlersTestsBase> +{ + protected override GetLatestResultHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + protected override GetLatestResultRequest DefaultRequest() + { + return new(); + } + + [Fact] + public async Task ShouldReturnLatestEventWithResult() + { + var eventWithResult = await dbContext.Events.FirstAsync(); + var request = DefaultRequest(); + var sut = CreateSut(); + + var test = await sut.Handle(request, default); + + test.Should().NotBeEmpty(); + test.Should().OnlyContain(x => x.EventId == eventWithResult.EventId); + } + + [Fact] + public async Task ShouldReturnLatestEventWithResult_EvenWhenPreviousEventHasNoResult() + { + var eventWithResult = await dbContext.Events.OrderBy(x => x.Date).LastAsync(); + await CreateScoredEventResults(eventWithResult); + var request = DefaultRequest(); + var sut = CreateSut(); + + var test = await sut.Handle(request, default); + + test.Should().NotBeEmpty(); + test.Should().OnlyContain(x => x.EventId == eventWithResult.EventId); + } + + [Fact] + public async Task ShouldReturnEmptyResult_WhenNoResultExists() + { + foreach(var scoredResult in dbContext.ScoredEventResults) + { + dbContext.Remove(scoredResult); + } + await dbContext.SaveChangesAsync(); + var request = DefaultRequest(); + var sut = CreateSut(); + + var test = await sut.Handle(request, default); + + test.Should().BeEmpty(); + } + + private GetLatestResultHandler CreateSut() + { + return CreateTestHandler(dbContext, MockHelpers.TestValidator()); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultConfigHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultConfigHandlerTests.cs new file mode 100644 index 00000000..75d488e7 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultConfigHandlerTests.cs @@ -0,0 +1,69 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity.Test; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; + +public sealed class GetResultConfigHandlerTests : ResultHandlersTestsBase +{ + public GetResultConfigHandlerTests() : base() + { + } + + protected override GetResultConfigHandler CreateTestHandler(LeagueDbContext dbContext, IValidator? validator = null) + { + return new GetResultConfigHandler(logger, dbContext, + new IValidator[] { validator ?? MockHelpers.TestValidator() }); + } + + private GetResultConfigRequest DefaultRequest(long resultConfigId) + { + return new GetResultConfigRequest(resultConfigId); + } + + protected override GetResultConfigRequest DefaultRequest() + { + return DefaultRequest(TestResultConfigId); + } + + protected override void DefaultAssertions(GetResultConfigRequest request, ResultConfigModel result, LeagueDbContext dbContext) + { + var resultConfigEntity = dbContext.ResultConfigurations + .FirstOrDefault(x => x.ResultConfigId == request.ResultConfigId); + resultConfigEntity.Should().NotBeNull(); + result.ResultConfigId.Should().Be(request.ResultConfigId); + result.Name.Should().Be(resultConfigEntity!.Name); + result.DisplayName.Should().Be(resultConfigEntity.DisplayName); + result.ResultsPerTeam.Should().Be(resultConfigEntity.ResultsPerTeam); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? resultConfigId) + { + leagueId ??= TestLeagueId; + resultConfigId ??= TestResultConfigId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(resultConfigId!.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultConfigsFromSeasonHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultConfigsFromSeasonHandlerTests.cs new file mode 100644 index 00000000..3a9be8b0 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultConfigsFromSeasonHandlerTests.cs @@ -0,0 +1,44 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; +using System.Diagnostics.Contracts; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; +public sealed class GetResultConfigsFromSeasonHandlerTests : ResultHandlersTestsBase> +{ + protected override GetResultConfigsFromSeasonHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + protected override GetResultConfigsFromSeasonRequest DefaultRequest() => DefaultRequest(TestSeasonId); + + private GetResultConfigsFromSeasonRequest DefaultRequest(long seasonId) => new(seasonId); + + protected override void DefaultAssertions(GetResultConfigsFromSeasonRequest request, IEnumerable result, LeagueDbContext dbContext) + { + base.DefaultAssertions(request, result, dbContext); + var champSeasons = dbContext.ChampSeasons + .Where(x => x.IsActive) + .Where(x => x.SeasonId == request.SeasonId); + var resultConfig = champSeasons.SelectMany(x => x.ResultConfigurations); + result.Should().HaveSameCount(resultConfig); + } + + [Fact] + public override Task> ShouldHandleDefault() + { + return base.ShouldHandleDefault(); + } + + [Fact] + public async Task ShouldHandle_WhenChampSeasonIsInactive() + { + var inActiveChampSeason = await dbContext.ChampSeasons.LastAsync(); + inActiveChampSeason.IsActive = false; + await dbContext.SaveChangesAsync(); + await base.ShouldHandleDefault(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultHandlerTests.cs new file mode 100644 index 00000000..405aa40e --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultHandlerTests.cs @@ -0,0 +1,127 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; + +public sealed class GetResultHandlerTests : ResultHandlersTestsBase +{ + public GetResultHandlerTests() : base() + { + } + + protected override GetResultHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetResultHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override GetResultRequest DefaultRequest() + { + return DefaultRequest(TestResultId); + } + + private GetResultRequest DefaultRequest(long resultId) + { + return new GetResultRequest(resultId); + } + + protected override void DefaultAssertions(GetResultRequest request, EventResultModel result, LeagueDbContext dbContext) + { + base.DefaultAssertions(request, result, dbContext); + var actualResult = dbContext.ScoredEventResults + .Where(x => x.ResultId == request.ResultId) + .Include(x => x.ScoredSessionResults) + .ThenInclude(x => x.ScoredResultRows) + .ThenInclude(x => x.Member) + .Include(x => x.ScoredSessionResults) + .ThenInclude(x => x.ScoredResultRows) + .ThenInclude(x => x.Team) + .Single(); + AssertEventResultData(result, actualResult); + } + + [Fact] + public async override Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public async override Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task HandleNotFoundAsync(long? leagueId, long? resultId) + { + leagueId ??= TestLeagueId; + resultId ??= TestResultId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(resultId.Value); + await HandleNotFoundRequestAsync(request); + } + + private void AssertEventResultData(EventResultModel expected, ScoredEventResultEntity test) + { + Assert.Equal(expected.LeagueId, test.LeagueId); + AssertSessionResultData(expected.SessionResults.OrderBy(x => x.SessionNr).First(), test.ScoredSessionResults.OrderBy(x => x.SessionNr).First()); + } + + private void AssertSessionResultData(ResultModel expected, ScoredSessionResultEntity test) + { + Assert.Equal(expected.ScoringId, test.ScoringId); + Assert.Equal(expected.LeagueId, test.LeagueId); + AssertResultRowData(expected.ResultRows.OrderBy(x => x.FinalPosition).First(), test.ScoredResultRows.OrderBy(x => x.FinalPosition).First()); + } + + private void AssertResultRowData(ResultRowModel expected, ScoredResultRowEntity test) + { + Assert.Equal(expected.BonusPoints, test.BonusPoints); + Assert.Equal(expected.FinalPosition, test.FinalPosition); + Assert.Equal(expected.FinalPositionChange, test.FinalPositionChange); + Assert.Equal(expected.PenaltyPoints, test.PenaltyPoints); + Assert.Equal(expected.RacePoints, test.RacePoints); + Assert.Equal(expected.AvgLapTime, test.AvgLapTime); + Assert.Equal(expected.Car, test.Car); + Assert.Equal(expected.CarClass, test.CarClass); + Assert.Equal(expected.CarId, test.CarId); + Assert.Equal(expected.CarNumber, test.CarNumber); + Assert.Equal(expected.ClassId, test.ClassId); + Assert.Equal(expected.CompletedLaps, test.CompletedLaps); + Assert.Equal(expected.CompletedPct, test.CompletedPct); + Assert.Equal(expected.Division, test.Division); + Assert.Equal(expected.FastestLapTime, test.FastestLapTime); + Assert.Equal(expected.FastLapNr, test.FastLapNr); + Assert.Equal(expected.FinishPosition, test.FinishPosition); + Assert.Equal(expected.Incidents, test.Incidents); + Assert.Equal(expected.Interval, new Interval(test.Interval)); + Assert.Equal(expected.LeadLaps, test.LeadLaps); + Assert.Equal(expected.License, test.License); + Assert.Equal(expected.Firstname, test.Member?.Firstname ?? string.Empty); + Assert.Equal(expected.Lastname, test.Member?.Lastname ?? string.Empty); + Assert.Equal(expected.MemberId, test.MemberId); + Assert.Equal(expected.NewIrating, test.NewIRating); + Assert.Equal(expected.NewLicenseLevel, test.NewLicenseLevel); + Assert.Equal(expected.NewSafetyRating, test.NewSafetyRating); + Assert.Equal(expected.OldIrating, test.OldIRating); + Assert.Equal(expected.OldLicenseLevel, test.OldLicenseLevel); + Assert.Equal(expected.OldSafetyRating, test.OldSafetyRating); + Assert.Equal(expected.PositionChange, test.PositionChange); + Assert.Equal(expected.QualifyingTime, test.QualifyingTime); + Assert.Equal(expected.SeasonStartIrating, test.SeasonStartIRating); + Assert.Equal(expected.StartPosition, test.StartPosition); + Assert.Equal(expected.Status, (RaceStatus)test.Status); + Assert.Equal(expected.TeamName, test.Team?.Name ?? string.Empty); + Assert.Equal(expected.TeamId, test.TeamId); + Assert.Equal(expected.TotalPoints, test.TotalPoints); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultsFromSeasonHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultsFromSeasonHandlerTests.cs new file mode 100644 index 00000000..a4a5f945 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/GetResultsFromSeasonHandlerTests.cs @@ -0,0 +1,64 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; + +public sealed class GetResultsFromSeasonHandlerTests : ResultHandlersTestsBase> +{ + public GetResultsFromSeasonHandlerTests() : base() + { + } + + protected override GetResultsFromSeasonHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetResultsFromSeasonHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override GetResultsFromSeasonRequest DefaultRequest() + { + return DefaultRequest(TestSeasonId); + } + + private GetResultsFromSeasonRequest DefaultRequest(long seasonId) + { + return new GetResultsFromSeasonRequest(seasonId); + } + + protected override void DefaultAssertions(GetResultsFromSeasonRequest request, IEnumerable result, LeagueDbContext dbContext) + { + base.DefaultAssertions(request, result, dbContext); + var seasonResults = dbContext.ScoredEventResults + .Where(x => x.Event.Schedule.SeasonId == request.SeasonId) + .GroupBy(x => x.EventId); + Assert.Equal(seasonResults.Count(), result.Count()); + } + + [Fact] + public async override Task> ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public async override Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task HandleNotFoundAsync(long? leagueId, long? seasonId) + { + leagueId ??= TestLeagueId; + seasonId ??= TestSeasonId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(seasonId.Value); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/PostResultConfigHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/PostResultConfigHandlerTests.cs new file mode 100644 index 00000000..2ae77a13 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/PostResultConfigHandlerTests.cs @@ -0,0 +1,69 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; + +public sealed class PostResultConfigHandlerTests : ResultHandlersTestsBase +{ + public PostResultConfigHandlerTests() : base() + { + } + + protected override PostResultConfigToChampSeasonHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PostResultConfigToChampSeasonHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override PostResultConfigToChampSeasonRequest DefaultRequest() + { + var postResultConfig = new PostResultConfigModel() + { + Name = "TestresultConfig", + DisplayName = "TestResultConfig DisplayName", + ResultsPerTeam = 10, + }; + return new PostResultConfigToChampSeasonRequest(TestChampSeasonId, DefaultUser(), postResultConfig); + } + + protected override void DefaultAssertions(PostResultConfigToChampSeasonRequest request, ResultConfigModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.ResultConfigId.Should().NotBe(0); + result.Name.Should().Be(expected.Name); + result.DisplayName.Should().Be(expected.DisplayName); + result.ResultsPerTeam.Should().Be(expected.ResultsPerTeam); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Fact] + public async Task Handle_ShouldSetSourceResultConfig_WhenIdIsNotNull() + { + var request = DefaultRequest(); + request.Model.SourceResultConfig = new() { ResultConfigId = TestResultConfigId }; + await HandleSpecialAsync(request, async (request, model, dbContext) => + { + model.SourceResultConfig.Should().NotBeNull(); + model.SourceResultConfig!.ResultConfigId.Should().Be(TestResultConfigId); + var sourceConfig = await dbContext.ResultConfigurations.FirstAsync(x => x.ResultConfigId == model.SourceResultConfig.ResultConfigId); + model.SourceResultConfig.DisplayName.Should().Be(sourceConfig.DisplayName); + model.SourceResultConfig.Name.Should().Be(sourceConfig.Name); + model.SourceResultConfig.LeagueId.Should().Be(sourceConfig.LeagueId); + }); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/PutResultConfigHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/PutResultConfigHandlerTests.cs new file mode 100644 index 00000000..8ec320d2 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/PutResultConfigHandlerTests.cs @@ -0,0 +1,77 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Exceptions; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity.Test; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; + +public sealed class PutResultConfigHandlerTests : ResultHandlersTestsBase +{ + public PutResultConfigHandlerTests() : base() + { + } + + protected override PutResultConfigHandler CreateTestHandler(LeagueDbContext dbContext, IValidator? validator = null) + { + return new PutResultConfigHandler(logger, dbContext, + new IValidator[] { validator ?? MockHelpers.TestValidator() }); + } + + private PutResultConfigRequest DefaultRequest(long resultConfigId) + { + var PutResultConfig = new PutResultConfigModel() + { + Name = "TestresultConfig", + DisplayName = "TestResultConfig DisplayName", + ResultsPerTeam = 10, + }; + return new PutResultConfigRequest(resultConfigId, DefaultUser(), PutResultConfig); + } + + protected override PutResultConfigRequest DefaultRequest() + { + return DefaultRequest(TestResultConfigId); + } + + protected override void DefaultAssertions(PutResultConfigRequest request, ResultConfigModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.ResultConfigId.Should().Be(request.ResultConfigId); + result.Name.Should().Be(expected.Name); + result.DisplayName.Should().Be(expected.DisplayName); + result.ResultsPerTeam.Should().Be(expected.ResultsPerTeam); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? resultConfigId) + { + leagueId ??= TestLeagueId; + resultConfigId ??= TestResultConfigId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + using var dbContext = accessMockHelper.CreateMockDbContext(databaseName); + var handler = CreateTestHandler(dbContext); + var request = DefaultRequest(resultConfigId.Value); + var act = () => handler.Handle(request, default); + await act.Should().ThrowAsync(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/ResultHandlersTestBase.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/ResultHandlersTestBase.cs new file mode 100644 index 00000000..3a19f86a --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/ResultHandlersTestBase.cs @@ -0,0 +1,38 @@ +using iRLeagueDatabaseCore.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; +using Xunit; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; +public abstract class ResultHandlersTestsBase : + HandlersTestsBase + where THandler : IRequestHandler + where TRequest : class, IRequest +{ + protected long TestChampSeasonId => dbContext.ChampSeasons.First().ChampSeasonId; + + public override async Task InitializeAsync() + { + await base.InitializeAsync(); + // Create results + var @event = await dbContext.Events.FirstAsync(); + await CreateScoredEventResults(@event); + } + + protected async Task CreateScoredEventResults(EventEntity @event) + { + var season = await dbContext.Seasons + .Where(x => x.Schedules.Any(y => y.Events.Any(z => z.EventId == @event.EventId))) + .FirstAsync(); + var championships = await dbContext.Championships.ToListAsync(); + var champSeasons = championships.Select(x => accessMockHelper.CreateChampSeason(x, season)).ToList(); + dbContext.AddRange(champSeasons); + foreach (var resultConfig in champSeasons.SelectMany(x => x.ResultConfigurations)) + { + var result = accessMockHelper.CreateScoredResult(@event, resultConfig); + dbContext.Add(result); + } + + await dbContext.SaveChangesAsync(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/UploadResultHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/UploadResultHandlerTests.cs new file mode 100644 index 00000000..1bc75391 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Results/UploadResultHandlerTests.cs @@ -0,0 +1,608 @@ +using AutoFixture.Dsl; +using FluentValidation; +using iRLeagueApiCore.Client.ResultsParsing; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Server.Handlers.Results; +using iRLeagueApiCore.Services.ResultService.Excecution; +using iRLeagueApiCore.UnitTests.Extensions; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using System.Diagnostics; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Results; + +public sealed class UploadResultHandlerTests : DataAccessTestsBase +{ + private readonly IResultCalculationQueue calculationQueue; + private readonly ILogger logger; + + public UploadResultHandlerTests() : base() + { + calculationQueue = Mock.Of(); + logger = Mock.Of>(); + } + + [Fact] + public async Task CreateFakeResult_ShouldReturnDefaultResult() + { + var result = await CreateFakeResult(); + + result.session_results.Should().HaveCount(3); + result.session_results[0].simsession_name.Should().Be("RACE"); + result.session_results[0].simsession_number.Should().Be(0); + result.session_results[0].simsession_type.Should().Be((int)SimSessionType.Race); + result.session_results[0].simsession_type_name.Should().Be("Race"); + result.session_results[1].simsession_name.Should().Be("QUALIFY"); + result.session_results[1].simsession_number.Should().Be(-1); + result.session_results[1].simsession_type.Should().Be((int)SimSessionType.LoneQualifying); + result.session_results[1].simsession_type_name.Should().Be("Lone Qualifying"); + result.session_results[2].simsession_name.Should().Be("PRACTICE"); + result.session_results[2].simsession_number.Should().Be(-2); + result.session_results[2].simsession_type.Should().Be((int)SimSessionType.OpenPractice); + result.session_results[2].simsession_type_name.Should().Be("Open Practice"); + } + + [Fact] + public async Task Handle_ShouldCreateMembers_WhenMemberDoesNotExist() + { + var rowCount = 10; + var names = Enumerable.Range(0, rowCount).Select(x => + new { Firstname = fixture.Create(), Lastname = fixture.Create() }) + .ToArray(); + var newMemberRows = names.Select((x, i) => fixture.Build() + .With(x => x.cust_id, dbContext.Members.Select(x => Convert.ToInt64(x.IRacingId)).Max() + 1 + i) + .With(x => x.display_name, $"{x.Firstname} {x.Lastname}") + .Without(x => x.driver_results) + .Create()) + .ToArray(); + var result = await CreateFakeResult(practice: false, qualy: false, raceCount: 1); + result.session_results.First().results = result.session_results.First().results.Concat(newMemberRows).ToArray(); + var sut = CreateSut(); + var request = CreateRequest(TestEventId, result); + + await sut.Handle(request, default); + + foreach ((var newMemberRow, var name) in newMemberRows.Zip(names)) + { + var newMember = await dbContext.Members + .FirstOrDefaultAsync(x => x.IRacingId == newMemberRow.cust_id.ToString()); + newMember.Should().NotBeNull(); + newMember!.Firstname.Should().Be(name.Firstname); + newMember.Lastname.Should().Be(name.Lastname); + } + } + + [Fact] + public async Task Handle_ShouldCreateTeam_WhenTeamDoesNotExist() + { + var rowCount = 2; + var names = Enumerable.Range(0, rowCount).Select(x => + new { Firstname = fixture.Create(), Lastname = fixture.Create() }) + .ToArray(); + var members = await dbContext.LeagueMembers + .Where(x => x.Team == null) + .Take(rowCount) + .ToListAsync(); + var newTeam = fixture.Build() + .With(x => x.Members, members) + .Without(x => x.League) + .Without(x => x.InvolvedReviews) + .Create(); + var newTeamRow = CreateTeamResultRow(1, (newTeam.IRacingTeamId!.Value, newTeam.Name, members)); + var result = await CreateFakeResult(practice: false, qualy: false, teamResult: true, raceCount: 1); + result.session_results.First().results = result.session_results.First().results.Concat(new[] { newTeamRow }).ToArray(); + var sut = CreateSut(); + var request = CreateRequest(TestEventId, result); + + await sut.Handle(request, default); + + var testNewTeam = await dbContext.Teams + .FirstOrDefaultAsync(x => x.IRacingTeamId == newTeam.IRacingTeamId); + testNewTeam.Should().NotBeNull(); + testNewTeam!.Name.Should().Be(newTeam.Name); + testNewTeam.Members.Should().Contain(members); + } + + [Fact] + public async Task Handle_ShouldAddMemberToTeam_WhenDriverIsInNoTeam() + { + var team = await dbContext.Teams + .Include(x => x.Members) + .FirstAsync(); + var addMember = await dbContext.LeagueMembers + .Where(x => x.Team == null) + .FirstAsync(); + var rowCount = team.Members.Count(); + var members = team.Members + .ToList(); + Debug.Assert(members.Contains(addMember) == false); + members.Add(addMember); + var updateTeamRow = CreateTeamResultRow(1, (team.IRacingTeamId!.Value, team.Name, members)); + var result = await CreateFakeResult(practice: false, qualy: false, teamResult: true, raceCount: 1); + result.session_results.First().results = result.session_results.First().results + .Concat(new[] { updateTeamRow }) + .ToArray(); + var sut = CreateSut(); + var request = CreateRequest(TestEventId, result); + + await sut.Handle(request, default); + + var testUpdateTeam = await dbContext.Teams + .Include(x => x.Members) + .FirstAsync(x => x.TeamId == team.TeamId); + testUpdateTeam.Members.Should().Contain(addMember); + } + + [Fact] + public async Task Handle_ShouldMoveMemberToTeam_WhenDriverIsInAnotherTeam() + { + var team = await dbContext.Teams + .Include(x => x.Members) + .FirstAsync(); + var oldTeam = await dbContext.Teams + .Include(x => x.Members) + .Skip(1) + .FirstAsync(); + var moveMember = oldTeam.Members.First(); + var rowCount = team.Members.Count(); + var members = team.Members + .ToList(); + Debug.Assert(members.Contains(moveMember) == false); + members.Add(moveMember); + var updateTeamRow = CreateTeamResultRow(1, (team.IRacingTeamId!.Value, team.Name, members)); + var result = await CreateFakeResult(practice: false, qualy: false, teamResult: true, raceCount: 1); + result.session_results.First().results = result.session_results.First().results + .Concat(new[] { updateTeamRow }) + .ToArray(); + var sut = CreateSut(); + var request = CreateRequest(TestEventId, result); + + await sut.Handle(request, default); + + var testUpdateTeam = await dbContext.Teams + .Include(x => x.Members) + .FirstAsync(x => x.TeamId == team.TeamId); + testUpdateTeam.Members.Should().Contain(moveMember); + var testUpdateOldTeam = await dbContext.Teams + .Include(x => x.Members) + .FirstAsync(x => x.TeamId == oldTeam.TeamId); + testUpdateOldTeam.Members.Should().NotContain(moveMember); + } + + [Fact] + public async Task Handle_ShouldRemoveMemberFromTeam_WhenDriverHasNoTeamInResult() + { + var team = await dbContext.Teams + .Include(x => x.Members) + .FirstAsync(); + var removeMember = team.Members.First(); + var members = team.Members.ToList(); + members.Remove(removeMember); + var updateTeamRow = CreateTeamResultRow(1, (team.IRacingTeamId!.Value, team.Name, members)); + var result = await CreateFakeResult(practice: false, qualy: false, teamResult: true, raceCount: 1); + result.session_results.First().results = result.session_results.First().results + .Concat(new[] { updateTeamRow }) + .ToArray(); + var sut = CreateSut(); + var request = CreateRequest(TestEventId, result); + + await sut.Handle(request, default); + + var testUpdateTeam = await dbContext.Teams + .Include(x => x.Members) + .FirstAsync(x => x.TeamId == team.TeamId); + testUpdateTeam.Members.Should().NotContain(removeMember); + } + + [Fact] + public async Task Handle_ShouldAssingPracticeResults() + { + var @event = EventBuilder().Create(); + var session = SessionBuilder() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Event, @event) + .With(x => x.SessionType, SessionType.Practice) + .Create(); + @event.Sessions.Add(session); + dbContext.Events.Add(@event); + await dbContext.SaveChangesAsync(); + var result = await CreateFakeResult(); + var request = CreateRequest(@event.EventId, result); + var sut = CreateSut(); + + await sut.Handle(request, default); + + var testSession = await dbContext.Sessions + .Include(x => x.SessionResult) + .FirstAsync(x => x.SessionId == session.SessionId); + var sessionResult = testSession.SessionResult; + sessionResult.Should().NotBeNull(); + sessionResult.Session.SessionId.Should().Be(session.SessionId); + sessionResult.SimSessionType.Should().Be(SimSessionType.OpenPractice); + } + + [Fact] + public async Task Handle_ShouldAssingQualifyingResults() + { + var @event = EventBuilder().Create(); + var session = SessionBuilder() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Event, @event) + .With(x => x.SessionType, SessionType.Qualifying) + .Create(); + @event.Sessions.Add(session); + dbContext.Events.Add(@event); + await dbContext.SaveChangesAsync(); + var result = await CreateFakeResult(); + var request = CreateRequest(@event.EventId, result); + var sut = CreateSut(); + + await sut.Handle(request, default); + + var testSession = await dbContext.Sessions + .Include(x => x.SessionResult) + .FirstAsync(x => x.SessionId == session.SessionId); + var sessionResult = testSession.SessionResult; + sessionResult.Should().NotBeNull(); + sessionResult.SimSessionType.Should().Be(SimSessionType.LoneQualifying); + } + + [Fact] + public async Task Handle_ShouldAssignSingleRace() + { + var @event = EventBuilder().Create(); + var session = SessionBuilder() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Event, @event) + .With(x => x.SessionType, SessionType.Race) + .Create(); + @event.Sessions.Add(session); + dbContext.Events.Add(@event); + await dbContext.SaveChangesAsync(); + var result = await CreateFakeResult(); + var request = CreateRequest(@event.EventId, result); + var sut = CreateSut(); + + await sut.Handle(request, default); + + var testSession = await dbContext.Sessions + .Include(x => x.SessionResult) + .FirstAsync(x => x.SessionId == session.SessionId); + var sessionResult = testSession.SessionResult; + sessionResult.Should().NotBeNull(); + sessionResult.SimSessionType.Should().Be(SimSessionType.Race); + } + + [Fact] + public async Task Handle_ShouldAssignHeatRaces() + { + var sessionCount = 3; + var @event = EventBuilder().Create(); + @event.Sessions = SessionBuilder() + .With(x => x.LeagueId, @event.LeagueId) + .With(x => x.Event, @event) + .With(x => x.SessionType, SessionType.Race) + .With(x => x.Name, "Heat") + .CreateMany(sessionCount) + .ToList(); + dbContext.Events.Add(@event); + await dbContext.SaveChangesAsync(); + var result = await CreateFakeResult(raceCount: sessionCount); + var request = CreateRequest(@event.EventId, result); + var sut = CreateSut(); + + await sut.Handle(request, default); + + var raceResults = result.session_results + .Where(x => x.simsession_type == (int)SimSessionType.Race) + .Reverse(); + var testSessions = await dbContext.Sessions + .Include(x => x.SessionResult) + .ThenInclude(x => x.ResultRows) + .Where(x => x.EventId == @event.EventId) + .OrderBy(x => x.SessionNr) + .ToListAsync(); + testSessions[0].SessionResult.Should().NotBeNull(); + foreach ((var testSession, var sessionResult) in testSessions.OrderBy(x => x.SessionNr).Zip(raceResults)) + { + foreach ((var testRow, var resultRow) in testSession.SessionResult.ResultRows.OrderBy(x => x.FinishPosition).Zip(sessionResult.results)) + { + testRow.FinishPosition.Should().Be(resultRow.position+1); + testRow.Member.IRacingId.Should().Be(resultRow.cust_id.ToString()); + } + } + } + + [Fact] + public async Task Handle_ShouldFillResultRowData() + { + var @event = EventBuilder().Create(); + @event.Sessions.Add(SessionBuilder() + .With(x => x.SessionType, SessionType.Race) + .Create()); + dbContext.Events.Add(@event); + await dbContext.SaveChangesAsync(); + var result = await CreateFakeResult(practice: false, qualy: false, raceCount: 1); + var request = CreateRequest(@event.EventId, result); + var sut = CreateSut(); + + await sut.Handle(request, default); + + var sessionResult = await dbContext.SessionResults + .Include(x => x.ResultRows) + .ThenInclude(x => x.Member) + .FirstAsync(x => x.EventId == @event.EventId); + var laps = result.session_results.First().results.Select(y => y.laps_complete).Max(); + foreach ((var testRow, var resultRow) in sessionResult.ResultRows.Zip(result.session_results.First().results)) + { + testRow.AvgLapTime.Should().Be(TimeSpan.FromSeconds(resultRow.average_lap / 10000D)); + testRow.Car.Should().Be(resultRow.car_name); + testRow.CarId.Should().Be(resultRow.car_id); + testRow.CarNumber.ToString().Should().Be(resultRow.livery.car_number); + testRow.ClassId.Should().Be(resultRow.car_class_id); + testRow.ClubId.Should().Be(resultRow.club_id); + testRow.CompletedLaps.Should().Be(resultRow.laps_complete); + testRow.CompletedPct.Should().BeApproximately(resultRow.laps_complete / (double)laps, 0.001); + testRow.Division.Should().Be(resultRow.division); + testRow.FastestLapTime.Should().Be(TimeSpan.FromSeconds(resultRow.best_lap_time / 10000D)); + testRow.FastLapNr.Should().Be(resultRow.best_lap_num); + testRow.FinishPosition.Should().Be(resultRow.position+1); + testRow.Incidents.Should().Be(resultRow.incidents); + testRow.Interval.Should().Be(TimeSpan.FromSeconds(resultRow.class_interval / 10000D)); + testRow.IRacingId.Should().Be(resultRow.cust_id.ToString()); + testRow.LeadLaps.Should().Be(resultRow.laps_lead); + testRow.Member.IRacingId.Should().Be(resultRow.cust_id.ToString()); + testRow.NewCpi.Should().Be((int)resultRow.new_cpi); + testRow.NewIRating.Should().Be(resultRow.newi_rating); + testRow.NewLicenseLevel.Should().Be(resultRow.new_license_level); + testRow.NewSafetyRating.Should().Be(resultRow.new_sub_level); + testRow.OldCpi.Should().Be((int)resultRow.old_cpi); + testRow.OldIRating.Should().Be(resultRow.oldi_rating); + testRow.OldLicenseLevel.Should().Be(resultRow.old_license_level); + testRow.OldSafetyRating.Should().Be(resultRow.old_sub_level); + testRow.PointsEligible.Should().Be(true); + testRow.PositionChange.Should().Be(resultRow.position - resultRow.starting_position); + testRow.QualifyingTime.Should().Be(TimeSpan.FromSeconds(resultRow.best_qual_lap_time / 10000D)); + testRow.QualifyingTimeAt.Should().Be(resultRow.best_qual_lap_at); + testRow.StartPosition.Should().Be(resultRow.starting_position + 1); + testRow.Status.Should().Be(resultRow.reason_out_id); + } + } + + [Fact] + public async Task Handle_ShouldGetIntervalLaps_WhenIntervalIsNegative() + { + var @event = EventBuilder().Create(); + @event.Sessions.Add(SessionBuilder() + .With(x => x.SessionType, SessionType.Race) + .Create()); + dbContext.Events.Add(@event); + await dbContext.SaveChangesAsync(); + var result = await CreateFakeResult(practice: false, qualy: false, raceCount: 1); + var maxLaps = result.session_results[0].results.Max(x => x.laps_complete); + result.session_results[0].results.First().laps_complete = maxLaps; + var lapsDown = 3; + var setupRow = result.session_results[0].results.Last(); + setupRow.class_interval = -1; + setupRow.laps_complete = maxLaps - lapsDown; + var request = CreateRequest(@event.EventId, result); + var sut = CreateSut(); + + await sut.Handle(request, default); + + var session = await dbContext.SessionResults + .Include(x => x.ResultRows) + .ThenInclude(x => x.Member) + .FirstAsync(x => x.EventId == @event.EventId); + var testRow = session.ResultRows.Last(); + testRow.Interval.Should().Be(TimeSpan.FromDays(lapsDown)); + } + + [Fact] + public async Task Handle_ShouldFillResultRowData_FromTeamResults() + { + var @event = EventBuilder().Create(); + @event.Sessions.Add(SessionBuilder() + .With(x => x.SessionType, SessionType.Race) + .Create()); + dbContext.Events.Add(@event); + await dbContext.SaveChangesAsync(); + var result = await CreateFakeResult(practice: false, qualy: false, teamResult: true, raceCount: 1); + var request = CreateRequest(@event.EventId, result); + var sut = CreateSut(); + + await sut.Handle(request, default); + + var sessionResult = await dbContext.SessionResults + .Include(x => x.ResultRows) + .ThenInclude(x => x.Member) + .FirstAsync(x => x.EventId == @event.EventId); + var laps = result.session_results.First().results.Select(y => y.laps_complete).Max(); + foreach ((var testRow, var resultRow) in sessionResult.ResultRows.Zip(result.session_results.First().results.SelectMany(x => x.driver_results))) + { + testRow.AvgLapTime.Should().Be(TimeSpan.FromSeconds(resultRow.average_lap / 10000D)); + testRow.Car.Should().Be(resultRow.car_name); + testRow.CarId.Should().Be(resultRow.car_id); + testRow.CarNumber.ToString().Should().Be(resultRow.livery.car_number); + testRow.ClassId.Should().Be(resultRow.car_class_id); + testRow.ClubId.Should().Be(resultRow.club_id); + testRow.CompletedLaps.Should().Be(resultRow.laps_complete); + testRow.CompletedPct.Should().BeApproximately(resultRow.laps_complete / (double)laps, 0.001); + testRow.Division.Should().Be(resultRow.division); + testRow.FastestLapTime.Should().Be(TimeSpan.FromSeconds(resultRow.best_lap_time / 10000D)); + testRow.FastLapNr.Should().Be(resultRow.best_lap_num); + testRow.FinishPosition.Should().Be(resultRow.position + 1); + testRow.Incidents.Should().Be(resultRow.incidents); + testRow.Interval.Should().Be(TimeSpan.FromSeconds(resultRow.class_interval / 10000D)); + testRow.IRacingId.Should().Be(resultRow.cust_id.ToString()); + testRow.LeadLaps.Should().Be(resultRow.laps_lead); + testRow.Member.IRacingId.Should().Be(resultRow.cust_id.ToString()); + testRow.NewCpi.Should().Be((int)resultRow.new_cpi); + testRow.NewIRating.Should().Be(resultRow.newi_rating); + testRow.NewLicenseLevel.Should().Be(resultRow.new_license_level); + testRow.NewSafetyRating.Should().Be(resultRow.new_sub_level); + testRow.OldCpi.Should().Be((int)resultRow.old_cpi); + testRow.OldIRating.Should().Be(resultRow.oldi_rating); + testRow.OldLicenseLevel.Should().Be(resultRow.old_license_level); + testRow.OldSafetyRating.Should().Be(resultRow.old_sub_level); + testRow.PointsEligible.Should().Be(true); + testRow.PositionChange.Should().Be(resultRow.position - resultRow.starting_position); + testRow.QualifyingTime.Should().Be(TimeSpan.FromSeconds(resultRow.best_qual_lap_time / 10000D)); + testRow.QualifyingTimeAt.Should().Be(resultRow.best_qual_lap_at); + testRow.StartPosition.Should().Be(resultRow.starting_position + 1); + testRow.Status.Should().Be(resultRow.reason_out_id); + } + } + + private IPostprocessComposer EventBuilder() + { + return fixture.Build() + .With(x => x.Schedule, dbContext.Schedules.First()) + .With(x => x.EventId, () => dbContext.Events.Select(x => x.EventId).Max() + 1) + .Without(x => x.LeagueId) + .Without(x => x.EventResult) + .Without(x => x.ResultConfigs) + .Without(x => x.ScoredEventResults) + .Without(x => x.Sessions) + .Without(x => x.Track) + .Without(x => x.SimSessionDetails); + } + + private IPostprocessComposer SessionBuilder() + { + return fixture.Build() + .With(x => x.SessionId, () => dbContext.Sessions.Select(x => x.SessionId).Max() + fixture.Create()) + .Without(x => x.Event) + .Without(x => x.IncidentReviews) + .Without(x => x.SessionResult); + } + + private UploadResultHandler CreateSut() + { + return new UploadResultHandler(logger, dbContext, Array.Empty>(), calculationQueue); + } + + private UploadResultRequest CreateRequest(long eventId, ParseSimSessionResult data) + { + return new UploadResultRequest(eventId, data); + } + + private async Task CreateFakeResult( + bool practice = true, + bool qualy = true, + bool teamResult = false, + int raceCount = 1) + { + var memberCount = 10; + var members = await dbContext.LeagueMembers + .Include(x => x.Member) + .Take(memberCount) + .ToListAsync(); + var result = fixture.Build() + .Without(x => x.session_results) + .Create(); + var sessionResults = new List(); + var sessionNr = (practice ? -1 : 0) + (qualy ? -1 : 0) - raceCount * 2 + 1; + if (practice) + { + sessionResults.Add(SessionResultBuilder(members, teamResult) + .With(x => x.simsession_number, ++sessionNr) + .With(x => x.simsession_type, (int)SimSessionType.OpenPractice) + .With(x => x.simsession_type_name, "Open Practice") + .With(x => x.simsession_name, "PRACTICE") + .Create()); + } + if (qualy) + { + sessionResults.Add(SessionResultBuilder(members, teamResult) + .With(x => x.simsession_number, ++sessionNr) + .With(x => x.simsession_type, (int)SimSessionType.LoneQualifying) + .With(x => x.simsession_type_name, "Lone Qualifying") + .With(x => x.simsession_name, "QUALIFY") + .Create()); + + } + var heatNr = 1; + for (int i = 0; i < raceCount; i++) + { + sessionResults.Add(SessionResultBuilder(members, teamResult) + .With(x => x.simsession_number, ++sessionNr) + .With(x => x.simsession_type, (int)SimSessionType.Race) + .With(x => x.simsession_type_name, "Race") + .With(x => x.simsession_name, raceCount == 1 ? "RACE" : sessionNr == 0 ? "FEATURE" : $"HEAT {heatNr++}") + .Create()); + if (sessionNr != 0) + { + sessionResults.Add(SessionResultBuilder(members, teamResult) + .With(x => x.simsession_number, ++sessionNr) + .With(x => x.simsession_type, (int)SimSessionType.OpenPractice) + .With(x => x.simsession_type_name, "Open Practice") + .With(x => x.simsession_name, "WARMUP") + .Create()); + } + } + sessionResults.Reverse(); + result.session_results = sessionResults.ToArray(); + return result; + } + + private IPostprocessComposer SessionResultBuilder(IEnumerable members, bool teamResult = false) + { + if (teamResult) + { + var teams = members.Chunk(3) + .Select(x => (fixture.Create(), fixture.Create(), x.AsEnumerable())); + return SessionTeamResultBuilder(teams); + } + + return fixture.Build() + .With(x => x.results, members.Shuffle() + .Select((member, i) => CreateResultRow(i + 1, member)) + .ToArray()); + } + + private IPostprocessComposer SessionTeamResultBuilder(IEnumerable<(long teamId, string teamName, IEnumerable members)> teams) + { + return fixture.Build() + .With(x => x.results, teams.Shuffle() + .Select((team, i) => CreateTeamResultRow(i + 1, team)) + .ToArray()); + } + + private ParseSessionResultRow CreateResultRow(int pos, LeagueMemberEntity leagueMember, long? teamId = null) + { + return fixture.Build() + .With(x => x.team_id, teamId) + .With(x => x.position, pos) + .With(x => x.cust_id, Convert.ToInt64(leagueMember.Member.IRacingId)) + .With(x => x.display_name, GetMemberFullName(leagueMember.Member)) + .With(x => x.livery, fixture.Build() + .With(x => x.car_number, fixture.Create().ToString()) + .Create()) + .Without(x => x.driver_results) + .Create(); + } + + private ParseSessionResultRow CreateTeamResultRow(int pos, (long teamId, string name, IEnumerable members) team) + { + return fixture.Build() + .With(x => x.position, pos) + .With(x => x.team_id, team.teamId) + .With(x => x.display_name, team.name) + .With(x => x.livery, fixture.Build() + .With(x => x.car_number, fixture.Create().ToString()) + .Create()) + .With(x => x.driver_results, team.members + .Select(x => CreateResultRow(pos, x, teamId: team.teamId)) + .ToArray()) + .Create(); + } + + private string GetMemberFullName(MemberEntity member) + { + return $"{member.Firstname} {member.Firstname}"; + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/DeleteReviewCommentHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/DeleteReviewCommentHandlerTests.cs new file mode 100644 index 00000000..267478df --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/DeleteReviewCommentHandlerTests.cs @@ -0,0 +1,74 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using MediatR; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; + +public sealed class DeleteReviewCommentHandlerTests : ReviewsHandlersTestsBase +{ + public DeleteReviewCommentHandlerTests() : base() + { + } + + protected override DeleteReviewCommentHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new DeleteReviewCommentHandler(logger, dbContext, new[] { validator }); + } + + private DeleteReviewCommentRequest DefaultRequest(long commentId) + { + + return new DeleteReviewCommentRequest(commentId); + } + + protected override DeleteReviewCommentRequest DefaultRequest() + { + return DefaultRequest(TestCommentId); + } + + protected override void DefaultPreTestAssertions(DeleteReviewCommentRequest request, LeagueDbContext dbContext) + { + dbContext.ReviewComments.Should().Contain(x => x.CommentId == request.CommentId); + base.DefaultPreTestAssertions(request, dbContext); + } + + protected override void DefaultAssertions(DeleteReviewCommentRequest request, Unit result, LeagueDbContext dbContext) + { + dbContext.ReviewComments.Should().NotContain(x => x.CommentId == request.CommentId); + base.DefaultAssertions(request, result, dbContext); + } + + private void AssertMemberInfo(MemberInfoModel expected, MemberInfoModel result) + { + result.MemberId.Should().Be(expected.MemberId); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? commentId) + { + leagueId ??= TestLeagueId; + commentId ??= TestCommentId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(commentId.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/DeleteReviewHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/DeleteReviewHandlerTests.cs new file mode 100644 index 00000000..7f9aeb73 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/DeleteReviewHandlerTests.cs @@ -0,0 +1,65 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using MediatR; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; + +public sealed class DeleteReviewHandlerTests : ReviewsHandlersTestsBase +{ + public DeleteReviewHandlerTests() : base() + { + } + + protected override DeleteReviewHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new DeleteReviewHandler(logger, dbContext, new[] { validator }); + } + + private DeleteReviewRequest DefaultRequest(long reviewId) + { + + return new DeleteReviewRequest(reviewId); + } + + protected override DeleteReviewRequest DefaultRequest() + { + return DefaultRequest(TestReviewId); + } + + protected override void DefaultAssertions(DeleteReviewRequest request, Unit result, LeagueDbContext dbContext) + { + var deletedReview = dbContext.IncidentReviews + .SingleOrDefault(x => x.ReviewId == request.ReviewId); + deletedReview.Should().BeNull(); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? reviewId) + { + leagueId ??= TestLeagueId; + reviewId ??= TestReviewId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(reviewId.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/GetPenaltiesFromSessionResultHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/GetPenaltiesFromSessionResultHandlerTests.cs new file mode 100644 index 00000000..75791b24 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/GetPenaltiesFromSessionResultHandlerTests.cs @@ -0,0 +1,92 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; +public sealed class GetPenaltiesFromSessionResultHandlerTests : ReviewsHandlersTestsBase> +{ + protected override GetPenaltiesFromSessionResultHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + protected override GetPenaltiesFromSessionResultRequest DefaultRequest() + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(PenaltyType.Points, 42, 0, 0)] + [InlineData(PenaltyType.Position, 0, 42, 0)] + [InlineData(PenaltyType.Time, 0, 0, 42)] + public async Task ShouldReturnPenaltyData(PenaltyType type, int points, int positions, int seconds) + { + var result = await dbContext.ScoredSessionResults + .Include(x => x.ScoredResultRows) + .FirstAsync(); + var vote = await dbContext.AcceptedReviewVotes + .Include(x => x.Review) + .FirstAsync(); + var reviewPenalty = new ReviewPenaltyEntity() + { + LeagueId = vote.LeagueId, + ResultRow = result.ScoredResultRows.First(), + Review = vote.Review, + ReviewVote = vote, + Value = new() + { + Type = type, + Points = points, + Positions = positions, + Time = TimeSpan.FromSeconds(seconds) + }, + }; + var addPenalty = new AddPenaltyEntity() + { + LeagueId = result.LeagueId, + ScoredResultRow = result.ScoredResultRows.First(), + Reason = "Test Result", + Value = new() + { + Type = type, + Points = points, + Positions = positions, + Time = TimeSpan.FromSeconds(seconds) + }, + }; + dbContext.ReviewPenaltys.Add(reviewPenalty); + dbContext.AddPenaltys.Add(addPenalty); + await dbContext.SaveChangesAsync(); + var request = new GetPenaltiesFromSessionResultRequest(result.SessionResultId); + var sut = CreateSut(); + + var test = await sut.Handle(request, default); + + test.Should().Satisfy( + x => + x.ResultRowId == reviewPenalty.ResultRowId && + x.ReviewId == reviewPenalty.ReviewId && + x.ReviewVoteId == reviewPenalty.ReviewVoteId && + x.Type == type && + x.Points == points && + x.Positions == positions && + x.Time == TimeSpan.FromSeconds(seconds), + x => + x.AddPenaltyId == addPenalty.AddPenaltyId && + x.Reason == addPenalty.Reason && + x.Type == type && + x.Points == points && + x.Positions == positions && + x.Time == TimeSpan.FromSeconds(seconds) + ); + } + + private GetPenaltiesFromSessionResultHandler CreateSut() + { + return CreateTestHandler(dbContext, MockHelpers.TestValidator()); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/GetReviewCommentHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/GetReviewCommentHandlerTests.cs new file mode 100644 index 00000000..103fb1f4 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/GetReviewCommentHandlerTests.cs @@ -0,0 +1,96 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; + +public sealed class GetReviewCommentHandlerTests : ReviewsHandlersTestsBase +{ + protected override GetReviewCommentHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetReviewCommentHandler(logger, dbContext, new[] { validator }); + } + + private GetReviewCommentRequest DefaultRequest(long commentId) + { + + return new GetReviewCommentRequest(commentId); + } + + protected override GetReviewCommentRequest DefaultRequest() + { + return DefaultRequest(TestCommentId); + } + + protected override void DefaultAssertions(GetReviewCommentRequest request, ReviewCommentModel result, LeagueDbContext dbContext) + { + var commentEntity = dbContext.ReviewComments + .Include(x => x.ReviewCommentVotes) + .ThenInclude(x => x.MemberAtFault) + .SingleOrDefault(x => x.CommentId == request.CommentId); + commentEntity.Should().NotBeNull(); + AssertReviewComment(commentEntity!, result); + base.DefaultAssertions(request, result, dbContext); + } + + private void AssertReviewComment(ReviewCommentEntity expected, ReviewCommentModel result) + { + result.LeagueId.Should().Be(expected.LeagueId); + result.CommentId.Should().Be(expected.CommentId); + result.AuthorName.Should().Be(expected.AuthorName); + result.AuthorUserId.Should().Be(expected.AuthorUserId); + result.ReviewId.Should().Be(expected.ReviewId); + result.Text.Should().Be(expected.Text); + result.Votes.Should().HaveSameCount(expected.ReviewCommentVotes); + foreach ((var vote, var expectedVote) in result.Votes.Zip(expected.ReviewCommentVotes)) + { + AssertCommentVote(expectedVote, vote); + } + AssertVersion(expected, result); + } + + private void AssertCommentVote(ReviewCommentVoteEntity expected, VoteModel result) + { + result.Id.Should().Be(expected.ReviewVoteId); + result.Description.Should().Be(expected.Description); + AssertMemberInfo(expected.MemberAtFault, result.MemberAtFault); + } + + private void AssertMemberInfo(MemberEntity? expected, MemberInfoModel? result) + { + + result?.MemberId.Should().Be(expected?.Id); + result?.FirstName.Should().Be(expected?.Firstname); + result?.LastName.Should().Be(expected?.Lastname); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? commentId) + { + leagueId ??= TestLeagueId; + commentId ??= TestCommentId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(commentId.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/GetReviewHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/GetReviewHandlerTests.cs new file mode 100644 index 00000000..3f536a81 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/GetReviewHandlerTests.cs @@ -0,0 +1,117 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; + +public sealed class GetReviewHandlerTests : ReviewsHandlersTestsBase +{ + protected override GetReviewHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetReviewHandler(logger, dbContext, new[] { validator }); + } + + private GetReviewRequest DefaultRequest(long reviewId, bool includeComments = true) + { + return new GetReviewRequest(reviewId, includeComments); + } + + protected override GetReviewRequest DefaultRequest() + { + return DefaultRequest(TestReviewId); + } + + protected override void DefaultAssertions(GetReviewRequest request, ReviewModel result, LeagueDbContext dbContext) + { + result.ReviewId.Should().Be(request.ReviewId); + var reviewEntity = dbContext.IncidentReviews + .Include(x => x.Session) + .ThenInclude(x => x.Event) + .ThenInclude(x => x.Schedule) + .Include(x => x.Comments) + .ThenInclude(x => x.ReviewCommentVotes) + .ThenInclude(x => x.MemberAtFault) + .SingleOrDefault(x => x.ReviewId == request.ReviewId); + reviewEntity.Should().NotBeNull(); + result.SeasonId.Should().Be(reviewEntity!.Session.Event.Schedule.SeasonId); + result.ReviewComments.Should().HaveSameCount(reviewEntity.Comments); + foreach ((var comment, var expected) in result.ReviewComments.Zip(reviewEntity.Comments)) + { + AssertReviewComment(expected, comment); + } + AssertVersion(reviewEntity, result); + base.DefaultAssertions(request, result, dbContext); + } + + private void AssertReviewComment(ReviewCommentEntity expected, ReviewCommentModel result) + { + result.LeagueId.Should().Be(expected.LeagueId); + result.CommentId.Should().Be(expected.CommentId); + result.AuthorName.Should().Be(expected.AuthorName); + result.AuthorUserId.Should().Be(expected.AuthorUserId); + result.ReviewId.Should().Be(expected.ReviewId); + result.Text.Should().Be(expected.Text); + result.Votes.Should().HaveSameCount(expected.ReviewCommentVotes); + foreach ((var vote, var expectedVote) in result.Votes.Zip(expected.ReviewCommentVotes)) + { + AssertCommentVote(expectedVote, vote); + } + AssertVersion(expected, result); + } + + private void AssertCommentVote(ReviewCommentVoteEntity expected, VoteModel result) + { + result.Id.Should().Be(expected.ReviewVoteId); + result.Description.Should().Be(expected.Description); + AssertMemberInfo(expected.MemberAtFault, result.MemberAtFault!); + } + + private void AssertMemberInfo(MemberEntity? expected, MemberInfoModel? result) + { + result?.MemberId.Should().Be(expected?.Id); + result?.FirstName.Should().Be(expected?.Firstname); + result?.LastName.Should().Be(expected?.Lastname); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? reviewId) + { + leagueId ??= TestLeagueId; + reviewId ??= TestReviewId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(reviewId.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Fact] + public async Task ShouldNotIncludeCommentsWhenFalse() + { + var request = DefaultRequest(TestReviewId, false); + await HandleSpecialAsync(request, (request, model, context) => + { + model.ReviewId.Should().Be(TestReviewId); + model.VoteResults.Should().NotBeEmpty(); + model.ReviewComments.Should().BeEmpty(); + }); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PostPenaltyToResultHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PostPenaltyToResultHandlerTests.cs new file mode 100644 index 00000000..925b904d --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PostPenaltyToResultHandlerTests.cs @@ -0,0 +1,56 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Enums; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; +public sealed class PostPenaltyToResultHandlerTests : ReviewsHandlersTestsBase +{ + protected override PostPenaltyToResultHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new(logger, dbContext, new[] { validator }); + } + + protected override PostPenaltyToResultRequest DefaultRequest() + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(PenaltyType.Position, 42, 0, 0)] + [InlineData(PenaltyType.Points, 0, 42, 0)] + [InlineData(PenaltyType.Time, 0, 0, 42)] + public async Task ShouldAddNewPenalty(PenaltyType type, int positions, int points, int seconds) + { + var result = await dbContext.ScoredSessionResults + .Include(x => x.ScoredResultRows) + .ThenInclude(x => x.Member) + .FirstAsync(); + var row = result.ScoredResultRows.First(); + var request = new PostPenaltyToResultRequest(result.SessionResultId, row.ScoredResultRowId, new() + { + Reason = "Test Penalty", + Type = type, + Points = points, + Positions = positions, + Time = TimeSpan.FromSeconds(seconds), + }); + var sut = CreateSut(); + + var test = await sut.Handle(request, default); + + test.Reason.Should().Be(request.Model.Reason); + test.Type.Should().Be(type); + test.Points.Should().Be(points); + test.Positions.Should().Be(positions); + test.Time.Should().Be(TimeSpan.FromSeconds(seconds)); + } + + private PostPenaltyToResultHandler CreateSut() + { + return CreateTestHandler(dbContext, MockHelpers.TestValidator()); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PostReviewCommentToReviewHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PostReviewCommentToReviewHandlerTests.cs new file mode 100644 index 00000000..894256ac --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PostReviewCommentToReviewHandlerTests.cs @@ -0,0 +1,89 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; + +public sealed class PostReviewCommentToReviewHandlerTests : ReviewsHandlersTestsBase +{ + private PutReviewCommentModel TestReviewComment => new PutReviewCommentModel() + { + Text = "Test Comment", + Votes = new[] { new VoteModel() + { + Description = "Test Vote", + MemberAtFault = new MemberInfoModel() { MemberId = TestMemberId}, + } }, + }; + + protected override PostReviewCommentToReviewHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PostReviewCommentToReviewHandler(logger, dbContext, new[] { validator }); + } + + private PostReviewCommentToReviewRequest DefaultRequest(long reviewId) + { + + return new PostReviewCommentToReviewRequest(reviewId, DefaultUser(), TestReviewComment); + } + + protected override PostReviewCommentToReviewRequest DefaultRequest() + { + return DefaultRequest(TestReviewId); + } + + protected override void DefaultAssertions(PostReviewCommentToReviewRequest request, ReviewCommentModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.LeagueId.Should().Be(result.LeagueId); + result.ReviewId.Should().NotBe(0); + result.Text.Should().Be(expected.Text); + result.Votes.Should().HaveSameCount(expected.Votes); + foreach ((var vote, var expectedVote) in result.Votes.Zip(expected.Votes)) + { + AssertCommentVote(expectedVote, vote); + } + AssertCreated(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + private void AssertCommentVote(VoteModel expected, VoteModel result) + { + result.Description.Should().Be(expected.Description); + AssertMemberInfo(expected.MemberAtFault, result.MemberAtFault); + } + + private void AssertMemberInfo(MemberInfoModel? expected, MemberInfoModel? result) + { + result?.MemberId.Should().Be(expected?.MemberId); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? reviewId) + { + leagueId ??= TestLeagueId; + reviewId ??= TestReviewId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(reviewId.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PostReviewToSessionHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PostReviewToSessionHandlerTests.cs new file mode 100644 index 00000000..55bf6cd7 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PostReviewToSessionHandlerTests.cs @@ -0,0 +1,100 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; + +public sealed class PostReviewToSessionHandlerTests : ReviewsHandlersTestsBase +{ + public PostReviewModel TestReviewModel => new PostReviewModel() + { + FullDescription = "Full Description", + Corner = "1", + OnLap = "2", + IncidentNr = "3.4", + IncidentKind = "Unfall", + TimeStamp = System.TimeSpan.FromMinutes(1.2), + InvolvedMembers = new MemberInfoModel[] + { + new MemberInfoModel() { MemberId = TestMemberId}, + new MemberInfoModel() { MemberId = dbContext.Members.Skip(1).First().Id}, + }, + VoteResults = new VoteModel[0], + }; + + protected override PostReviewToSessionHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PostReviewToSessionHandler(logger, dbContext, new[] { validator }); + } + + private PostReviewToSessionRequest DefaultRequest(long sessionId) + { + return new PostReviewToSessionRequest(sessionId, DefaultUser(), TestReviewModel); + } + + protected override PostReviewToSessionRequest DefaultRequest() + { + return DefaultRequest(TestSessionId); + } + + protected override void DefaultAssertions(PostReviewToSessionRequest request, ReviewModel result, LeagueDbContext dbContext) + { + var expected = TestReviewModel; + result.SessionId.Should().Be(request.SessionId); + result.ReviewId.Should().NotBe(0); + result.Corner.Should().Be(expected.Corner); + result.OnLap.Should().Be(expected.OnLap); + result.IncidentKind.Should().Be(expected.IncidentKind); + result.IncidentNr.Should().Be(expected.IncidentNr); + result.TimeStamp.Should().Be(expected.TimeStamp); + result.InvolvedMembers.Should().HaveSameCount(expected.InvolvedMembers); + var reviewEntity = dbContext.IncidentReviews + .SingleOrDefault(x => x.ReviewId == result.ReviewId); + reviewEntity.Should().NotBeNull(); + foreach ((var member, var expectedMember) in result.InvolvedMembers + .OrderBy(x => x.MemberId) + .Zip(reviewEntity!.InvolvedMembers + .OrderBy(x => x.Id))) + { + AssertMemberInfo(expectedMember, member); + } + AssertCreated(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + private void AssertMemberInfo(MemberEntity expected, MemberInfoModel result) + { + result.MemberId.Should().Be(expected.Id); + result.FirstName.Should().Be(expected.Firstname); + result.LastName.Should().Be(expected.Lastname); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? sessionId) + { + leagueId ??= TestLeagueId; + sessionId ??= TestSessionId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(sessionId.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PutReviewCommentHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PutReviewCommentHandlerTests.cs new file mode 100644 index 00000000..908f0ef8 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PutReviewCommentHandlerTests.cs @@ -0,0 +1,88 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; + +public sealed class PutReviewCommentHandlerTests : ReviewsHandlersTestsBase +{ + private PutReviewCommentModel TestReviewComment => new PutReviewCommentModel() + { + Text = "Test Comment", + Votes = new[] { new VoteModel() + { + Description = "Test Vote", + MemberAtFault = new MemberInfoModel() { MemberId = TestMemberId}, + } }, + }; + + protected override PutReviewCommentHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PutReviewCommentHandler(logger, dbContext, new[] { validator }); + } + + private PutReviewCommentRequest DefaultRequest(long commentId) + { + + return new PutReviewCommentRequest(commentId, DefaultUser(), TestReviewComment); + } + + protected override PutReviewCommentRequest DefaultRequest() + { + return DefaultRequest(TestCommentId); + } + + protected override void DefaultAssertions(PutReviewCommentRequest request, ReviewCommentModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.CommentId.Should().Be(request.CommentId); + result.Text.Should().Be(expected.Text); + result.Votes.Should().HaveSameCount(expected.Votes); + foreach ((var vote, var expectedVote) in result.Votes.Zip(expected.Votes)) + { + AssertCommentVote(expectedVote, vote); + } + AssertChanged(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + private void AssertCommentVote(VoteModel expected, VoteModel result) + { + result.Description.Should().Be(expected.Description); + AssertMemberInfo(expected.MemberAtFault, result.MemberAtFault); + } + + private void AssertMemberInfo(MemberInfoModel? expected, MemberInfoModel? result) + { + result?.MemberId.Should().Be(expected?.MemberId); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? reviewId) + { + leagueId ??= TestLeagueId; + reviewId ??= TestReviewId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(reviewId.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PutReviewHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PutReviewHandlerTests.cs new file mode 100644 index 00000000..eb6c377c --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/PutReviewHandlerTests.cs @@ -0,0 +1,116 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Common.Models.Reviews; +using iRLeagueApiCore.Server.Handlers.Reviews; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; + +public sealed class PutReviewHandlerTests : ReviewsHandlersTestsBase +{ + public PutReviewModel TestReviewModel => new PutReviewModel() + { + FullDescription = "Full Description", + Corner = "1", + OnLap = "2", + IncidentNr = "3.4", + IncidentKind = "Unfall", + TimeStamp = System.TimeSpan.FromMinutes(1.2), + InvolvedMembers = new MemberInfoModel[] + { + new MemberInfoModel() { MemberId = TestMemberId }, + new MemberInfoModel() { MemberId = TestMemberId2 }, + }, + VoteResults = new[] + { + new VoteModel() { + Id = TestReviewVoteId, + VoteCategoryId = TestVoteCategory, + Description = "Vote Description", + MemberAtFault = new MemberInfoModel() { MemberId = TestMemberId } + }, + }, + }; + + protected override PutReviewHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PutReviewHandler(logger, dbContext, new[] { validator }); + } + + private PutReviewRequest DefaultRequest(long reviewId) + { + + return new PutReviewRequest(reviewId, DefaultUser(), TestReviewModel); + } + + protected override PutReviewRequest DefaultRequest() + { + return DefaultRequest(TestReviewId); + } + + protected override void DefaultAssertions(PutReviewRequest request, ReviewModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.ReviewId.Should().Be(request.ReviewId); + result.Corner.Should().Be(expected.Corner); + result.OnLap.Should().Be(expected.OnLap); + result.IncidentKind.Should().Be(expected.IncidentKind); + result.IncidentNr.Should().Be(expected.IncidentNr); + result.TimeStamp.Should().Be(expected.TimeStamp); + result.InvolvedMembers.Should().HaveSameCount(expected.InvolvedMembers); + foreach ((var member, var expectedMember) in result.InvolvedMembers.OrderBy(x => x.MemberId).Zip(expected.InvolvedMembers.OrderBy(x => x.MemberId))) + { + AssertMemberInfo(expectedMember, member); + } + result.VoteResults.Should().HaveSameCount(expected.VoteResults); + foreach ((var vote, var expectedVote) in result.VoteResults.Zip(expected.VoteResults)) + { + AssertVote(expectedVote, vote); + } + AssertChanged(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + private void AssertMemberInfo(MemberInfoModel? expected, MemberInfoModel? result) + { + result?.MemberId.Should().Be(expected?.MemberId); + } + + private void AssertVote(VoteModel expected, VoteModel result) + { + if (expected.Id != default) + { + result.Id.Should().Be(expected.Id); + } + AssertMemberInfo(result.MemberAtFault, expected.MemberAtFault); + result.Description.Should().Be(expected.Description); + result.VoteCategoryId.Should().Be(expected.VoteCategoryId); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task ShouldHandleNotFoundAsync(long? leagueId, long? reviewId) + { + leagueId ??= TestLeagueId; + reviewId ??= TestReviewId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(reviewId.Value); + await HandleNotFoundRequestAsync(request); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/ReviewsHandlersTestsBase.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/ReviewsHandlersTestsBase.cs new file mode 100644 index 00000000..ee8b361c --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Reviews/ReviewsHandlersTestsBase.cs @@ -0,0 +1,47 @@ +using iRLeagueDatabaseCore.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Reviews; +public abstract class ReviewsHandlersTestsBase : + HandlersTestsBase + where THandler : IRequestHandler + where TRequest : class, IRequest +{ + public override async Task InitializeAsync() + { + await base.InitializeAsync(); + var @event = dbContext.Events.First(); + await CreateScoredEventResults(@event); + var reviews = accessMockHelper.CreateReviews(@event); + dbContext.IncidentReviews.RemoveRange(dbContext.IncidentReviews); + dbContext.IncidentReviews.AddRange(reviews); + foreach(var review in reviews) + { + review.Comments = accessMockHelper.CreateComments(review).ToList(); + dbContext.ReviewComments.AddRange(review.Comments); + review.AcceptedReviewVotes = accessMockHelper.AcceptedReviewVoteBuilder() + .CreateMany() + .ToList(); + dbContext.AcceptedReviewVotes.AddRange(review.AcceptedReviewVotes); + } + await dbContext.SaveChangesAsync(); + } + + protected async Task CreateScoredEventResults(EventEntity @event) + { + var season = await dbContext.Seasons + .Where(x => x.Schedules.Any(y => y.Events.Any(z => z.EventId == @event.EventId))) + .FirstAsync(); + var championships = await dbContext.Championships.ToListAsync(); + var champSeasons = championships.Select(x => accessMockHelper.CreateChampSeason(x, season)).ToList(); + dbContext.AddRange(champSeasons); + foreach (var resultConfig in champSeasons.SelectMany(x => x.ResultConfigurations)) + { + var result = accessMockHelper.CreateScoredResult(@event, resultConfig); + dbContext.Add(result); + } + + await dbContext.SaveChangesAsync(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/DeleteScheduleHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/DeleteScheduleHandlerTests.cs new file mode 100644 index 00000000..a7492a2c --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/DeleteScheduleHandlerTests.cs @@ -0,0 +1,67 @@ +using FluentValidation; +using iRLeagueApiCore.Server.Handlers.Schedules; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using MediatR; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Schedules; + +public sealed class DeleteScheduleDbTestFixture : HandlersTestsBase +{ + public DeleteScheduleDbTestFixture() : base() + { + } + + protected override DeleteScheduleHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new DeleteScheduleHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override DeleteScheduleRequest DefaultRequest() + { + return DefaultRequest(TestScheduleId); + } + + private DeleteScheduleRequest DefaultRequest(long scheduleId) + { + return new DeleteScheduleRequest(scheduleId); + } + + protected override void DefaultPreTestAssertions(DeleteScheduleRequest request, LeagueDbContext dbContext) + { + // assert schedule exists in dbContext + Assert.Contains(dbContext.Schedules, x => x.ScheduleId == request.ScheduleId); + } + + protected override void DefaultAssertions(DeleteScheduleRequest request, Unit result, LeagueDbContext dbContext) + { + // assert schedule was deleted + Assert.DoesNotContain(dbContext.Schedules, x => x.ScheduleId == request.ScheduleId); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task HandleNotFoundAsync(long? leagueId, long? scheduleId) + { + leagueId ??= TestLeagueId; + scheduleId ??= TestScheduleId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(scheduleId.Value); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/GetScheduleHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/GetScheduleHandlerTests.cs new file mode 100644 index 00000000..296d400d --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/GetScheduleHandlerTests.cs @@ -0,0 +1,70 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Schedules; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Schedules; + +public sealed class GetScheduleDbTestFixture : HandlersTestsBase +{ + public GetScheduleDbTestFixture() : base() + { + } + + protected override GetScheduleHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetScheduleHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override GetScheduleRequest DefaultRequest() + { + return DefaultRequest(TestScheduleId); + } + + private GetScheduleRequest DefaultRequest(long scheduleId) + { + return new GetScheduleRequest(scheduleId); + } + + protected override void DefaultAssertions(GetScheduleRequest request, ScheduleModel result, LeagueDbContext dbContext) + { + result.ScheduleId.Should().Be(request.ScheduleId); + var scheduleEntity = dbContext.Schedules + .Include(x => x.Events) + .SingleOrDefault(x => x.ScheduleId == result.ScheduleId); + scheduleEntity.Should().NotBeNull(); + result.Name.Should().Be(scheduleEntity!.Name); + result.EventIds.Should().BeEquivalentTo(scheduleEntity.Events.Select(x => x.EventId)); + result.SeasonId.Should().Be(scheduleEntity.SeasonId); + AssertVersion(scheduleEntity, result); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-43, defaultId)] + [InlineData(defaultId, -43)] + public async Task HandleNotFoundAsync(long? leagueId, long? scheduleId) + { + leagueId ??= TestLeagueId; + scheduleId ??= TestScheduleId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(scheduleId.Value); + await base.HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/GetSchedulesHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/GetSchedulesHandlerTests.cs new file mode 100644 index 00000000..e5d6f03d --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/GetSchedulesHandlerTests.cs @@ -0,0 +1,54 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Schedules; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Schedules; + +public sealed class GetSchedulesDbTestFixture : HandlersTestsBase> +{ + public GetSchedulesDbTestFixture() : base() + { + } + + protected override GetSchedulesHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetSchedulesHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override GetSchedulesRequest DefaultRequest() + { + return new GetSchedulesRequest(); + } + + protected override void DefaultAssertions(GetSchedulesRequest request, IEnumerable result, LeagueDbContext dbContext) + { + foreach (var dbSchedule in dbContext.Schedules.Where(x => x.LeagueId == TestLeagueId)) + { + Assert.Contains(result, x => x.ScheduleId == dbSchedule.ScheduleId); + } + } + + [Fact] + public override async Task> ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0)] + [InlineData(-43)] + public async Task HandleNotFoundAsync(long leagueId) + { + accessMockHelper.SetCurrentLeague(leagueId); + var request = DefaultRequest(); + await base.HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/PostScheduleHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/PostScheduleHandlerTests.cs new file mode 100644 index 00000000..5b26f239 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/PostScheduleHandlerTests.cs @@ -0,0 +1,70 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Schedules; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Schedules; + +public sealed class PostScheduleDbTestFixture : HandlersTestsBase +{ + private const string testScheduleName = "TestSchedule"; + + public PostScheduleDbTestFixture() : base() + { + } + + protected override PostScheduleHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PostScheduleHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override PostScheduleRequest DefaultRequest() + { + return DefaultRequest(TestSeasonId); + } + + private PostScheduleRequest DefaultRequest(long seasonId) + { + var model = new PostScheduleModel() + { + Name = testScheduleName + }; + return new PostScheduleRequest(seasonId, DefaultUser(), model); + } + + protected override void DefaultAssertions(PostScheduleRequest request, ScheduleModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.ScheduleId.Should().NotBe(0); + result.Name.Should().Be(expected.Name); + AssertCreated(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-42, defaultId)] + [InlineData(defaultId, -42)] + public async Task HandleNotFoundAsync(long? leagueId, long? seasonId) + { + leagueId ??= TestLeagueId; + seasonId ??= TestSeasonId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(seasonId.Value); + await base.HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/PutScheduleHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/PutScheduleHandlerTests.cs new file mode 100644 index 00000000..6791d390 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Schedules/PutScheduleHandlerTests.cs @@ -0,0 +1,70 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Schedules; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Schedules; + +public sealed class PutScheduleDbTestFixture : HandlersTestsBase +{ + private const string testScheduleName = "TestSchedule"; + + public PutScheduleDbTestFixture() : base() + { + } + + protected override PutScheduleHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PutScheduleHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override PutScheduleRequest DefaultRequest() + { + return DefaultRequest(TestScheduleId); + } + + private PutScheduleRequest DefaultRequest(long scheduleId) + { + var model = new PutScheduleModel() + { + Name = testScheduleName + }; + return new PutScheduleRequest(DefaultUser(), scheduleId, model); + } + + protected override void DefaultAssertions(PutScheduleRequest request, ScheduleModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.ScheduleId.Should().Be(request.ScheduleId); + result.Name.Should().Be(expected.Name); + AssertChanged(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public override async Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0, defaultId)] + [InlineData(defaultId, 0)] + [InlineData(-43, defaultId)] + [InlineData(defaultId, -43)] + public async Task HandleNotFoundAsync(long? leagueId, long? scheduleId) + { + leagueId ??= TestLeagueId; + scheduleId ??= TestScheduleId; + accessMockHelper.SetCurrentLeague(leagueId.Value); + var request = DefaultRequest(scheduleId.Value); + await base.HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/DeleteSeasonHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/DeleteSeasonHandlerTests.cs new file mode 100644 index 00000000..c8a3e3e1 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/DeleteSeasonHandlerTests.cs @@ -0,0 +1,67 @@ + +using FluentValidation; +using iRLeagueApiCore.Server.Handlers.Seasons; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using MediatR; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Seasons; + +public sealed class DeleteSeasonDbTestFixture : HandlersTestsBase +{ + private const string testSeasonName = "TestSeason"; + + public DeleteSeasonDbTestFixture() : base() + { + } + + protected override DeleteSeasonHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new DeleteSeasonHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override DeleteSeasonRequest DefaultRequest() + { + return DefaultRequest(TestSeasonId); + } + + private DeleteSeasonRequest DefaultRequest(long seasonId) + { + + return new DeleteSeasonRequest(seasonId); + } + + protected override void DefaultPreTestAssertions(DeleteSeasonRequest request, LeagueDbContext dbContext) + { + Assert.Contains(dbContext.Seasons, x => x.SeasonId == request.SeasonId); + } + + protected override void DefaultAssertions(DeleteSeasonRequest request, Unit result, LeagueDbContext dbContext) + { + Assert.DoesNotContain(dbContext.Seasons, x => x.SeasonId == request.SeasonId); + } + + [Fact] + public async override Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0, 1)] + [InlineData(1, 0)] + [InlineData(-42, 1)] + [InlineData(1, -42)] + public async Task HandleNotFound(long leagueId, long seasonId) + { + accessMockHelper.SetCurrentLeague(leagueId); + var request = DefaultRequest(seasonId); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/GetSeasonHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/GetSeasonHandlerTests.cs new file mode 100644 index 00000000..17d05bd6 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/GetSeasonHandlerTests.cs @@ -0,0 +1,74 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Seasons; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.EntityFrameworkCore; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Seasons; + +public sealed class GetSeasonDbTestFixture : HandlersTestsBase +{ + public GetSeasonDbTestFixture() : base() + { + } + + protected override GetSeasonHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetSeasonHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override GetSeasonRequest DefaultRequest() + { + return DefaultRequest(TestSeasonId); + } + + private GetSeasonRequest DefaultRequest(long seasonId) + { + return new GetSeasonRequest(seasonId); + } + + protected override void DefaultAssertions(GetSeasonRequest request, SeasonModel result, LeagueDbContext dbContext) + { + var testSeason = dbContext.Seasons + .Include(x => x.Schedules) + .First(x => x.SeasonId == request.SeasonId); + result.SeasonId.Should().Be(request.SeasonId); + result.Finished.Should().Be(testSeason.Finished); + result.HideComments.Should().Be(testSeason.HideCommentsBeforeVoted); + result.ScheduleIds.Should().BeEquivalentTo(testSeason.Schedules.Select(x => x.ScheduleId)); + result.SeasonEnd.Should().Be(testSeason.Schedules.SelectMany(x => x.Events) + .OrderBy(x => x.Date) + .Last().Date); + result.SeasonStart.Should().Be(testSeason.Schedules.SelectMany(x => x.Events) + .OrderBy(x => x.Date) + .First().Date); + result.SeasonName.Should().Be(testSeason.SeasonName); + AssertVersion(testSeason, result); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public async override Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0, 1)] + [InlineData(1, 0)] + [InlineData(1, -42)] + [InlineData(-42, 1)] + public async Task HandleNotFound(long leagueId, long seasonId) + { + accessMockHelper.SetCurrentLeague(leagueId); + var request = DefaultRequest(seasonId); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/GetSeasonsHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/GetSeasonsHandlerTests.cs new file mode 100644 index 00000000..4adc57fc --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/GetSeasonsHandlerTests.cs @@ -0,0 +1,46 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Seasons; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Seasons; + +public sealed class GetSeasonsDbTestFixture : HandlersTestsBase> +{ + public GetSeasonsDbTestFixture() : base() + { + } + + protected override GetSeasonsHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new GetSeasonsHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override GetSeasonsRequest DefaultRequest() + { + return new GetSeasonsRequest(); + } + + [Fact] + public async override Task> ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0)] + [InlineData(-42)] + public async Task HandleNotFound(long leagueId) + { + accessMockHelper.SetCurrentLeague(leagueId); + var request = DefaultRequest(); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/PostSeasonHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/PostSeasonHandlerTests.cs new file mode 100644 index 00000000..685075a5 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/PostSeasonHandlerTests.cs @@ -0,0 +1,65 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Seasons; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Seasons; + +public sealed class PostSeasonHandlerTests : HandlersTestsBase +{ + private const string testSeasonName = "TestSeason"; + + public PostSeasonHandlerTests() : base() + { + } + + protected override PostSeasonHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PostSeasonHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override PostSeasonRequest DefaultRequest() + { + var model = new PostSeasonModel() + { + SeasonName = testSeasonName + }; + return new PostSeasonRequest(DefaultUser(), model); + } + + protected override void DefaultAssertions(PostSeasonRequest request, SeasonModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.LeagueId.Should().Be(accessMockHelper.LeagueProvider.LeagueId); + result.SeasonId.Should().NotBe(0); + result.Finished.Should().Be(expected.Finished); + result.HideComments.Should().Be(expected.HideComments); + result.MainScoringId.Should().Be(expected.MainScoringId); + result.SeasonName.Should().Be(expected.SeasonName); + AssertCreated(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public async override Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0)] + [InlineData(-42)] + public async Task HandleNotFound(long leagueId) + { + accessMockHelper.SetCurrentLeague(leagueId); + var request = DefaultRequest(); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/PutSeasonHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/PutSeasonHandlerTests.cs new file mode 100644 index 00000000..abbe3fd9 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Seasons/PutSeasonHandlerTests.cs @@ -0,0 +1,77 @@ +using FluentValidation; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Handlers.Seasons; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Seasons; + +public sealed class PutSeasonDbTestFixture : HandlersTestsBase +{ + private const string testSeasonName = "TestSeason"; + + public PutSeasonDbTestFixture() : base() + { + } + + protected override PutSeasonHandler CreateTestHandler(LeagueDbContext dbContext, IValidator validator) + { + return new PutSeasonHandler(logger, dbContext, new IValidator[] { validator }); + } + + protected override PutSeasonRequest DefaultRequest() + { + return DefaultRequest(TestSeasonId); + } + + private PutSeasonRequest DefaultRequest(long seasonId) + { + var model = new PutSeasonModel() + { + SeasonName = testSeasonName + }; + return new PutSeasonRequest(DefaultUser(), seasonId, model); + } + + protected override void DefaultPreTestAssertions(PutSeasonRequest request, LeagueDbContext dbContext) + { + Assert.NotEqual(dbContext.Seasons.Single(x => x.SeasonId == request.SeasonId).SeasonName, request.Model.SeasonName); + } + + protected override void DefaultAssertions(PutSeasonRequest request, SeasonModel result, LeagueDbContext dbContext) + { + var expected = request.Model; + result.LeagueId.Should().Be(accessMockHelper.LeagueProvider.LeagueId); + result.SeasonId.Should().Be(request.SeasonId); + result.Finished.Should().Be(expected.Finished); + result.HideComments.Should().Be(expected.HideComments); + result.MainScoringId.Should().Be(expected.MainScoringId); + result.SeasonName.Should().Be(expected.SeasonName); + AssertChanged(request.User, DateTime.UtcNow, result); + base.DefaultAssertions(request, result, dbContext); + } + + [Fact] + public async override Task ShouldHandleDefault() + { + return await base.ShouldHandleDefault(); + } + + [Fact] + public override async Task ShouldHandleValidationFailed() + { + await base.ShouldHandleValidationFailed(); + } + + [Theory] + [InlineData(0, 1)] + [InlineData(1, 0)] + [InlineData(1, -42)] + [InlineData(-42, 1)] + public async Task HandleNotFound(long leagueId, long seasonId) + { + accessMockHelper.SetCurrentLeague(leagueId); + var request = DefaultRequest(seasonId); + await HandleNotFoundRequestAsync(request); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/AddLeagueRoleHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/AddLeagueRoleHandlerTests.cs new file mode 100644 index 00000000..ae49f1c9 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/AddLeagueRoleHandlerTests.cs @@ -0,0 +1,65 @@ +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Users; +using iRLeagueApiCore.UnitTests.Fixtures; +using Microsoft.AspNetCore.Identity; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Users; +public sealed class AddLeagueRoleHandlerTests : UserHandlerTestsBase +{ + public AddLeagueRoleHandlerTests(IdentityFixture identityFixture) : + base(identityFixture) + { + } + + [Fact] + public async Task ShouldAddUserToRole() + { + var testUser = CreateTestUser(); + var testRole = CreateTestRole(identityFixture.testLeague); + var request = CreateRequest(identityFixture.testLeague, testUser, testRole); + var sut = CreateSut(); + + await sut.Handle(request, default); + + identityFixture.UserRoles.Should().Contain(x => x.Value.Any(role => role.Id == testRole.Id)); + } + + [Fact] + public async Task ShoulCreateNonExistingRole() + { + var testUser = CreateTestUser(); + var testRole = CreateTestRole(identityFixture.testLeague); + identityFixture.Roles.Remove(testRole.Id); + var request = CreateRequest(identityFixture.testLeague, testUser, testRole); + var sut = CreateSut(); + + identityFixture.Roles.Should().NotContain(x => x.Value.Name == testRole.Name); + await sut.Handle(request, default); + + identityFixture.Roles.Should().Contain(x => x.Value.Name == testRole.Name); + } + + [Fact] + public async Task ShouldReturnUserWithRole() + { + var testUser = CreateTestUser(); + var testRole = CreateTestRole(identityFixture.testLeague); + var request = CreateRequest(identityFixture.testLeague, testUser, testRole); + var sut = CreateSut(); + + var result = await sut.Handle(request, default); + + result.LeagueRoles.Should().Contain(LeagueRoles.GetRoleName(testRole.Name)); + } + + private AddLeagueRoleRequest CreateRequest(string leagueName, ApplicationUser user, IdentityRole role) + { + return new AddLeagueRoleRequest(leagueName, user.Id, LeagueRoles.GetRoleName(role.Name)!); + } + + private AddLeagueRoleHandler CreateSut() + { + return new AddLeagueRoleHandler(logger, identityFixture.UserManager, identityFixture.RoleManager, validators); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/GetUserHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/GetUserHandlerTests.cs new file mode 100644 index 00000000..846ff07b --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/GetUserHandlerTests.cs @@ -0,0 +1,67 @@ +using FluentValidation; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Users; +using iRLeagueApiCore.UnitTests.Fixtures; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Users; +public sealed class GetUserHandlerTests : UserHandlerTestsBase +{ + public GetUserHandlerTests(IdentityFixture identityFixture) : base(identityFixture) + { + } + + [Fact] + public async Task ShouldReturn_WhenExists() + { + var testUser = UserBuilder().Create(); + identityFixture.Users.Add(testUser); + var userManager = identityFixture.UserManager; + var request = new GetUserRequest(testUser.Id); + var sut = new GetUserHandler(logger, userManager, validators); + + var test = await sut.Handle(request, default); + + test.Should().NotBeNull(); + test!.UserId.Should().Be(testUser.Id); + test.UserName.Should().Be(testUser.UserName); + } + + [Fact] + public async Task ShouldReturn_FirstnameAndLastname_WhenPublic() + { + var testUser = UserBuilder().Create(); + var (firstname, lastname) = GetFirstnameLastname(testUser.FullName); + identityFixture.Users.Add(testUser); + var userManager = identityFixture.UserManager; + var request = new GetUserRequest(testUser.Id); + var sut = new GetUserHandler(logger, userManager, validators); + + testUser.HideFullName = false; + var test = await sut.Handle(request, default); + + test.Should().NotBeNull(); + test!.UserId.Should().Be(testUser.Id); + test.UserName.Should().Be(testUser.UserName); + test.Firstname.Should().Be(firstname); + test.Lastname.Should().Be(lastname); + } + + [Fact] + public async Task ShouldReturn_FirstnameAndLastnameEmpty_WhenNotPublic() + { + var testUser = UserBuilder().Create(); + identityFixture.Users.Add(testUser); + var userManager = identityFixture.UserManager; + var request = new GetUserRequest(testUser.Id); + var sut = new GetUserHandler(logger, userManager, validators); + + testUser.HideFullName = true; + var test = await sut.Handle(request, default); + + test.Should().NotBeNull(); + test!.UserId.Should().Be(testUser.Id); + test.UserName.Should().Be(testUser.UserName); + test.Firstname.Should().BeEmpty(); + test.Lastname.Should().BeEmpty(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/RemoveLeagueRoleHandlerTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/RemoveLeagueRoleHandlerTests.cs new file mode 100644 index 00000000..4736acbf --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/RemoveLeagueRoleHandlerTests.cs @@ -0,0 +1,71 @@ + +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Users; +using iRLeagueApiCore.UnitTests.Fixtures; +using Microsoft.AspNetCore.Identity; +using Serilog; +using System.Diagnostics.Contracts; +using System.Runtime.InteropServices; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Users; +public sealed class RemoveLeagueRoleHandlerTests : UserHandlerTestsBase +{ + private string TestLeagueName => identityFixture.testLeague; + + public RemoveLeagueRoleHandlerTests(IdentityFixture identityFixture) : + base(identityFixture) + { + } + + [Fact] + public async Task ShouldRemoveRoleFromUser() + { + var testUser = CreateTestUser(); + var testRole = CreateTestRole(TestLeagueName); + identityFixture.UserRoles.Add(testUser, new() {testRole}); + var request = CreateRequest(TestLeagueName, testUser, testRole); + var sut = CreateSut(); + + identityFixture.UserRoles.Should().Contain(x => x.Key == testUser && x.Value.Any(role => role == testRole)); + await sut.Handle(request, default); + + identityFixture.UserRoles.Should().NotContain(x => x.Key == testUser && x.Value.Any(role => role == testRole)); + } + + [Fact] + public async Task ShouldSucceed_WhenUserNotInRole() + { + var testUser = CreateTestUser(); + var testRole = CreateTestRole(TestLeagueName); + var request = CreateRequest(TestLeagueName, testUser, testRole); + var sut = CreateSut(); + + await sut.Handle(request, default); + } + + [Fact] + public async Task ShouldReturnUserWithoutRole() + { + var testUser = CreateTestUser(); + var testRole = CreateTestRole(TestLeagueName); + identityFixture.UserRoles.Add(testUser, new() { testRole }); + var request = CreateRequest(TestLeagueName, testUser, testRole); + var sut = CreateSut(); + + var result = await sut.Handle(request, default); + + result.LeagueRoles.Should().NotContain(LeagueRoles.GetRoleName(testRole.Name)); + } + + + private RemoveLeagueRoleRequest CreateRequest(string leagueName, ApplicationUser user, IdentityRole role) + { + return new(leagueName, user.Id, LeagueRoles.GetRoleName(role.Name)!); + } + + private RemoveLeagueRoleHandler CreateSut() + { + return new RemoveLeagueRoleHandler(logger, identityFixture.UserManager, validators); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/UserHandlerTestsBase.cs b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/UserHandlerTestsBase.cs new file mode 100644 index 00000000..064ba8a5 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Handlers/Users/UserHandlerTestsBase.cs @@ -0,0 +1,59 @@ +using AutoFixture.Dsl; +using FluentValidation; +using iRLeagueApiCore.Common; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.UnitTests.Fixtures; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.Test; +using Microsoft.Extensions.Logging; + +namespace iRLeagueApiCore.UnitTests.Server.Handlers.Users; +public abstract class UserHandlerTestsBase : IClassFixture +{ + protected readonly Fixture fixture; + protected readonly IdentityFixture identityFixture; + protected readonly ILogger logger; + protected readonly IEnumerable> validators; + + public UserHandlerTestsBase(IdentityFixture identityFixture) + { + this.identityFixture = identityFixture; + fixture = new(); + logger = Mock.Of>(); + validators = Array.Empty>(); + identityFixture.Setup(); + } + + protected IPostprocessComposer UserBuilder() + { + return fixture.Build() + .With(x => x.FullName, () => GetFullName(fixture.Create().Substring(0,10), fixture.Create().Substring(0,10))); + } + + protected string GetFullName(string firstname, string lastname) + { + return $"{firstname};{lastname}"; + } + + protected (string? firstname, string? lastname) GetFirstnameLastname(string? fullName) + { + var parts = fullName?.Split(';'); + return (parts?.ElementAtOrDefault(0), parts?.ElementAtOrDefault(1)); + } + + protected ApplicationUser CreateTestUser() + { + var user = UserBuilder().Create(); + identityFixture.Users.Add(user); + return user; + } + + protected IdentityRole CreateTestRole(string leagueName) + { + var roleName = LeagueRoles.GetLeagueRoleName(leagueName, LeagueRoles.Admin); + var role = new IdentityRole(roleName); + role.NormalizedName = MockHelpers.MockLookupNormalizer().NormalizeName(roleName); + identityFixture.Roles.Add(role.Id, role); + return role; + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Models/CredentialListTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Models/CredentialListTests.cs new file mode 100644 index 00000000..c217ae88 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Models/CredentialListTests.cs @@ -0,0 +1,97 @@ +using iRLeagueApiCore.Server.Models; +using System.Net; + +namespace iRLeagueApiCore.UnitTests.Server.Models; +public sealed class CredentialListTests +{ + private readonly Fixture fixture; + private readonly Uri uri; + private readonly string authenticationType; + private readonly string username; + private readonly string password; + + public CredentialListTests() + { + fixture = new(); + uri = new Uri("https://example.com"); + authenticationType = "BasicAuth"; + username = fixture.Create(); + password = fixture.Create(); + } + + [Fact] + public void Add_ShouldAddAndReturnNewCredential() + { + var credential = new NetworkCredential(username, password); + var sut = new CredentialList(); + + sut.Add(uri, authenticationType, credential); + + var test = sut.GetCredential(uri, authenticationType); + test.Should().NotBeNull(); + test!.UserName.Should().Be(username); + test.Password.Should().Be(password); + } + + [Fact] + public void Add_ShouldUpdateExistingCredential() + { + var original = new NetworkCredential(username, password); + var newPassword = fixture.Create(); + var updated = new NetworkCredential(username, newPassword); + var sut = new CredentialList(); + + sut.Add(uri, authenticationType, original); + sut.Add(uri, authenticationType , updated); + + var test = sut.GetCredential(uri, authenticationType); + test.Should().NotBeNull(); + test!.UserName.Should().Be(username); + test.Password.Should().Be(newPassword); + } + + [Fact] + public void Add_ShouldStoreDifferentCredentials_WhenUriIsDifferent() + { + var uri1 = fixture.Create(); + var uri2 = fixture.Create(); + var password1 = fixture.Create(); + var password2 = fixture.Create(); + var credential1 = new NetworkCredential(username, password1); + var credential2 = new NetworkCredential(username, password2); + var sut = new CredentialList(); + + sut.Add(uri1, authenticationType, credential1); + sut.Add(uri2, authenticationType , credential2); + + var test1 = sut.GetCredential(uri1, authenticationType); + var test2 = sut.GetCredential(uri2, authenticationType); + test1.Should().NotBeNull(); + test1!.Password.Should().Be(password1); + test2.Should().NotBeNull(); + test2!.Password.Should().Be(password2); + } + + [Fact] + public void Remove_ShouldRemoveExistingCredential() + { + var credential = new NetworkCredential(username, password); + var sut = new CredentialList(); + sut.Add(uri, authenticationType, credential); + + sut.Remove(uri, authenticationType); + + var test = sut.GetCredential(uri, authenticationType); + test.Should().BeNull(); + } + + [Fact] + public void Remove_ShouldNotThrow_WhenCredentialDoesNotExist() + { + var sut = new CredentialList(); + + sut.Remove(uri, authenticationType); + + sut.GetCredential(uri, authenticationType); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Validators/Leagues/PostLeagueRequestValidatorTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Validators/Leagues/PostLeagueRequestValidatorTests.cs new file mode 100644 index 00000000..8776bd9e --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Validators/Leagues/PostLeagueRequestValidatorTests.cs @@ -0,0 +1,73 @@ +using FluentValidation.TestHelper; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Server.Authentication; +using iRLeagueApiCore.Server.Handlers.Leagues; +using iRLeagueApiCore.Server.Models; +using iRLeagueApiCore.Server.Validation.Leagues; +using iRLeagueApiCore.UnitTests.Fixtures; +using iRLeagueDatabaseCore.Models; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.Test; + +namespace iRLeagueApiCore.UnitTests.Server.Validators.Leagues; + +public sealed class PostLeagueRequestDbTestFixture : IClassFixture +{ + private readonly DbTestFixture fixture; + private const string testLeagueName = "ValidationLeague123_-"; + private const string testLeagueNameFull = "Full test league name"; + + private string ExistingLeagueName => fixture.DbContext.Leagues.First().Name; + + public PostLeagueRequestDbTestFixture(DbTestFixture fixture) + { + this.fixture = fixture; + } + + private static PostLeagueRequest DefaultRequest(string name = testLeagueName) + { + var model = new PostLeagueModel() + { + Name = name, + NameFull = testLeagueNameFull, + }; + return new PostLeagueRequest(LeagueUser.Empty, model); + } + + private static PostLeagueRequestValidator CreateValidator(LeagueDbContext dbContext) + { + return new PostLeagueRequestValidator(new PostLeagueModelValidator(dbContext), MockHelpers.TestUserManager()); + } + + [Fact] + public async Task ValidRequest() + { + using var dbContext = fixture.CreateDbContext(); + var request = DefaultRequest(); + var validator = CreateValidator(dbContext); + var result = await validator.TestValidateAsync(request); + result.ShouldNotHaveAnyValidationErrors(); + } + + [Theory] + [InlineData("1league", true)] // number at beginning: ok + [InlineData(null, false)] // league name exists + [InlineData("1337", false)] // only numbers + [InlineData("123.league.de", false)] // no dots + [InlineData("sh", false)] // too short + [InlineData("abcdefghiklmnopqrstuvwxyzabcdefghiklmnopqrstuvwxyzabcdefghiklmnopqrstuvwxyzabcdefghiklmnopqrstuvwxyz", false)] // too long + [InlineData("league name", false)] // invalid character: space + public async Task ValidateName(string? leagueName, bool isValid) + { + leagueName ??= ExistingLeagueName; + using var dbContext = fixture.CreateDbContext(); + var request = DefaultRequest(leagueName); + var validator = CreateValidator(dbContext); + var result = await validator.TestValidateAsync(request); + Assert.Equal(isValid, result.IsValid); + if (isValid == false) + { + result.ShouldHaveValidationErrorFor(x => x.Model.Name); + } + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Validators/Seasons/PostSeasonValidatorTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Validators/Seasons/PostSeasonValidatorTests.cs new file mode 100644 index 00000000..0bb801c0 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Validators/Seasons/PostSeasonValidatorTests.cs @@ -0,0 +1,48 @@ +using FluentValidation.TestHelper; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Server.Handlers.Seasons; +using iRLeagueApiCore.Server.Models; +using iRLeagueApiCore.Server.Validation.Seasons; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Validators.Seasons; + +public sealed class PostSeasonValidatorTests : DataAccessTestsBase +{ + private const string testSeasonName = "TestSeason"; + + private PostSeasonRequest DefaultRequest() + { + var model = new PostSeasonModel() + { + HideComments = true, + MainScoringId = null, + Finished = true, + SeasonName = testSeasonName, + }; + return new PostSeasonRequest(LeagueUser.Empty, model); + } + + private static PostSeasonRequestValidator CreateValidator(LeagueDbContext dbContext) + { + return new PostSeasonRequestValidator(dbContext, new PostSeasonModelValidator()); + } + + [Theory] + [InlineData("ValidName", true)] + [InlineData("", false)] + [InlineData(null, false)] + public async Task ValidateSeasonName(string name, bool expectValid) + { + var request = DefaultRequest(); + request.Model.SeasonName = name; + var validator = CreateValidator(dbContext); + var result = await validator.TestValidateAsync(request); + Assert.Equal(expectValid, result.IsValid); + if (expectValid == false) + { + result.ShouldHaveValidationErrorFor(x => x.Model.SeasonName); + } + } +} diff --git a/test/iRLeagueApiCore.UnitTests/Server/Validators/Seasons/PutSeasonValidatorTests.cs b/test/iRLeagueApiCore.UnitTests/Server/Validators/Seasons/PutSeasonValidatorTests.cs new file mode 100644 index 00000000..e2f15db6 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/Server/Validators/Seasons/PutSeasonValidatorTests.cs @@ -0,0 +1,65 @@ +using FluentValidation.TestHelper; +using iRLeagueApiCore.Common.Models; +using iRLeagueApiCore.Mocking.DataAccess; +using iRLeagueApiCore.Server.Handlers.Seasons; +using iRLeagueApiCore.Server.Models; +using iRLeagueApiCore.Server.Validation.Seasons; +using iRLeagueDatabaseCore.Models; + +namespace iRLeagueApiCore.UnitTests.Server.Validators.Seasons; + +public sealed class PutSeasonValidatorTests : DataAccessTestsBase +{ + private const long testLeagueId = 1; + private const long testSeasonId = 1; + private const string testSeasonName = "TestSeason"; + + private static PutSeasonRequest DefaultRequest(long seasonId = testSeasonId) + { + var model = new PutSeasonModel() + { + HideComments = true, + MainScoringId = null, + Finished = true, + SeasonName = testSeasonName, + }; + return new PutSeasonRequest(LeagueUser.Empty, seasonId, model); + } + + private static PutSeasonRequestValidator CreateValidator(LeagueDbContext dbContext) + { + return new PutSeasonRequestValidator(dbContext, new PutSeasonModelValidator(new())); + } + + [Theory] + [InlineData(1, true)] + [InlineData(0, false)] + public async Task ValidateSeasonId(long seasonId, bool expectValid) + { + var request = DefaultRequest(seasonId: seasonId); + var validator = CreateValidator(dbContext); + var result = await validator.TestValidateAsync(request); + Assert.Equal(expectValid, result.IsValid); + if (expectValid == false) + { + result.ShouldHaveValidationErrorFor(x => x.SeasonId); + } + } + + [Theory] + [InlineData("ValidName", true)] + [InlineData("", false)] + [InlineData(null, false)] + public async Task ValidateSeasonName(string name, bool expectValid) + { + var request = DefaultRequest(); + request.Model.SeasonName = name; + var validator = CreateValidator(dbContext); + var result = await validator.TestValidateAsync(request); + Assert.Equal(expectValid, result.IsValid); + if (expectValid == false) + { + result.ShouldHaveValidationErrorFor(x => x.Model.SeasonName); + } + } +} diff --git a/test/iRLeagueApiCore.UnitTests/TrackImport/TrackImportModelTests.cs b/test/iRLeagueApiCore.UnitTests/TrackImport/TrackImportModelTests.cs new file mode 100644 index 00000000..996f87fc --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/TrackImport/TrackImportModelTests.cs @@ -0,0 +1,144 @@ +using iRLeagueApiCore.TrackImport.Models; +using System.Text.Json; + +namespace iRLeagueApiCore.UnitTests.TrackImport; + +public sealed class TrackImportModelTests +{ + [Fact] + public void ShouldReadDataFromJson() + { + var data = testJson; + var imported = JsonSerializer.Deserialize(data); + + imported.Should().NotBeEmpty(); + var firstTrack = imported![0]; + firstTrack.ai_enabled.Should().BeFalse(); + firstTrack.award_exempt.Should().BeTrue(); + firstTrack.category.Should().Be("road"); + firstTrack.category_id.Should().Be(2); + firstTrack.closes.Should().Be(DateTime.Parse("2018-10-31")); + firstTrack.config_name.Should().Be("Full Course"); + firstTrack.corners_per_lap.Should().Be(7); + firstTrack.created.Should().BeCloseTo(DateTime.Parse("2006-04-04T19:10:00Z"), TimeSpan.FromDays(1)); + firstTrack.free_with_subscription.Should().BeTrue(); + firstTrack.fully_lit.Should().BeFalse(); + firstTrack.grid_stalls.Should().Be(62); + firstTrack.has_opt_path.Should().BeFalse(); + firstTrack.has_short_parade_lap.Should().BeTrue(); + firstTrack.track_name.Should().Be("[Legacy] Lime Rock Park - 2008"); + firstTrack.track_types.Should().HaveCount(1); + var trackType = firstTrack.track_types![0]; + trackType.track_type.Should().Be("road"); + } + + public static string testJson = @"[ + { + ""ai_enabled"": false, + ""award_exempt"": true, + ""category"": ""road"", + ""category_id"": 2, + ""closes"": ""2018-10-31"", + ""config_name"": ""Full Course"", + ""corners_per_lap"": 7, + ""created"": ""2006-04-04T19:10:00Z"", + ""free_with_subscription"": true, + ""fully_lit"": false, + ""grid_stalls"": 62, + ""has_opt_path"": false, + ""has_short_parade_lap"": true, + ""has_start_zone"": false, + ""has_svg_map"": true, + ""is_dirt"": false, + ""is_oval"": false, + ""lap_scoring"": 0, + ""latitude"": 41.9282105, + ""location"": ""Lakeville, Connecticut, USA"", + ""longitude"": -73.3839642, + ""max_cars"": 66, + ""night_lighting"": false, + ""nominal_lap_time"": 53.54668, + ""number_pitstalls"": 34, + ""opens"": ""2018-04-01"", + ""package_id"": 9, + ""pit_road_speed_limit"": 45, + ""price"": 0, + ""priority"": 1, + ""purchasable"": true, + ""qualify_laps"": 2, + ""restart_on_left"": false, + ""retired"": false, + ""search_filters"": ""road,lrp"", + ""site_url"": ""http://www.limerock.com/"", + ""sku"": 10021, + ""solo_laps"": 8, + ""start_on_left"": false, + ""supports_grip_compound"": false, + ""tech_track"": false, + ""time_zone"": ""America/New_York"", + ""track_config_length"": 1.53, + ""track_dirpath"": ""limerock\\full"", + ""track_id"": 1, + ""track_name"": ""[Legacy] Lime Rock Park - 2008"", + ""track_types"": [ + { + ""track_type"": ""road"" + } + ] + }, + { + ""ai_enabled"": false, + ""award_exempt"": false, + ""category"": ""road"", + ""category_id"": 2, + ""closes"": ""2022-10-31"", + ""config_name"": ""Full Course"", + ""corners_per_lap"": 20, + ""created"": ""2006-05-28T04:20:00Z"", + ""free_with_subscription"": false, + ""fully_lit"": false, + ""grid_stalls"": 62, + ""has_opt_path"": false, + ""has_short_parade_lap"": false, + ""has_start_zone"": false, + ""has_svg_map"": true, + ""is_dirt"": false, + ""is_oval"": false, + ""lap_scoring"": 0, + ""latitude"": 36.560008, + ""location"": ""Alton, Virginia, USA"", + ""longitude"": -79.2048, + ""max_cars"": 72, + ""night_lighting"": false, + ""nominal_lap_time"": 114.92681, + ""number_pitstalls"": 37, + ""opens"": ""2022-03-01"", + ""package_id"": 14, + ""pit_road_speed_limit"": 45, + ""price"": 14.95, + ""priority"": 1, + ""purchasable"": true, + ""qualify_laps"": 2, + ""restart_on_left"": false, + ""retired"": false, + ""search_filters"": ""road"", + ""site_url"": ""http://www.virclub.com/vir"", + ""sku"": 10031, + ""solo_laps"": 4, + ""start_on_left"": false, + ""supports_grip_compound"": false, + ""tech_track"": false, + ""time_zone"": ""America/New_York"", + ""track_config_length"": 3.27, + ""track_dirpath"": ""virginia\\full"", + ""track_id"": 2, + ""track_name"": ""Virginia International Raceway"", + ""track_types"": [ + { + ""track_type"": ""road"" + } + ] + } +]"; + +} diff --git a/test/iRLeagueApiCore.UnitTests/TrackImport/TrackImportServiceTests.cs b/test/iRLeagueApiCore.UnitTests/TrackImport/TrackImportServiceTests.cs new file mode 100644 index 00000000..ae96400b --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/TrackImport/TrackImportServiceTests.cs @@ -0,0 +1,91 @@ +using iRLeagueApiCore.TrackImport.Service; +using Microsoft.Extensions.Configuration; +using System.Net; + +namespace iRLeagueApiCore.UnitTests.TrackImport; + +public sealed class TrackImportServiceTests +{ + private readonly IConfiguration configuration; + private const string Skip = "Skip tests that hit external api"; + + private const string testUserName = "CLunky@iracing.Com"; + private const string testPassword = "MyPassWord"; + private const string testPasswordEncoded = "xGKecAR27ALXNuMLsGaG0v5Q9pSs2tZTZRKNgmHMg+Q="; + + public TrackImportServiceTests() + { + configuration = ((IConfigurationBuilder)(new ConfigurationBuilder())) + .AddUserSecrets() + .Build(); + } + [Fact] + public void EncodePassword_ShouldEncodeTestHash_WhenUsingTestPassword() + { + string userName = testUserName; + string password = testPassword; + string expected = testPasswordEncoded; + + var encoded = TrackImportService.EncodePassword(userName, password); + + encoded.Should().Be(expected); + } + + [Fact(Skip = Skip)] + public async Task Authenticate_ShouldReturnTrue_WhenUsingValidCredentials() + { + string username = configuration["Iracing:UserName"]; + string password = configuration["Iracing:Password"]; + var cookieContainer = new CookieContainer(); + var httpClientHander = new HttpClientHandler() + { + UseCookies = true, + CookieContainer = cookieContainer + }; + + var sut = new TrackImportService(new(httpClientHander)); + var result = await sut.Authenticate(username, password); + + result.Should().BeTrue(); + cookieContainer.GetAllCookies().Should().NotBeEmpty(); + } + + [Fact(Skip = Skip)] + public async Task Authenticate_ShouldReturnFalse_WhenUsingInvalidCredentials() + { + var username = testUserName; + var password = testPassword; + var cookieContainer = new CookieContainer(); + var httpClientHander = new HttpClientHandler() + { + UseCookies = true, + CookieContainer = cookieContainer + }; + + var sut = new TrackImportService(new(httpClientHander)); + var result = await sut.Authenticate(username, password); + + result.Should().BeFalse(); + } + + [Fact(Skip = Skip)] + public async Task GetTracksData_ShouldReturnData_WhenUsingValidCredentials() + { + string username = configuration["Iracing:UserName"]; + string password = configuration["Iracing:Password"]; + var cookieContainer = new CookieContainer(); + var httpClientHander = new HttpClientHandler() + { + UseCookies = true, + CookieContainer = cookieContainer + }; + + var sut = new TrackImportService(new(httpClientHander)); + await sut.Authenticate(username, password); + cookieContainer.GetCookies(new("https://members-ng.iracing.com")).Should().NotBeEmpty(); + var result = await sut.GetTracksData(); + + result.Should().NotBeNull(); + result.Should().NotBeEmpty(); + } +} diff --git a/test/iRLeagueApiCore.UnitTests/_GlobalUsings.cs b/test/iRLeagueApiCore.UnitTests/_GlobalUsings.cs new file mode 100644 index 00000000..b089d68b --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/_GlobalUsings.cs @@ -0,0 +1,4 @@ +global using AutoFixture; +global using FluentAssertions; +global using Moq; +global using Xunit; diff --git a/test/iRLeagueApiCore.UnitTests/iRLeagueApiCore.UnitTests.csproj b/test/iRLeagueApiCore.UnitTests/iRLeagueApiCore.UnitTests.csproj new file mode 100644 index 00000000..1dfeb934 --- /dev/null +++ b/test/iRLeagueApiCore.UnitTests/iRLeagueApiCore.UnitTests.csproj @@ -0,0 +1,53 @@ + + + + net6.0 + false + 268f531b-646e-4c03-bd3f-0c5544ed5c1b + enable + enable + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + + + Always + + + +