From 16275e3cd527071e54228c97faeedaf4f0e72428 Mon Sep 17 00:00:00 2001 From: mcmuzzle Date: Tue, 10 Sep 2024 22:56:32 +0200 Subject: [PATCH] ajout d'un premier test pour l'affichage des jeux --- .gitea/workflows/merge.yaml | 4 - src/LudikZone.model/LudikZone.model.csproj | 13 + src/LudikZone.model/Src/Game.cs | 20 ++ src/LudikZone.sln | 6 + .../Components/Games/GameIcon.razor | 10 + .../Components/Pages/Games.razor | 19 +- .../Data/ApplicationDbContext.cs | 3 +- src/LudikZoneBlazor/Data/Model/Game.cs | 11 - src/LudikZoneBlazor/LudikZoneBlazor.csproj | 5 + .../20240910202256_AjoutGames.Designer.cs | 300 ++++++++++++++++++ .../Migrations/20240910202256_AjoutGames.cs | 37 +++ .../ApplicationDbContextModelSnapshot.cs | 23 ++ 12 files changed, 427 insertions(+), 24 deletions(-) create mode 100644 src/LudikZone.model/LudikZone.model.csproj create mode 100644 src/LudikZone.model/Src/Game.cs create mode 100644 src/LudikZoneBlazor/Components/Games/GameIcon.razor delete mode 100644 src/LudikZoneBlazor/Data/Model/Game.cs create mode 100644 src/LudikZoneBlazor/Migrations/20240910202256_AjoutGames.Designer.cs create mode 100644 src/LudikZoneBlazor/Migrations/20240910202256_AjoutGames.cs diff --git a/.gitea/workflows/merge.yaml b/.gitea/workflows/merge.yaml index 9d6e170..fc9958c 100644 --- a/.gitea/workflows/merge.yaml +++ b/.gitea/workflows/merge.yaml @@ -1,14 +1,10 @@ name: "Generation data pour merge sur master" on: - push: - branches: ["main"] pull_request: types: - closed branches: ["main"] - release: - types: [published] jobs: generateData: diff --git a/src/LudikZone.model/LudikZone.model.csproj b/src/LudikZone.model/LudikZone.model.csproj new file mode 100644 index 0000000..2fcf98b --- /dev/null +++ b/src/LudikZone.model/LudikZone.model.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + true + true + true + All + + + diff --git a/src/LudikZone.model/Src/Game.cs b/src/LudikZone.model/Src/Game.cs new file mode 100644 index 0000000..01fa2c7 --- /dev/null +++ b/src/LudikZone.model/Src/Game.cs @@ -0,0 +1,20 @@ +namespace LudikZone.model; + +/// +/// Informations relative a un jeu précis +/// +public class Game +{ + + /// Identifiant unique d'un jeu + public int Id { get; init; } + + /// le nom du jeu + public required string Name { get; init; } + + /// Le nombre minimum de joueur pour une partie + public int MinPlayerCount { get; init; } + + /// Le nombre maximum de joueur pour une partie + public int MaxPlayerCount { get; init; } +} \ No newline at end of file diff --git a/src/LudikZone.sln b/src/LudikZone.sln index 0950581..735ceeb 100644 --- a/src/LudikZone.sln +++ b/src/LudikZone.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LudikZoneBlazor", "LudikZoneBlazor\LudikZoneBlazor.csproj", "{79AF398A-0AC3-425C-BA51-B6CFBEECAC28}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LudikZone.model", "LudikZone.model\LudikZone.model.csproj", "{C50658FF-0EE9-4EE8-AAA3-FAF4B9F622EA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -18,5 +20,9 @@ Global {79AF398A-0AC3-425C-BA51-B6CFBEECAC28}.Debug|Any CPU.Build.0 = Debug|Any CPU {79AF398A-0AC3-425C-BA51-B6CFBEECAC28}.Release|Any CPU.ActiveCfg = Release|Any CPU {79AF398A-0AC3-425C-BA51-B6CFBEECAC28}.Release|Any CPU.Build.0 = Release|Any CPU + {C50658FF-0EE9-4EE8-AAA3-FAF4B9F622EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C50658FF-0EE9-4EE8-AAA3-FAF4B9F622EA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C50658FF-0EE9-4EE8-AAA3-FAF4B9F622EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C50658FF-0EE9-4EE8-AAA3-FAF4B9F622EA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/LudikZoneBlazor/Components/Games/GameIcon.razor b/src/LudikZoneBlazor/Components/Games/GameIcon.razor new file mode 100644 index 0000000..74a42dc --- /dev/null +++ b/src/LudikZoneBlazor/Components/Games/GameIcon.razor @@ -0,0 +1,10 @@ +@using LudikZone.model + + + @Game.Name + + +@code { + [Parameter] + public required Game Game { get; set; } +} \ No newline at end of file diff --git a/src/LudikZoneBlazor/Components/Pages/Games.razor b/src/LudikZoneBlazor/Components/Pages/Games.razor index cb56a59..27a8310 100644 --- a/src/LudikZoneBlazor/Components/Pages/Games.razor +++ b/src/LudikZoneBlazor/Components/Pages/Games.razor @@ -1,28 +1,31 @@ @page "/games" +@using LudikZoneBlazor.Components.Games +@using LudikZoneBlazor.Data @using Microsoft.AspNetCore.Authorization -@using LudikZoneBlazor.Data.Model - -@attribute [Authorize] +@using LudikZone.model @inject IStringLocalizer localizer +@inject ApplicationDbContext context @localizer["Games"] @localizer["Game list"] - + @foreach (var g in GetGames()) { - + + + } - + @code { private List GetGames() { - return new List(); + return context.Games.ToList(); } -} +} \ No newline at end of file diff --git a/src/LudikZoneBlazor/Data/ApplicationDbContext.cs b/src/LudikZoneBlazor/Data/ApplicationDbContext.cs index 60a9042..06163a3 100644 --- a/src/LudikZoneBlazor/Data/ApplicationDbContext.cs +++ b/src/LudikZoneBlazor/Data/ApplicationDbContext.cs @@ -1,7 +1,8 @@ -using LudikZoneBlazor.Data.Model; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; +using LudikZone.model; + namespace LudikZoneBlazor.Data; /// diff --git a/src/LudikZoneBlazor/Data/Model/Game.cs b/src/LudikZoneBlazor/Data/Model/Game.cs deleted file mode 100644 index 15479bf..0000000 --- a/src/LudikZoneBlazor/Data/Model/Game.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace LudikZoneBlazor.Data.Model; - -/// -/// Informations relative a un jeu précis -/// -public class Game -{ - - /// Identifiant unique d'un jeu - public int Id { get; init; } -} \ No newline at end of file diff --git a/src/LudikZoneBlazor/LudikZoneBlazor.csproj b/src/LudikZoneBlazor/LudikZoneBlazor.csproj index 898045d..be13958 100644 --- a/src/LudikZoneBlazor/LudikZoneBlazor.csproj +++ b/src/LudikZoneBlazor/LudikZoneBlazor.csproj @@ -22,4 +22,9 @@ + + + + + diff --git a/src/LudikZoneBlazor/Migrations/20240910202256_AjoutGames.Designer.cs b/src/LudikZoneBlazor/Migrations/20240910202256_AjoutGames.Designer.cs new file mode 100644 index 0000000..f8b2519 --- /dev/null +++ b/src/LudikZoneBlazor/Migrations/20240910202256_AjoutGames.Designer.cs @@ -0,0 +1,300 @@ +// +using System; +using LudikZoneBlazor.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LudikZoneBlazor.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240910202256_AjoutGames")] + partial class AjoutGames + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LudikZone.model.Game", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("MaxPlayerCount") + .HasColumnType("integer"); + + b.Property("MinPlayerCount") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Games"); + }); + + modelBuilder.Entity("LudikZoneBlazor.Data.ApplicationUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("LudikZoneBlazor.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("LudikZoneBlazor.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LudikZoneBlazor.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("LudikZoneBlazor.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/LudikZoneBlazor/Migrations/20240910202256_AjoutGames.cs b/src/LudikZoneBlazor/Migrations/20240910202256_AjoutGames.cs new file mode 100644 index 0000000..83b39d3 --- /dev/null +++ b/src/LudikZoneBlazor/Migrations/20240910202256_AjoutGames.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LudikZoneBlazor.Migrations +{ + /// + public partial class AjoutGames : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Games", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + MinPlayerCount = table.Column(type: "integer", nullable: false), + MaxPlayerCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Games", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Games"); + } + } +} diff --git a/src/LudikZoneBlazor/Migrations/ApplicationDbContextModelSnapshot.cs b/src/LudikZoneBlazor/Migrations/ApplicationDbContextModelSnapshot.cs index 087db82..cf2ab2a 100644 --- a/src/LudikZoneBlazor/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/LudikZoneBlazor/Migrations/ApplicationDbContextModelSnapshot.cs @@ -22,6 +22,29 @@ namespace LudikZoneBlazor.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("LudikZone.model.Game", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("MaxPlayerCount") + .HasColumnType("integer"); + + b.Property("MinPlayerCount") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Games"); + }); + modelBuilder.Entity("LudikZoneBlazor.Data.ApplicationUser", b => { b.Property("Id")