feat: initial datamodel + ef connection and migrations

Initial version of the data model
Includes EF initialization and migrations
EF migrations are applied on application start
This commit is contained in:
2026-04-09 10:36:09 +02:00
commit 16160f6424
45 changed files with 2522 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TournamentOrganizer"
x:Class="TournamentOrganizer.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
+66
View File
@@ -0,0 +1,66 @@
using System.Linq;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using Microsoft.EntityFrameworkCore;
using TournamentOrganizer.ViewModels;
using TournamentOrganizer.Views;
namespace TournamentOrganizer;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
// Avoid duplicate validations from both Avalonia and the CommunityToolkit.
// More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins
DisableAvaloniaDataAnnotationValidation();
desktop.MainWindow = new MainWindow
{
DataContext = new MainViewModel()
};
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView
{
DataContext = new MainViewModel()
};
}
Dispatcher.UIThread.Post(async () => await ApplyDatabaseMigrations());
base.OnFrameworkInitializationCompleted();
}
private async Task ApplyDatabaseMigrations()
{
using var context = new TournamentContext();
await context.Database.MigrateAsync();
}
private void DisableAvaloniaDataAnnotationValidation()
{
// Get an array of plugins to remove
var dataValidationPluginsToRemove =
BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();
// remove each entry found
foreach (var plugin in dataValidationPluginsToRemove)
{
BindingPlugins.DataValidators.Remove(plugin);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

@@ -0,0 +1,40 @@
using System;
using System.IO;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using TournamentOrganizer.Models;
namespace TournamentOrganizer;
public class TournamentContext : DbContext
{
public DbSet<Event> Events { get; set; }
public DbSet<Game> Games { get; set; }
public DbSet<Match> Matches { get; set; }
public DbSet<TeamParticipant> TeamParticipants { get; set; }
public DbSet<PlayerParticipant> PlayerParticipants { get; set; }
public DbSet<Player> Players { get; set; }
public DbSet<Round> Rounds { get; set; }
public DbSet<Team> Teams { get; set; }
public DbSet<Tournament> Tournaments { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string datadir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TournamentOrganizer");
Directory.CreateDirectory(datadir);
string dbfile = Path.Combine(datadir, "sqlite.db");
optionsBuilder.UseSqlite(new SqliteConnectionStringBuilder()
{
DataSource = dbfile,
Mode = SqliteOpenMode.ReadWriteCreate,
ForeignKeys = true,
RecursiveTriggers = true
}.ToString());
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
@@ -0,0 +1,46 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TournamentOrganizer;
#nullable disable
namespace TournamentOrganizer.Migrations
{
[DbContext(typeof(TournamentContext))]
[Migration("20260409072947_InitialEvent")]
partial class InitialEvent
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.5");
modelBuilder.Entity("TournamentOrganizer.Models.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("EventEnd")
.HasColumnType("TEXT");
b.Property<DateTime>("EventStart")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Events");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,37 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TournamentOrganizer.Migrations
{
/// <inheritdoc />
public partial class InitialEvent : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Events",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
EventStart = table.Column<DateTime>(type: "TEXT", nullable: false),
EventEnd = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Events", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Events");
}
}
}
@@ -0,0 +1,315 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TournamentOrganizer;
#nullable disable
namespace TournamentOrganizer.Migrations
{
[DbContext(typeof(TournamentContext))]
[Migration("20260409082427_InitialDataModel")]
partial class InitialDataModel
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.5");
modelBuilder.Entity("TournamentOrganizer.Models.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("EventEnd")
.HasColumnType("TEXT");
b.Property<DateTime>("EventStart")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Events");
});
modelBuilder.Entity("TournamentOrganizer.Models.Game", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("S1RuleSet")
.HasColumnType("INTEGER");
b.Property<int?>("S2RuleSet")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Games");
});
modelBuilder.Entity("TournamentOrganizer.Models.Match", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("TournamentId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Matches");
});
modelBuilder.Entity("TournamentOrganizer.Models.Player", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("TeamId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Players");
});
modelBuilder.Entity("TournamentOrganizer.Models.PlayerParticipant", b =>
{
b.Property<int>("RoundId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerId")
.HasColumnType("INTEGER");
b.HasKey("RoundId", "PlayerId");
b.HasIndex("PlayerId");
b.ToTable("PlayerParticipants");
});
modelBuilder.Entity("TournamentOrganizer.Models.Round", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MatchId")
.HasColumnType("INTEGER");
b.Property<int>("State")
.HasColumnType("INTEGER");
b.Property<int?>("WinnerId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("MatchId");
b.ToTable("Rounds");
});
modelBuilder.Entity("TournamentOrganizer.Models.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Teams");
});
modelBuilder.Entity("TournamentOrganizer.Models.TeamParticipant", b =>
{
b.Property<int>("MatchId")
.HasColumnType("INTEGER");
b.Property<int>("TeamId")
.HasColumnType("INTEGER");
b.Property<int>("Seed")
.HasColumnType("INTEGER");
b.HasKey("MatchId", "TeamId");
b.HasIndex("TeamId");
b.ToTable("TeamParticipants");
});
modelBuilder.Entity("TournamentOrganizer.Models.Tournament", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("EventId")
.HasColumnType("INTEGER");
b.Property<int>("GameId")
.HasColumnType("INTEGER");
b.Property<int>("S1RuleSet")
.HasColumnType("INTEGER");
b.Property<int?>("S2RuleSet")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("EventId");
b.HasIndex("GameId");
b.ToTable("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Match", b =>
{
b.HasOne("TournamentOrganizer.Models.Tournament", "Tournament")
.WithMany()
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("TournamentOrganizer.Models.Player", b =>
{
b.HasOne("TournamentOrganizer.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("TournamentOrganizer.Models.PlayerParticipant", b =>
{
b.HasOne("TournamentOrganizer.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Round", "Round")
.WithMany()
.HasForeignKey("RoundId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
b.Navigation("Round");
});
modelBuilder.Entity("TournamentOrganizer.Models.Round", b =>
{
b.HasOne("TournamentOrganizer.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
});
modelBuilder.Entity("TournamentOrganizer.Models.TeamParticipant", b =>
{
b.HasOne("TournamentOrganizer.Models.Match", "Round")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Team", "Team")
.WithMany("Matches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Round");
b.Navigation("Team");
});
modelBuilder.Entity("TournamentOrganizer.Models.Tournament", b =>
{
b.HasOne("TournamentOrganizer.Models.Event", "Event")
.WithMany("Tournaments")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Game", "Game")
.WithMany("Tournaments")
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Event");
b.Navigation("Game");
});
modelBuilder.Entity("TournamentOrganizer.Models.Event", b =>
{
b.Navigation("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Game", b =>
{
b.Navigation("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Team", b =>
{
b.Navigation("Matches");
b.Navigation("Players");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,244 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TournamentOrganizer.Migrations
{
/// <inheritdoc />
public partial class InitialDataModel : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Games",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
S1RuleSet = table.Column<int>(type: "INTEGER", nullable: false),
S2RuleSet = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Games", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Teams",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Teams", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Tournaments",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
GameId = table.Column<int>(type: "INTEGER", nullable: false),
EventId = table.Column<int>(type: "INTEGER", nullable: false),
S1RuleSet = table.Column<int>(type: "INTEGER", nullable: false),
S2RuleSet = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Tournaments", x => x.Id);
table.ForeignKey(
name: "FK_Tournaments_Events_EventId",
column: x => x.EventId,
principalTable: "Events",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Tournaments_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Players",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Contact = table.Column<string>(type: "TEXT", nullable: false),
TeamId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Players", x => x.Id);
table.ForeignKey(
name: "FK_Players_Teams_TeamId",
column: x => x.TeamId,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Matches",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
TournamentId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Matches", x => x.Id);
table.ForeignKey(
name: "FK_Matches_Tournaments_TournamentId",
column: x => x.TournamentId,
principalTable: "Tournaments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Rounds",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
MatchId = table.Column<int>(type: "INTEGER", nullable: false),
WinnerId = table.Column<int>(type: "INTEGER", nullable: true),
State = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Rounds", x => x.Id);
table.ForeignKey(
name: "FK_Rounds_Matches_MatchId",
column: x => x.MatchId,
principalTable: "Matches",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TeamParticipants",
columns: table => new
{
MatchId = table.Column<int>(type: "INTEGER", nullable: false),
TeamId = table.Column<int>(type: "INTEGER", nullable: false),
Seed = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TeamParticipants", x => new { x.MatchId, x.TeamId });
table.ForeignKey(
name: "FK_TeamParticipants_Matches_MatchId",
column: x => x.MatchId,
principalTable: "Matches",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TeamParticipants_Teams_TeamId",
column: x => x.TeamId,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PlayerParticipants",
columns: table => new
{
RoundId = table.Column<int>(type: "INTEGER", nullable: false),
PlayerId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PlayerParticipants", x => new { x.RoundId, x.PlayerId });
table.ForeignKey(
name: "FK_PlayerParticipants_Players_PlayerId",
column: x => x.PlayerId,
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PlayerParticipants_Rounds_RoundId",
column: x => x.RoundId,
principalTable: "Rounds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Matches_TournamentId",
table: "Matches",
column: "TournamentId");
migrationBuilder.CreateIndex(
name: "IX_PlayerParticipants_PlayerId",
table: "PlayerParticipants",
column: "PlayerId");
migrationBuilder.CreateIndex(
name: "IX_Players_TeamId",
table: "Players",
column: "TeamId");
migrationBuilder.CreateIndex(
name: "IX_Rounds_MatchId",
table: "Rounds",
column: "MatchId");
migrationBuilder.CreateIndex(
name: "IX_TeamParticipants_TeamId",
table: "TeamParticipants",
column: "TeamId");
migrationBuilder.CreateIndex(
name: "IX_Tournaments_EventId",
table: "Tournaments",
column: "EventId");
migrationBuilder.CreateIndex(
name: "IX_Tournaments_GameId",
table: "Tournaments",
column: "GameId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PlayerParticipants");
migrationBuilder.DropTable(
name: "TeamParticipants");
migrationBuilder.DropTable(
name: "Players");
migrationBuilder.DropTable(
name: "Rounds");
migrationBuilder.DropTable(
name: "Teams");
migrationBuilder.DropTable(
name: "Matches");
migrationBuilder.DropTable(
name: "Tournaments");
migrationBuilder.DropTable(
name: "Games");
}
}
}
@@ -0,0 +1,318 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TournamentOrganizer;
#nullable disable
namespace TournamentOrganizer.Migrations
{
[DbContext(typeof(TournamentContext))]
[Migration("20260409083011_TournamentStartEnd")]
partial class TournamentStartEnd
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.5");
modelBuilder.Entity("TournamentOrganizer.Models.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("End")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("Start")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Events");
});
modelBuilder.Entity("TournamentOrganizer.Models.Game", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("S1RuleSet")
.HasColumnType("INTEGER");
b.Property<int?>("S2RuleSet")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Games");
});
modelBuilder.Entity("TournamentOrganizer.Models.Match", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("TournamentId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Matches");
});
modelBuilder.Entity("TournamentOrganizer.Models.Player", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("TeamId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Players");
});
modelBuilder.Entity("TournamentOrganizer.Models.PlayerParticipant", b =>
{
b.Property<int>("RoundId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerId")
.HasColumnType("INTEGER");
b.HasKey("RoundId", "PlayerId");
b.HasIndex("PlayerId");
b.ToTable("PlayerParticipants");
});
modelBuilder.Entity("TournamentOrganizer.Models.Round", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MatchId")
.HasColumnType("INTEGER");
b.Property<int>("State")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("MatchId");
b.ToTable("Rounds");
});
modelBuilder.Entity("TournamentOrganizer.Models.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Teams");
});
modelBuilder.Entity("TournamentOrganizer.Models.TeamParticipant", b =>
{
b.Property<int>("MatchId")
.HasColumnType("INTEGER");
b.Property<int>("TeamId")
.HasColumnType("INTEGER");
b.Property<int>("Seed")
.HasColumnType("INTEGER");
b.HasKey("MatchId", "TeamId");
b.HasIndex("TeamId");
b.ToTable("TeamParticipants");
});
modelBuilder.Entity("TournamentOrganizer.Models.Tournament", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("End")
.HasColumnType("TEXT");
b.Property<int>("EventId")
.HasColumnType("INTEGER");
b.Property<int>("GameId")
.HasColumnType("INTEGER");
b.Property<int>("S1RuleSet")
.HasColumnType("INTEGER");
b.Property<int?>("S2RuleSet")
.HasColumnType("INTEGER");
b.Property<DateTime>("Start")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("EventId");
b.HasIndex("GameId");
b.ToTable("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Match", b =>
{
b.HasOne("TournamentOrganizer.Models.Tournament", "Tournament")
.WithMany()
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("TournamentOrganizer.Models.Player", b =>
{
b.HasOne("TournamentOrganizer.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("TournamentOrganizer.Models.PlayerParticipant", b =>
{
b.HasOne("TournamentOrganizer.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Round", "Round")
.WithMany()
.HasForeignKey("RoundId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
b.Navigation("Round");
});
modelBuilder.Entity("TournamentOrganizer.Models.Round", b =>
{
b.HasOne("TournamentOrganizer.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
});
modelBuilder.Entity("TournamentOrganizer.Models.TeamParticipant", b =>
{
b.HasOne("TournamentOrganizer.Models.Match", "Round")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Team", "Team")
.WithMany("Matches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Round");
b.Navigation("Team");
});
modelBuilder.Entity("TournamentOrganizer.Models.Tournament", b =>
{
b.HasOne("TournamentOrganizer.Models.Event", "Event")
.WithMany("Tournaments")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Game", "Game")
.WithMany("Tournaments")
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Event");
b.Navigation("Game");
});
modelBuilder.Entity("TournamentOrganizer.Models.Event", b =>
{
b.Navigation("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Game", b =>
{
b.Navigation("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Team", b =>
{
b.Navigation("Matches");
b.Navigation("Players");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,71 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TournamentOrganizer.Migrations
{
/// <inheritdoc />
public partial class TournamentStartEnd : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "WinnerId",
table: "Rounds");
migrationBuilder.RenameColumn(
name: "EventStart",
table: "Events",
newName: "Start");
migrationBuilder.RenameColumn(
name: "EventEnd",
table: "Events",
newName: "End");
migrationBuilder.AddColumn<DateTime>(
name: "End",
table: "Tournaments",
type: "TEXT",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
name: "Start",
table: "Tournaments",
type: "TEXT",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "End",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "Start",
table: "Tournaments");
migrationBuilder.RenameColumn(
name: "Start",
table: "Events",
newName: "EventStart");
migrationBuilder.RenameColumn(
name: "End",
table: "Events",
newName: "EventEnd");
migrationBuilder.AddColumn<int>(
name: "WinnerId",
table: "Rounds",
type: "INTEGER",
nullable: true);
}
}
}
@@ -0,0 +1,321 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TournamentOrganizer;
#nullable disable
namespace TournamentOrganizer.Migrations
{
[DbContext(typeof(TournamentContext))]
[Migration("20260409083129_TeamParticipantScore")]
partial class TeamParticipantScore
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.5");
modelBuilder.Entity("TournamentOrganizer.Models.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("End")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("Start")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Events");
});
modelBuilder.Entity("TournamentOrganizer.Models.Game", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("S1RuleSet")
.HasColumnType("INTEGER");
b.Property<int?>("S2RuleSet")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Games");
});
modelBuilder.Entity("TournamentOrganizer.Models.Match", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("TournamentId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Matches");
});
modelBuilder.Entity("TournamentOrganizer.Models.Player", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("TeamId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Players");
});
modelBuilder.Entity("TournamentOrganizer.Models.PlayerParticipant", b =>
{
b.Property<int>("RoundId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerId")
.HasColumnType("INTEGER");
b.HasKey("RoundId", "PlayerId");
b.HasIndex("PlayerId");
b.ToTable("PlayerParticipants");
});
modelBuilder.Entity("TournamentOrganizer.Models.Round", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MatchId")
.HasColumnType("INTEGER");
b.Property<int>("State")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("MatchId");
b.ToTable("Rounds");
});
modelBuilder.Entity("TournamentOrganizer.Models.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Teams");
});
modelBuilder.Entity("TournamentOrganizer.Models.TeamParticipant", b =>
{
b.Property<int>("MatchId")
.HasColumnType("INTEGER");
b.Property<int>("TeamId")
.HasColumnType("INTEGER");
b.Property<int>("Score")
.HasColumnType("INTEGER");
b.Property<int>("Seed")
.HasColumnType("INTEGER");
b.HasKey("MatchId", "TeamId");
b.HasIndex("TeamId");
b.ToTable("TeamParticipants");
});
modelBuilder.Entity("TournamentOrganizer.Models.Tournament", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("End")
.HasColumnType("TEXT");
b.Property<int>("EventId")
.HasColumnType("INTEGER");
b.Property<int>("GameId")
.HasColumnType("INTEGER");
b.Property<int>("S1RuleSet")
.HasColumnType("INTEGER");
b.Property<int?>("S2RuleSet")
.HasColumnType("INTEGER");
b.Property<DateTime>("Start")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("EventId");
b.HasIndex("GameId");
b.ToTable("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Match", b =>
{
b.HasOne("TournamentOrganizer.Models.Tournament", "Tournament")
.WithMany()
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("TournamentOrganizer.Models.Player", b =>
{
b.HasOne("TournamentOrganizer.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("TournamentOrganizer.Models.PlayerParticipant", b =>
{
b.HasOne("TournamentOrganizer.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Round", "Round")
.WithMany()
.HasForeignKey("RoundId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
b.Navigation("Round");
});
modelBuilder.Entity("TournamentOrganizer.Models.Round", b =>
{
b.HasOne("TournamentOrganizer.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
});
modelBuilder.Entity("TournamentOrganizer.Models.TeamParticipant", b =>
{
b.HasOne("TournamentOrganizer.Models.Match", "Round")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Team", "Team")
.WithMany("Matches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Round");
b.Navigation("Team");
});
modelBuilder.Entity("TournamentOrganizer.Models.Tournament", b =>
{
b.HasOne("TournamentOrganizer.Models.Event", "Event")
.WithMany("Tournaments")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Game", "Game")
.WithMany("Tournaments")
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Event");
b.Navigation("Game");
});
modelBuilder.Entity("TournamentOrganizer.Models.Event", b =>
{
b.Navigation("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Game", b =>
{
b.Navigation("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Team", b =>
{
b.Navigation("Matches");
b.Navigation("Players");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TournamentOrganizer.Migrations
{
/// <inheritdoc />
public partial class TeamParticipantScore : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Score",
table: "TeamParticipants",
type: "INTEGER",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Score",
table: "TeamParticipants");
}
}
}
@@ -0,0 +1,318 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TournamentOrganizer;
#nullable disable
namespace TournamentOrganizer.Migrations
{
[DbContext(typeof(TournamentContext))]
partial class TournamentContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.5");
modelBuilder.Entity("TournamentOrganizer.Models.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("End")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("Start")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Events");
});
modelBuilder.Entity("TournamentOrganizer.Models.Game", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("S1RuleSet")
.HasColumnType("INTEGER");
b.Property<int?>("S2RuleSet")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Games");
});
modelBuilder.Entity("TournamentOrganizer.Models.Match", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("TournamentId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Matches");
});
modelBuilder.Entity("TournamentOrganizer.Models.Player", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("TeamId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Players");
});
modelBuilder.Entity("TournamentOrganizer.Models.PlayerParticipant", b =>
{
b.Property<int>("RoundId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerId")
.HasColumnType("INTEGER");
b.HasKey("RoundId", "PlayerId");
b.HasIndex("PlayerId");
b.ToTable("PlayerParticipants");
});
modelBuilder.Entity("TournamentOrganizer.Models.Round", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MatchId")
.HasColumnType("INTEGER");
b.Property<int>("State")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("MatchId");
b.ToTable("Rounds");
});
modelBuilder.Entity("TournamentOrganizer.Models.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Teams");
});
modelBuilder.Entity("TournamentOrganizer.Models.TeamParticipant", b =>
{
b.Property<int>("MatchId")
.HasColumnType("INTEGER");
b.Property<int>("TeamId")
.HasColumnType("INTEGER");
b.Property<int>("Score")
.HasColumnType("INTEGER");
b.Property<int>("Seed")
.HasColumnType("INTEGER");
b.HasKey("MatchId", "TeamId");
b.HasIndex("TeamId");
b.ToTable("TeamParticipants");
});
modelBuilder.Entity("TournamentOrganizer.Models.Tournament", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("End")
.HasColumnType("TEXT");
b.Property<int>("EventId")
.HasColumnType("INTEGER");
b.Property<int>("GameId")
.HasColumnType("INTEGER");
b.Property<int>("S1RuleSet")
.HasColumnType("INTEGER");
b.Property<int?>("S2RuleSet")
.HasColumnType("INTEGER");
b.Property<DateTime>("Start")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("EventId");
b.HasIndex("GameId");
b.ToTable("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Match", b =>
{
b.HasOne("TournamentOrganizer.Models.Tournament", "Tournament")
.WithMany()
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("TournamentOrganizer.Models.Player", b =>
{
b.HasOne("TournamentOrganizer.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("TournamentOrganizer.Models.PlayerParticipant", b =>
{
b.HasOne("TournamentOrganizer.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Round", "Round")
.WithMany()
.HasForeignKey("RoundId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
b.Navigation("Round");
});
modelBuilder.Entity("TournamentOrganizer.Models.Round", b =>
{
b.HasOne("TournamentOrganizer.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
});
modelBuilder.Entity("TournamentOrganizer.Models.TeamParticipant", b =>
{
b.HasOne("TournamentOrganizer.Models.Match", "Round")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Team", "Team")
.WithMany("Matches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Round");
b.Navigation("Team");
});
modelBuilder.Entity("TournamentOrganizer.Models.Tournament", b =>
{
b.HasOne("TournamentOrganizer.Models.Event", "Event")
.WithMany("Tournaments")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TournamentOrganizer.Models.Game", "Game")
.WithMany("Tournaments")
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Event");
b.Navigation("Game");
});
modelBuilder.Entity("TournamentOrganizer.Models.Event", b =>
{
b.Navigation("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Game", b =>
{
b.Navigation("Tournaments");
});
modelBuilder.Entity("TournamentOrganizer.Models.Team", b =>
{
b.Navigation("Matches");
b.Navigation("Players");
});
#pragma warning restore 612, 618
}
}
}
+19
View File
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TournamentOrganizer.Models;
public class Event
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; } = "Example Tournament";
public DateTime Start { get; set; }
public DateTime End { get; set; }
public required List<Tournament> Tournaments { get; set; }
}
+32
View File
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TournamentOrganizer.Models;
public enum RuleSet
{
DoubleElimination,
SingleElimination,
RoundRobin,
Swiss
}
public class Game
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; } = "Example Game";
public string Description { get; set; } = "Example Game Description";
public RuleSet S1RuleSet { get; set; }
public int S1Groups;
public int S1GroupAdvances;
public RuleSet? S2RuleSet { get; set; }
public required List<Tournament> Tournaments { get; set; }
}
+19
View File
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TournamentOrganizer.Models;
public class Match
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int TournamentId { get; set; }
public required List<TeamParticipant> Teams;
public required List<Round> Rounds;
public required Tournament Tournament { get; set; }
}
+29
View File
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace TournamentOrganizer.Models;
[PrimaryKey(nameof(RoundId), nameof(PlayerId))]
public class PlayerParticipant
{
public int RoundId { get; set; }
public int PlayerId { get; set; }
public required Player Player { get; set; }
public required Round Round { get; set; }
}
public class TeamParticipant
{
public int MatchId { get; set; }
public int TeamId { get; set; }
public int Seed { get; set; }
public int Score { get; set; }
public required Team Team { get; set; }
public required Match Round { get; set; }
}
+19
View File
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TournamentOrganizer.Models;
public class Player
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; } = "Example Tournament";
public string Contact { get; set; } = "discordname";
public int TeamId { get; set; }
public required Team Team { get; set; }
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TournamentOrganizer.Models;
public enum RoundState
{
WAITING,
STARTED,
FINISHED
}
public class Round
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int MatchId { get; set; }
public RoundState State { get; set; } = RoundState.WAITING;
public required List<PlayerParticipant> Players;
public required Match Match { get; set; }
}
+18
View File
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TournamentOrganizer.Models;
public class Team
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; } = "Example Team";
public required List<Player> Players { get; set; }
public required List<TeamParticipant> Matches { get; set; }
}
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace TournamentOrganizer.Models;
public class Tournament
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int GameId { get; set; }
public int EventId { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public RuleSet S1RuleSet { get; set; }
public int S1Groups;
public int S1GroupAdvances;
public RuleSet? S2RuleSet { get; set; }
public required Game Game { get; set; }
public required Event Event { get; set; }
}
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" />
<PackageReference Include="Avalonia.Themes.Fluent" />
<PackageReference Include="Avalonia.Fonts.Inter" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="CommunityToolkit.Mvvm" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
</ItemGroup>
</Project>
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using TournamentOrganizer.ViewModels;
namespace TournamentOrganizer;
/// <summary>
/// Given a view model, returns the corresponding view if possible.
/// </summary>
[RequiresUnreferencedCode(
"Default implementation of ViewLocator involves reflection which may be trimmed away.",
Url = "https://docs.avaloniaui.net/docs/concepts/view-locator")]
public class ViewLocator : IDataTemplate
{
public Control? Build(object? param)
{
if (param is null)
return null;
var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
return new TextBlock { Text = "Not Found: " + name };
}
public bool Match(object? data)
{
return data is ViewModelBase;
}
}
@@ -0,0 +1,9 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace TournamentOrganizer.ViewModels;
public partial class MainViewModel : ViewModelBase
{
[ObservableProperty]
private string _greeting = "Welcome to Avalonia!";
}
@@ -0,0 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace TournamentOrganizer.ViewModels;
public abstract class ViewModelBase : ObservableObject
{
}
+16
View File
@@ -0,0 +1,16 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:TournamentOrganizer.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="TournamentOrganizer.Views.MainView"
x:DataType="vm:MainViewModel">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainViewModel />
</Design.DataContext>
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</UserControl>
@@ -0,0 +1,11 @@
using Avalonia.Controls;
namespace TournamentOrganizer.Views;
public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
}
}
@@ -0,0 +1,12 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:TournamentOrganizer.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="using:TournamentOrganizer.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="TournamentOrganizer.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="TournamentOrganizer">
<views:MainView />
</Window>
@@ -0,0 +1,11 @@
using Avalonia.Controls;
namespace TournamentOrganizer.Views;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}