From 281608beeb7ab3a864a50dc16a6e1daa8bd9e68f Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 4 Apr 2023 21:58:24 -0400 Subject: [PATCH] progress, building services --- CardUtility.cs | 42 + DbContext.cs | 24 +- Entities/Player.cs | 2 +- Entities/{LayoutCard.cs => PlayerCard.cs} | 2 +- Migrations/20230405014613_initial.Designer.cs | 778 ++++++++++++++++++ Migrations/20230405014613_initial.cs | 492 +++++++++++ Migrations/DbContextModelSnapshot.cs | 775 +++++++++++++++++ Program.cs | 13 + Services/ICardService.cs | 13 + appsettings.json | 6 +- 10 files changed, 2143 insertions(+), 4 deletions(-) create mode 100644 CardUtility.cs rename Entities/{LayoutCard.cs => PlayerCard.cs} (88%) create mode 100644 Migrations/20230405014613_initial.Designer.cs create mode 100644 Migrations/20230405014613_initial.cs create mode 100644 Migrations/DbContextModelSnapshot.cs create mode 100644 Services/ICardService.cs diff --git a/CardUtility.cs b/CardUtility.cs new file mode 100644 index 0000000..0682cca --- /dev/null +++ b/CardUtility.cs @@ -0,0 +1,42 @@ +using Sequence.Entities; + +public static class CardUtility +{ + public static readonly IDictionary faceCardMap = new Dictionary + { + [11] = "J", + [12] = "Q", + [13] = "K" + }; + + public static ICollection GenerateDeck() + { + var cards = new List(); + var suits = Enum.GetValues(); + + foreach (var suit in suits) + { + for (var i = 1; i <= 10; i++) + { + cards.Add(new Card + { + Id = Guid.NewGuid(), + Suit = suit, + Value = i.ToString() + }); + } + + foreach (var faceCard in faceCardMap) + { + cards.Add(new Card + { + Id = Guid.NewGuid(), + Suit = suit, + Value = faceCard.Value + }); + } + } + + return cards; + } +} \ No newline at end of file diff --git a/DbContext.cs b/DbContext.cs index ded20d8..8236e74 100644 --- a/DbContext.cs +++ b/DbContext.cs @@ -7,7 +7,29 @@ public class DbContext : IdentityDbContext, Guid> { public DbContext(DbContextOptions options) : base(options) { } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + var deck = CardUtility.GenerateDeck(); + + var players = new Player[] + { + new Player + { + Id = Guid.NewGuid(), + + } + }; + + modelBuilder.Entity().HasData(deck); + + //modelBuilder.Entity().HasData() + } + public DbSet Deck { get; set; } - public DbSet LayoutCards { get; set; } + public DbSet PlayerCards { get; set; } + public DbSet Matches { get; set; } + public DbSet Players { get; set; } } \ No newline at end of file diff --git a/Entities/Player.cs b/Entities/Player.cs index cbaeb14..1d6a489 100644 --- a/Entities/Player.cs +++ b/Entities/Player.cs @@ -5,5 +5,5 @@ public class Player public Guid Id { get; set; } public User User { get; set; } public Hand Hand { get; set; } - public ICollection PlayedCards { get; set; } + public ICollection PlayerCards { get; set; } } \ No newline at end of file diff --git a/Entities/LayoutCard.cs b/Entities/PlayerCard.cs similarity index 88% rename from Entities/LayoutCard.cs rename to Entities/PlayerCard.cs index 7e96963..3a43751 100644 --- a/Entities/LayoutCard.cs +++ b/Entities/PlayerCard.cs @@ -1,6 +1,6 @@ namespace Sequence.Entities; -public class LayoutCard +public class PlayerCard { public Guid Id { get; set; } public Card Card { get; set; } diff --git a/Migrations/20230405014613_initial.Designer.cs b/Migrations/20230405014613_initial.Designer.cs new file mode 100644 index 0000000..904d3c0 --- /dev/null +++ b/Migrations/20230405014613_initial.Designer.cs @@ -0,0 +1,778 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Sequence.Migrations +{ + [DbContext(typeof(DbContext))] + [Migration("20230405014613_initial")] + partial class initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("varchar(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("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("ProviderKey") + .HasColumnType("varchar(255)"); + + b.Property("ProviderDisplayName") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Sequence.Entities.Card", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("HandId") + .HasColumnType("char(36)"); + + b.Property("Suit") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("HandId"); + + b.ToTable("Deck"); + + b.HasData( + new + { + Id = new Guid("3df3eb49-4286-4335-b0fd-1f22324fc8da"), + Suit = 0, + Value = "1" + }, + new + { + Id = new Guid("3ccbf18b-d428-4b3c-9816-079ed93d50e0"), + Suit = 0, + Value = "2" + }, + new + { + Id = new Guid("e182e163-badf-4455-89a4-4d5bb718359b"), + Suit = 0, + Value = "3" + }, + new + { + Id = new Guid("1f745661-7e8c-457e-8c21-af328ebea6ef"), + Suit = 0, + Value = "4" + }, + new + { + Id = new Guid("48bd12de-6e41-4618-ab60-e6a96a63672a"), + Suit = 0, + Value = "5" + }, + new + { + Id = new Guid("c0a3b138-0ad3-4384-9ec3-79e642d9972a"), + Suit = 0, + Value = "6" + }, + new + { + Id = new Guid("1cd6d866-f3d9-4006-aad1-4a1e35f43a73"), + Suit = 0, + Value = "7" + }, + new + { + Id = new Guid("4776a685-7d6e-4bf5-a44a-075ef7109a52"), + Suit = 0, + Value = "8" + }, + new + { + Id = new Guid("aec2f6dc-115b-4a67-8049-a20b2a99f9f0"), + Suit = 0, + Value = "9" + }, + new + { + Id = new Guid("f9146877-b413-4f92-aee6-f4ee93f8a164"), + Suit = 0, + Value = "10" + }, + new + { + Id = new Guid("1348276b-52f2-4708-bd38-7e3e11505271"), + Suit = 0, + Value = "J" + }, + new + { + Id = new Guid("a8c3fff6-ac16-4e73-a322-6640304f4a1d"), + Suit = 0, + Value = "Q" + }, + new + { + Id = new Guid("7a3d84d9-1ae2-49fc-83a4-4c9a9ba96f9e"), + Suit = 0, + Value = "K" + }, + new + { + Id = new Guid("774c4661-8c70-4140-aa06-b77c81cdc6c9"), + Suit = 1, + Value = "1" + }, + new + { + Id = new Guid("cb23f13e-9e01-4c07-934b-91f83fe63754"), + Suit = 1, + Value = "2" + }, + new + { + Id = new Guid("3dd48e85-61c3-458c-8197-6b320b70412f"), + Suit = 1, + Value = "3" + }, + new + { + Id = new Guid("e95f7dc6-66e1-433a-a048-bb89a287112b"), + Suit = 1, + Value = "4" + }, + new + { + Id = new Guid("775465f6-af76-4899-a4c0-87e9f87fde19"), + Suit = 1, + Value = "5" + }, + new + { + Id = new Guid("2fb260a9-5c85-4d31-bd5f-9160b108a7d6"), + Suit = 1, + Value = "6" + }, + new + { + Id = new Guid("123a0c42-19c2-4310-b557-fe9a4939c5db"), + Suit = 1, + Value = "7" + }, + new + { + Id = new Guid("5d3faa3f-2140-4a2d-837b-3089b28a8b7a"), + Suit = 1, + Value = "8" + }, + new + { + Id = new Guid("ac12f0ae-331e-4603-bfd5-0e8f39c67291"), + Suit = 1, + Value = "9" + }, + new + { + Id = new Guid("60be6c1a-9caa-4b67-b24c-ce31fe13b270"), + Suit = 1, + Value = "10" + }, + new + { + Id = new Guid("6fa3e767-f549-4fe1-aaa0-2325481bf954"), + Suit = 1, + Value = "J" + }, + new + { + Id = new Guid("8e253b6c-27a7-4505-b29d-5a75478f8344"), + Suit = 1, + Value = "Q" + }, + new + { + Id = new Guid("fa8aebfb-6450-4e23-ba5d-49201011e8cc"), + Suit = 1, + Value = "K" + }, + new + { + Id = new Guid("dc9ab320-1c25-406f-ab25-962de5a22608"), + Suit = 2, + Value = "1" + }, + new + { + Id = new Guid("92917f34-d2cc-4621-a175-d199cb4a2f99"), + Suit = 2, + Value = "2" + }, + new + { + Id = new Guid("d998e124-b28a-4fef-991a-9e135e3f61d5"), + Suit = 2, + Value = "3" + }, + new + { + Id = new Guid("df67ffb9-4a54-4d76-b0ce-3582975b78c5"), + Suit = 2, + Value = "4" + }, + new + { + Id = new Guid("4d0802db-85d1-4418-a1b7-86e87d00353f"), + Suit = 2, + Value = "5" + }, + new + { + Id = new Guid("7f7ea50b-4b9b-49b5-942f-82a5b62f6103"), + Suit = 2, + Value = "6" + }, + new + { + Id = new Guid("ff232d8b-753c-4c4a-bd03-6ce9633eceb9"), + Suit = 2, + Value = "7" + }, + new + { + Id = new Guid("0651b023-b17f-494a-88ed-ecbe2cfa7a49"), + Suit = 2, + Value = "8" + }, + new + { + Id = new Guid("83641870-bb94-45de-8542-5d55ed369319"), + Suit = 2, + Value = "9" + }, + new + { + Id = new Guid("5172a226-bc3d-4175-b5ae-c33981792ed1"), + Suit = 2, + Value = "10" + }, + new + { + Id = new Guid("676f533a-c834-4b8b-9a82-618b25249add"), + Suit = 2, + Value = "J" + }, + new + { + Id = new Guid("9f67ac4f-23eb-4b7d-baae-d8b3e4a91870"), + Suit = 2, + Value = "Q" + }, + new + { + Id = new Guid("54bd5f32-0c4f-454d-8e66-21ca14740157"), + Suit = 2, + Value = "K" + }, + new + { + Id = new Guid("a37baaf1-78f6-4cb9-a940-37d170b9c727"), + Suit = 3, + Value = "1" + }, + new + { + Id = new Guid("8c7ee0d6-da46-487c-9636-ce677fd14ba8"), + Suit = 3, + Value = "2" + }, + new + { + Id = new Guid("c2e04c69-7436-4b09-a269-8708e957af5a"), + Suit = 3, + Value = "3" + }, + new + { + Id = new Guid("c387869f-b4a9-4163-8cea-2b2c2fdeb6cc"), + Suit = 3, + Value = "4" + }, + new + { + Id = new Guid("7d07e71e-f955-4a86-ad02-71e1c2d2c888"), + Suit = 3, + Value = "5" + }, + new + { + Id = new Guid("423c23a4-f5b2-4676-9564-75714d289811"), + Suit = 3, + Value = "6" + }, + new + { + Id = new Guid("999d24a8-1aca-47cb-a45b-4f3a436f2492"), + Suit = 3, + Value = "7" + }, + new + { + Id = new Guid("b1971ee2-878a-4c6e-ae2b-606d41a34bc0"), + Suit = 3, + Value = "8" + }, + new + { + Id = new Guid("bf3353de-d18c-4857-bfef-d9dcda88d512"), + Suit = 3, + Value = "9" + }, + new + { + Id = new Guid("ae7ea808-52f1-47f6-b68b-0ab596c47282"), + Suit = 3, + Value = "10" + }, + new + { + Id = new Guid("3aa4bd47-a91e-4b18-9915-e0f149be671d"), + Suit = 3, + Value = "J" + }, + new + { + Id = new Guid("0158f904-5c80-4d15-864c-b234dd8d596c"), + Suit = 3, + Value = "Q" + }, + new + { + Id = new Guid("f2359dd3-13ee-492d-bd3e-0d53a568cd0a"), + Suit = 3, + Value = "K" + }); + }); + + modelBuilder.Entity("Sequence.Entities.Hand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Hand"); + }); + + modelBuilder.Entity("Sequence.Entities.Match", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Created") + .HasColumnType("datetime(6)"); + + b.Property("PlayerOneId") + .HasColumnType("char(36)"); + + b.Property("PlayerTwoId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("PlayerOneId"); + + b.HasIndex("PlayerTwoId"); + + b.ToTable("Matches"); + }); + + modelBuilder.Entity("Sequence.Entities.Player", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("HandId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("HandId"); + + b.HasIndex("UserId"); + + b.ToTable("Players"); + }); + + modelBuilder.Entity("Sequence.Entities.PlayerCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CardId") + .HasColumnType("char(36)"); + + b.Property("PlayerId") + .HasColumnType("char(36)"); + + b.Property("PositionX") + .HasColumnType("int"); + + b.Property("PositionY") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CardId"); + + b.HasIndex("PlayerId"); + + b.ToTable("PlayerCards"); + }); + + modelBuilder.Entity("Sequence.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("SecurityStamp") + .HasColumnType("longtext"); + + b.Property("TwoFactorEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(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.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("Sequence.Entities.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Sequence.Entities.User", 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("Sequence.Entities.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Sequence.Entities.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sequence.Entities.Card", b => + { + b.HasOne("Sequence.Entities.Hand", null) + .WithMany("Cards") + .HasForeignKey("HandId"); + }); + + modelBuilder.Entity("Sequence.Entities.Hand", b => + { + b.HasOne("Sequence.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Sequence.Entities.Match", b => + { + b.HasOne("Sequence.Entities.Player", "PlayerOne") + .WithMany() + .HasForeignKey("PlayerOneId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sequence.Entities.Player", "PlayerTwo") + .WithMany() + .HasForeignKey("PlayerTwoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PlayerOne"); + + b.Navigation("PlayerTwo"); + }); + + modelBuilder.Entity("Sequence.Entities.Player", b => + { + b.HasOne("Sequence.Entities.Hand", "Hand") + .WithMany() + .HasForeignKey("HandId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sequence.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Hand"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Sequence.Entities.PlayerCard", b => + { + b.HasOne("Sequence.Entities.Card", "Card") + .WithMany() + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sequence.Entities.Player", null) + .WithMany("PlayerCards") + .HasForeignKey("PlayerId"); + + b.Navigation("Card"); + }); + + modelBuilder.Entity("Sequence.Entities.Hand", b => + { + b.Navigation("Cards"); + }); + + modelBuilder.Entity("Sequence.Entities.Player", b => + { + b.Navigation("PlayerCards"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20230405014613_initial.cs b/Migrations/20230405014613_initial.cs new file mode 100644 index 0000000..f8492f3 --- /dev/null +++ b/Migrations/20230405014613_initial.cs @@ -0,0 +1,492 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace Sequence.Migrations +{ + /// + public partial class initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AspNetRoles", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + NormalizedName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoles", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AspNetUsers", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + NormalizedUserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Email = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + NormalizedEmail = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + EmailConfirmed = table.Column(type: "tinyint(1)", nullable: false), + PasswordHash = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SecurityStamp = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PhoneNumber = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PhoneNumberConfirmed = table.Column(type: "tinyint(1)", nullable: false), + TwoFactorEnabled = table.Column(type: "tinyint(1)", nullable: false), + LockoutEnd = table.Column(type: "datetime(6)", nullable: true), + LockoutEnabled = table.Column(type: "tinyint(1)", nullable: false), + AccessFailedCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUsers", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AspNetRoleClaims", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + RoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ClaimType = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClaimValue = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AspNetUserClaims", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ClaimType = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClaimValue = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetUserClaims_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AspNetUserLogins", + columns: table => new + { + LoginProvider = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderKey = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProviderDisplayName = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_AspNetUserLogins_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AspNetUserRoles", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + RoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AspNetUserTokens", + columns: table => new + { + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + LoginProvider = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AspNetUserTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "Hand", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_Hand", x => x.Id); + table.ForeignKey( + name: "FK_Hand_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "Deck", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Suit = table.Column(type: "int", nullable: false), + Value = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + HandId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_Deck", x => x.Id); + table.ForeignKey( + name: "FK_Deck_Hand_HandId", + column: x => x.HandId, + principalTable: "Hand", + principalColumn: "Id"); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "Players", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + HandId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_Players", x => x.Id); + table.ForeignKey( + name: "FK_Players_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Players_Hand_HandId", + column: x => x.HandId, + principalTable: "Hand", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "Matches", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Created = table.Column(type: "datetime(6)", nullable: false), + PlayerOneId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + PlayerTwoId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_Matches", x => x.Id); + table.ForeignKey( + name: "FK_Matches_Players_PlayerOneId", + column: x => x.PlayerOneId, + principalTable: "Players", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Matches_Players_PlayerTwoId", + column: x => x.PlayerTwoId, + principalTable: "Players", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "PlayerCards", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CardId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + PositionX = table.Column(type: "int", nullable: false), + PositionY = table.Column(type: "int", nullable: false), + PlayerId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_PlayerCards", x => x.Id); + table.ForeignKey( + name: "FK_PlayerCards_Deck_CardId", + column: x => x.CardId, + principalTable: "Deck", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PlayerCards_Players_PlayerId", + column: x => x.PlayerId, + principalTable: "Players", + principalColumn: "Id"); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.InsertData( + table: "Deck", + columns: new[] { "Id", "HandId", "Suit", "Value" }, + values: new object[,] + { + { new Guid("0158f904-5c80-4d15-864c-b234dd8d596c"), null, 3, "Q" }, + { new Guid("0651b023-b17f-494a-88ed-ecbe2cfa7a49"), null, 2, "8" }, + { new Guid("123a0c42-19c2-4310-b557-fe9a4939c5db"), null, 1, "7" }, + { new Guid("1348276b-52f2-4708-bd38-7e3e11505271"), null, 0, "J" }, + { new Guid("1cd6d866-f3d9-4006-aad1-4a1e35f43a73"), null, 0, "7" }, + { new Guid("1f745661-7e8c-457e-8c21-af328ebea6ef"), null, 0, "4" }, + { new Guid("2fb260a9-5c85-4d31-bd5f-9160b108a7d6"), null, 1, "6" }, + { new Guid("3aa4bd47-a91e-4b18-9915-e0f149be671d"), null, 3, "J" }, + { new Guid("3ccbf18b-d428-4b3c-9816-079ed93d50e0"), null, 0, "2" }, + { new Guid("3dd48e85-61c3-458c-8197-6b320b70412f"), null, 1, "3" }, + { new Guid("3df3eb49-4286-4335-b0fd-1f22324fc8da"), null, 0, "1" }, + { new Guid("423c23a4-f5b2-4676-9564-75714d289811"), null, 3, "6" }, + { new Guid("4776a685-7d6e-4bf5-a44a-075ef7109a52"), null, 0, "8" }, + { new Guid("48bd12de-6e41-4618-ab60-e6a96a63672a"), null, 0, "5" }, + { new Guid("4d0802db-85d1-4418-a1b7-86e87d00353f"), null, 2, "5" }, + { new Guid("5172a226-bc3d-4175-b5ae-c33981792ed1"), null, 2, "10" }, + { new Guid("54bd5f32-0c4f-454d-8e66-21ca14740157"), null, 2, "K" }, + { new Guid("5d3faa3f-2140-4a2d-837b-3089b28a8b7a"), null, 1, "8" }, + { new Guid("60be6c1a-9caa-4b67-b24c-ce31fe13b270"), null, 1, "10" }, + { new Guid("676f533a-c834-4b8b-9a82-618b25249add"), null, 2, "J" }, + { new Guid("6fa3e767-f549-4fe1-aaa0-2325481bf954"), null, 1, "J" }, + { new Guid("774c4661-8c70-4140-aa06-b77c81cdc6c9"), null, 1, "1" }, + { new Guid("775465f6-af76-4899-a4c0-87e9f87fde19"), null, 1, "5" }, + { new Guid("7a3d84d9-1ae2-49fc-83a4-4c9a9ba96f9e"), null, 0, "K" }, + { new Guid("7d07e71e-f955-4a86-ad02-71e1c2d2c888"), null, 3, "5" }, + { new Guid("7f7ea50b-4b9b-49b5-942f-82a5b62f6103"), null, 2, "6" }, + { new Guid("83641870-bb94-45de-8542-5d55ed369319"), null, 2, "9" }, + { new Guid("8c7ee0d6-da46-487c-9636-ce677fd14ba8"), null, 3, "2" }, + { new Guid("8e253b6c-27a7-4505-b29d-5a75478f8344"), null, 1, "Q" }, + { new Guid("92917f34-d2cc-4621-a175-d199cb4a2f99"), null, 2, "2" }, + { new Guid("999d24a8-1aca-47cb-a45b-4f3a436f2492"), null, 3, "7" }, + { new Guid("9f67ac4f-23eb-4b7d-baae-d8b3e4a91870"), null, 2, "Q" }, + { new Guid("a37baaf1-78f6-4cb9-a940-37d170b9c727"), null, 3, "1" }, + { new Guid("a8c3fff6-ac16-4e73-a322-6640304f4a1d"), null, 0, "Q" }, + { new Guid("ac12f0ae-331e-4603-bfd5-0e8f39c67291"), null, 1, "9" }, + { new Guid("ae7ea808-52f1-47f6-b68b-0ab596c47282"), null, 3, "10" }, + { new Guid("aec2f6dc-115b-4a67-8049-a20b2a99f9f0"), null, 0, "9" }, + { new Guid("b1971ee2-878a-4c6e-ae2b-606d41a34bc0"), null, 3, "8" }, + { new Guid("bf3353de-d18c-4857-bfef-d9dcda88d512"), null, 3, "9" }, + { new Guid("c0a3b138-0ad3-4384-9ec3-79e642d9972a"), null, 0, "6" }, + { new Guid("c2e04c69-7436-4b09-a269-8708e957af5a"), null, 3, "3" }, + { new Guid("c387869f-b4a9-4163-8cea-2b2c2fdeb6cc"), null, 3, "4" }, + { new Guid("cb23f13e-9e01-4c07-934b-91f83fe63754"), null, 1, "2" }, + { new Guid("d998e124-b28a-4fef-991a-9e135e3f61d5"), null, 2, "3" }, + { new Guid("dc9ab320-1c25-406f-ab25-962de5a22608"), null, 2, "1" }, + { new Guid("df67ffb9-4a54-4d76-b0ce-3582975b78c5"), null, 2, "4" }, + { new Guid("e182e163-badf-4455-89a4-4d5bb718359b"), null, 0, "3" }, + { new Guid("e95f7dc6-66e1-433a-a048-bb89a287112b"), null, 1, "4" }, + { new Guid("f2359dd3-13ee-492d-bd3e-0d53a568cd0a"), null, 3, "K" }, + { new Guid("f9146877-b413-4f92-aee6-f4ee93f8a164"), null, 0, "10" }, + { new Guid("fa8aebfb-6450-4e23-ba5d-49201011e8cc"), null, 1, "K" }, + { new Guid("ff232d8b-753c-4c4a-bd03-6ce9633eceb9"), null, 2, "7" } + }); + + migrationBuilder.CreateIndex( + name: "IX_AspNetRoleClaims_RoleId", + table: "AspNetRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "AspNetRoles", + column: "NormalizedName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserClaims_UserId", + table: "AspNetUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserLogins_UserId", + table: "AspNetUserLogins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserRoles_RoleId", + table: "AspNetUserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + table: "AspNetUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + table: "AspNetUsers", + column: "NormalizedUserName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Deck_HandId", + table: "Deck", + column: "HandId"); + + migrationBuilder.CreateIndex( + name: "IX_Hand_UserId", + table: "Hand", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Matches_PlayerOneId", + table: "Matches", + column: "PlayerOneId"); + + migrationBuilder.CreateIndex( + name: "IX_Matches_PlayerTwoId", + table: "Matches", + column: "PlayerTwoId"); + + migrationBuilder.CreateIndex( + name: "IX_PlayerCards_CardId", + table: "PlayerCards", + column: "CardId"); + + migrationBuilder.CreateIndex( + name: "IX_PlayerCards_PlayerId", + table: "PlayerCards", + column: "PlayerId"); + + migrationBuilder.CreateIndex( + name: "IX_Players_HandId", + table: "Players", + column: "HandId"); + + migrationBuilder.CreateIndex( + name: "IX_Players_UserId", + table: "Players", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AspNetRoleClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserLogins"); + + migrationBuilder.DropTable( + name: "AspNetUserRoles"); + + migrationBuilder.DropTable( + name: "AspNetUserTokens"); + + migrationBuilder.DropTable( + name: "Matches"); + + migrationBuilder.DropTable( + name: "PlayerCards"); + + migrationBuilder.DropTable( + name: "AspNetRoles"); + + migrationBuilder.DropTable( + name: "Deck"); + + migrationBuilder.DropTable( + name: "Players"); + + migrationBuilder.DropTable( + name: "Hand"); + + migrationBuilder.DropTable( + name: "AspNetUsers"); + } + } +} diff --git a/Migrations/DbContextModelSnapshot.cs b/Migrations/DbContextModelSnapshot.cs new file mode 100644 index 0000000..9cf05dd --- /dev/null +++ b/Migrations/DbContextModelSnapshot.cs @@ -0,0 +1,775 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Sequence.Migrations +{ + [DbContext(typeof(DbContext))] + partial class DbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("varchar(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("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("ProviderKey") + .HasColumnType("varchar(255)"); + + b.Property("ProviderDisplayName") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Sequence.Entities.Card", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("HandId") + .HasColumnType("char(36)"); + + b.Property("Suit") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("HandId"); + + b.ToTable("Deck"); + + b.HasData( + new + { + Id = new Guid("3df3eb49-4286-4335-b0fd-1f22324fc8da"), + Suit = 0, + Value = "1" + }, + new + { + Id = new Guid("3ccbf18b-d428-4b3c-9816-079ed93d50e0"), + Suit = 0, + Value = "2" + }, + new + { + Id = new Guid("e182e163-badf-4455-89a4-4d5bb718359b"), + Suit = 0, + Value = "3" + }, + new + { + Id = new Guid("1f745661-7e8c-457e-8c21-af328ebea6ef"), + Suit = 0, + Value = "4" + }, + new + { + Id = new Guid("48bd12de-6e41-4618-ab60-e6a96a63672a"), + Suit = 0, + Value = "5" + }, + new + { + Id = new Guid("c0a3b138-0ad3-4384-9ec3-79e642d9972a"), + Suit = 0, + Value = "6" + }, + new + { + Id = new Guid("1cd6d866-f3d9-4006-aad1-4a1e35f43a73"), + Suit = 0, + Value = "7" + }, + new + { + Id = new Guid("4776a685-7d6e-4bf5-a44a-075ef7109a52"), + Suit = 0, + Value = "8" + }, + new + { + Id = new Guid("aec2f6dc-115b-4a67-8049-a20b2a99f9f0"), + Suit = 0, + Value = "9" + }, + new + { + Id = new Guid("f9146877-b413-4f92-aee6-f4ee93f8a164"), + Suit = 0, + Value = "10" + }, + new + { + Id = new Guid("1348276b-52f2-4708-bd38-7e3e11505271"), + Suit = 0, + Value = "J" + }, + new + { + Id = new Guid("a8c3fff6-ac16-4e73-a322-6640304f4a1d"), + Suit = 0, + Value = "Q" + }, + new + { + Id = new Guid("7a3d84d9-1ae2-49fc-83a4-4c9a9ba96f9e"), + Suit = 0, + Value = "K" + }, + new + { + Id = new Guid("774c4661-8c70-4140-aa06-b77c81cdc6c9"), + Suit = 1, + Value = "1" + }, + new + { + Id = new Guid("cb23f13e-9e01-4c07-934b-91f83fe63754"), + Suit = 1, + Value = "2" + }, + new + { + Id = new Guid("3dd48e85-61c3-458c-8197-6b320b70412f"), + Suit = 1, + Value = "3" + }, + new + { + Id = new Guid("e95f7dc6-66e1-433a-a048-bb89a287112b"), + Suit = 1, + Value = "4" + }, + new + { + Id = new Guid("775465f6-af76-4899-a4c0-87e9f87fde19"), + Suit = 1, + Value = "5" + }, + new + { + Id = new Guid("2fb260a9-5c85-4d31-bd5f-9160b108a7d6"), + Suit = 1, + Value = "6" + }, + new + { + Id = new Guid("123a0c42-19c2-4310-b557-fe9a4939c5db"), + Suit = 1, + Value = "7" + }, + new + { + Id = new Guid("5d3faa3f-2140-4a2d-837b-3089b28a8b7a"), + Suit = 1, + Value = "8" + }, + new + { + Id = new Guid("ac12f0ae-331e-4603-bfd5-0e8f39c67291"), + Suit = 1, + Value = "9" + }, + new + { + Id = new Guid("60be6c1a-9caa-4b67-b24c-ce31fe13b270"), + Suit = 1, + Value = "10" + }, + new + { + Id = new Guid("6fa3e767-f549-4fe1-aaa0-2325481bf954"), + Suit = 1, + Value = "J" + }, + new + { + Id = new Guid("8e253b6c-27a7-4505-b29d-5a75478f8344"), + Suit = 1, + Value = "Q" + }, + new + { + Id = new Guid("fa8aebfb-6450-4e23-ba5d-49201011e8cc"), + Suit = 1, + Value = "K" + }, + new + { + Id = new Guid("dc9ab320-1c25-406f-ab25-962de5a22608"), + Suit = 2, + Value = "1" + }, + new + { + Id = new Guid("92917f34-d2cc-4621-a175-d199cb4a2f99"), + Suit = 2, + Value = "2" + }, + new + { + Id = new Guid("d998e124-b28a-4fef-991a-9e135e3f61d5"), + Suit = 2, + Value = "3" + }, + new + { + Id = new Guid("df67ffb9-4a54-4d76-b0ce-3582975b78c5"), + Suit = 2, + Value = "4" + }, + new + { + Id = new Guid("4d0802db-85d1-4418-a1b7-86e87d00353f"), + Suit = 2, + Value = "5" + }, + new + { + Id = new Guid("7f7ea50b-4b9b-49b5-942f-82a5b62f6103"), + Suit = 2, + Value = "6" + }, + new + { + Id = new Guid("ff232d8b-753c-4c4a-bd03-6ce9633eceb9"), + Suit = 2, + Value = "7" + }, + new + { + Id = new Guid("0651b023-b17f-494a-88ed-ecbe2cfa7a49"), + Suit = 2, + Value = "8" + }, + new + { + Id = new Guid("83641870-bb94-45de-8542-5d55ed369319"), + Suit = 2, + Value = "9" + }, + new + { + Id = new Guid("5172a226-bc3d-4175-b5ae-c33981792ed1"), + Suit = 2, + Value = "10" + }, + new + { + Id = new Guid("676f533a-c834-4b8b-9a82-618b25249add"), + Suit = 2, + Value = "J" + }, + new + { + Id = new Guid("9f67ac4f-23eb-4b7d-baae-d8b3e4a91870"), + Suit = 2, + Value = "Q" + }, + new + { + Id = new Guid("54bd5f32-0c4f-454d-8e66-21ca14740157"), + Suit = 2, + Value = "K" + }, + new + { + Id = new Guid("a37baaf1-78f6-4cb9-a940-37d170b9c727"), + Suit = 3, + Value = "1" + }, + new + { + Id = new Guid("8c7ee0d6-da46-487c-9636-ce677fd14ba8"), + Suit = 3, + Value = "2" + }, + new + { + Id = new Guid("c2e04c69-7436-4b09-a269-8708e957af5a"), + Suit = 3, + Value = "3" + }, + new + { + Id = new Guid("c387869f-b4a9-4163-8cea-2b2c2fdeb6cc"), + Suit = 3, + Value = "4" + }, + new + { + Id = new Guid("7d07e71e-f955-4a86-ad02-71e1c2d2c888"), + Suit = 3, + Value = "5" + }, + new + { + Id = new Guid("423c23a4-f5b2-4676-9564-75714d289811"), + Suit = 3, + Value = "6" + }, + new + { + Id = new Guid("999d24a8-1aca-47cb-a45b-4f3a436f2492"), + Suit = 3, + Value = "7" + }, + new + { + Id = new Guid("b1971ee2-878a-4c6e-ae2b-606d41a34bc0"), + Suit = 3, + Value = "8" + }, + new + { + Id = new Guid("bf3353de-d18c-4857-bfef-d9dcda88d512"), + Suit = 3, + Value = "9" + }, + new + { + Id = new Guid("ae7ea808-52f1-47f6-b68b-0ab596c47282"), + Suit = 3, + Value = "10" + }, + new + { + Id = new Guid("3aa4bd47-a91e-4b18-9915-e0f149be671d"), + Suit = 3, + Value = "J" + }, + new + { + Id = new Guid("0158f904-5c80-4d15-864c-b234dd8d596c"), + Suit = 3, + Value = "Q" + }, + new + { + Id = new Guid("f2359dd3-13ee-492d-bd3e-0d53a568cd0a"), + Suit = 3, + Value = "K" + }); + }); + + modelBuilder.Entity("Sequence.Entities.Hand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Hand"); + }); + + modelBuilder.Entity("Sequence.Entities.Match", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Created") + .HasColumnType("datetime(6)"); + + b.Property("PlayerOneId") + .HasColumnType("char(36)"); + + b.Property("PlayerTwoId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("PlayerOneId"); + + b.HasIndex("PlayerTwoId"); + + b.ToTable("Matches"); + }); + + modelBuilder.Entity("Sequence.Entities.Player", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("HandId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("HandId"); + + b.HasIndex("UserId"); + + b.ToTable("Players"); + }); + + modelBuilder.Entity("Sequence.Entities.PlayerCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CardId") + .HasColumnType("char(36)"); + + b.Property("PlayerId") + .HasColumnType("char(36)"); + + b.Property("PositionX") + .HasColumnType("int"); + + b.Property("PositionY") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CardId"); + + b.HasIndex("PlayerId"); + + b.ToTable("PlayerCards"); + }); + + modelBuilder.Entity("Sequence.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("SecurityStamp") + .HasColumnType("longtext"); + + b.Property("TwoFactorEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(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.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("Sequence.Entities.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Sequence.Entities.User", 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("Sequence.Entities.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Sequence.Entities.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sequence.Entities.Card", b => + { + b.HasOne("Sequence.Entities.Hand", null) + .WithMany("Cards") + .HasForeignKey("HandId"); + }); + + modelBuilder.Entity("Sequence.Entities.Hand", b => + { + b.HasOne("Sequence.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Sequence.Entities.Match", b => + { + b.HasOne("Sequence.Entities.Player", "PlayerOne") + .WithMany() + .HasForeignKey("PlayerOneId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sequence.Entities.Player", "PlayerTwo") + .WithMany() + .HasForeignKey("PlayerTwoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PlayerOne"); + + b.Navigation("PlayerTwo"); + }); + + modelBuilder.Entity("Sequence.Entities.Player", b => + { + b.HasOne("Sequence.Entities.Hand", "Hand") + .WithMany() + .HasForeignKey("HandId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sequence.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Hand"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Sequence.Entities.PlayerCard", b => + { + b.HasOne("Sequence.Entities.Card", "Card") + .WithMany() + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sequence.Entities.Player", null) + .WithMany("PlayerCards") + .HasForeignKey("PlayerId"); + + b.Navigation("Card"); + }); + + modelBuilder.Entity("Sequence.Entities.Hand", b => + { + b.Navigation("Cards"); + }); + + modelBuilder.Entity("Sequence.Entities.Player", b => + { + b.Navigation("PlayerCards"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Program.cs b/Program.cs index 0727468..0f3585f 100644 --- a/Program.cs +++ b/Program.cs @@ -1,8 +1,21 @@ +using Microsoft.EntityFrameworkCore; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); +builder.Services.AddDbContext((services, options) => +{ + var configuration = services.GetService(); + + var version = new MySqlServerVersion(new Version(10, 6)); + var connectionString = configuration.GetConnectionString("MariaDB"); + + options.UseMySql(connectionString, version); +}); + + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/Services/ICardService.cs b/Services/ICardService.cs new file mode 100644 index 0000000..0e61162 --- /dev/null +++ b/Services/ICardService.cs @@ -0,0 +1,13 @@ +using Sequence.Entities; + +namespace Sequence.Services; + +public interface ICardService +{ + ICollection GetCards(); +} + +public interface IUserService +{ + Task CreateUserAsync(string username, string password); +} \ No newline at end of file diff --git a/appsettings.json b/appsettings.json index 10f68b8..930a709 100644 --- a/appsettings.json +++ b/appsettings.json @@ -5,5 +5,9 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "ConnectionStrings": { + "MariaDB": "server=mariadb.binarydad.com;uid=root;pwd=rex30638;database=sequence" + } + }