From aedfaa45a69feb1c1dca9057f1dd87db77eee834 Mon Sep 17 00:00:00 2001 From: maja Date: Fri, 30 Oct 2026 15:25:31 +0100 Subject: [PATCH] databaze kosik --- .../Web-Jarmark/Data/ApplicationDbContext.cs | 25 +- Web-Jarmark/Web-Jarmark/Data/Models/Cart.cs | 18 + .../Web-Jarmark/Data/Models/CartItem.cs | 19 + .../20261030142312_261030_kosik.Designer.cs | 615 ++++++++++++++++++ .../Migrations/20261030142312_261030_kosik.cs | 84 +++ .../ApplicationDbContextModelSnapshot.cs | 73 +++ Web-Jarmark/Web-Jarmark/jarmark.db | Bin 147456 -> 172032 bytes Web-Jarmark/Web-Jarmark/jarmark.db-shm | Bin 0 -> 32768 bytes Web-Jarmark/Web-Jarmark/jarmark.db-wal | 0 9 files changed, 833 insertions(+), 1 deletion(-) create mode 100644 Web-Jarmark/Web-Jarmark/Data/Models/Cart.cs create mode 100644 Web-Jarmark/Web-Jarmark/Data/Models/CartItem.cs create mode 100644 Web-Jarmark/Web-Jarmark/Migrations/20261030142312_261030_kosik.Designer.cs create mode 100644 Web-Jarmark/Web-Jarmark/Migrations/20261030142312_261030_kosik.cs create mode 100644 Web-Jarmark/Web-Jarmark/jarmark.db-shm create mode 100644 Web-Jarmark/Web-Jarmark/jarmark.db-wal diff --git a/Web-Jarmark/Web-Jarmark/Data/ApplicationDbContext.cs b/Web-Jarmark/Web-Jarmark/Data/ApplicationDbContext.cs index e2532a8..5218ec8 100644 --- a/Web-Jarmark/Web-Jarmark/Data/ApplicationDbContext.cs +++ b/Web-Jarmark/Web-Jarmark/Data/ApplicationDbContext.cs @@ -9,7 +9,8 @@ namespace Web_Jarmark.Data { public DbSet Categories { get; set; } public DbSet Products { get; set; } - + public DbSet Carts { get; set; } + public DbSet CartItems { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -19,6 +20,28 @@ namespace Web_Jarmark.Data .HasMany(c => c.Products) // Jedna kategorie obsahuje mnoho produktů .WithOne(p => p.Category) // Každý produkt patří ke jedné kategorii .HasForeignKey(p => p.CategoryId); // Cizí klíč v tabulce Product + + // Jeden košík obsahuje více položek + modelBuilder.Entity() + .HasMany(c => c.CartItems) + .WithOne(ci => ci.Cart) + .HasForeignKey(ci => ci.CartId); + + // Každá položka odkazuje na jeden produkt + modelBuilder.Entity() + .HasOne(ci => ci.Product) + .WithMany() + .HasForeignKey(ci => ci.ProductId); + + // Jeden produkt může být v košíku pouze jednou + modelBuilder.Entity() + .HasIndex(ci => new { ci.CartId, ci.ProductId }) + .IsUnique(); + + // Token košíku musí být unikátní + modelBuilder.Entity() + .HasIndex(c => c.Token) + .IsUnique(); } } diff --git a/Web-Jarmark/Web-Jarmark/Data/Models/Cart.cs b/Web-Jarmark/Web-Jarmark/Data/Models/Cart.cs new file mode 100644 index 0000000..0c8ed3c --- /dev/null +++ b/Web-Jarmark/Web-Jarmark/Data/Models/Cart.cs @@ -0,0 +1,18 @@ + +namespace Web_Jarmark.Data.Models +{ + public class Cart + { + public int Id { get; set; } + + // Unikátní identifikátor návštěvníka v prohlížeči + public string Token { get; set; } = Guid.NewGuid().ToString(); + + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + + public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; + + // Navigační vlastnost pro položky košíku + public ICollection CartItems { get; set; } = new List(); + } +} diff --git a/Web-Jarmark/Web-Jarmark/Data/Models/CartItem.cs b/Web-Jarmark/Web-Jarmark/Data/Models/CartItem.cs new file mode 100644 index 0000000..eaffff3 --- /dev/null +++ b/Web-Jarmark/Web-Jarmark/Data/Models/CartItem.cs @@ -0,0 +1,19 @@ + +namespace Web_Jarmark.Data.Models +{ + public class CartItem + { + public int Id { get; set; } + + public int CartId { get; set; } + + public int ProductId { get; set; } + + public int Quantity { get; set; } = 1; + + // Navigační vlastnosti + public Cart Cart { get; set; } = null!; + + public Product Product { get; set; } = null!; + } +} diff --git a/Web-Jarmark/Web-Jarmark/Migrations/20261030142312_261030_kosik.Designer.cs b/Web-Jarmark/Web-Jarmark/Migrations/20261030142312_261030_kosik.Designer.cs new file mode 100644 index 0000000..e294ffb --- /dev/null +++ b/Web-Jarmark/Web-Jarmark/Migrations/20261030142312_261030_kosik.Designer.cs @@ -0,0 +1,615 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Web_Jarmark.Data; + +#nullable disable + +namespace Web_Jarmark.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20261030142312_261030_kosik")] + partial class _261030_kosik + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "10.0.13"); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + 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"); + + 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"); + + 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") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasMaxLength(128) + .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.IdentityUserPasskey", b => + { + b.Property("CredentialId") + .HasMaxLength(1024) + .HasColumnType("BLOB"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("CredentialId"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserPasskeys", (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") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Web_Jarmark.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("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Token") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Token") + .IsUnique(); + + b.ToTable("Carts"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CartId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("CartId", "ProductId") + .IsUnique(); + + b.ToTable("CartItems"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Slug") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CancelledAt") + .HasColumnType("TEXT"); + + b.Property("Code") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CustomerName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ExpiresAt") + .HasColumnType("TEXT"); + + b.Property("IssuedAt") + .HasColumnType("TEXT"); + + b.Property("IssuedByUserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Note") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PaidAt") + .HasColumnType("TEXT"); + + b.Property("PaymentReference") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PreferredPayment") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("TotalAmount") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("INTEGER"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("OrderItem"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CategoryId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ImageUrl") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("IsVisible") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.Property("StockQuantity") + .HasColumnType("INTEGER"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products"); + }); + + 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("Web_Jarmark.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Web_Jarmark.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserPasskey", b => + { + b.HasOne("Web_Jarmark.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Microsoft.AspNetCore.Identity.IdentityPasskeyData", "Data", b1 => + { + b1.Property("IdentityUserPasskeyCredentialId"); + + b1.Property("AttestationObject") + .IsRequired(); + + b1.Property("ClientDataJson") + .IsRequired(); + + b1.Property("CreatedAt"); + + b1.Property("IsBackedUp"); + + b1.Property("IsBackupEligible"); + + b1.Property("IsUserVerified"); + + b1.Property("Name"); + + b1.Property("PublicKey") + .IsRequired(); + + b1.Property("SignCount"); + + b1.PrimitiveCollection("Transports"); + + b1.HasKey("IdentityUserPasskeyCredentialId"); + + b1.ToTable("AspNetUserPasskeys"); + + b1 + .ToJson("Data") + .HasColumnType("TEXT"); + + b1.WithOwner() + .HasForeignKey("IdentityUserPasskeyCredentialId"); + }); + + b.Navigation("Data") + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Web_Jarmark.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Web_Jarmark.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b => + { + b.HasOne("Web_Jarmark.Data.Models.Cart", "Cart") + .WithMany("CartItems") + .HasForeignKey("CartId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Web_Jarmark.Data.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cart"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b => + { + b.HasOne("Web_Jarmark.Data.Models.Order", "Order") + .WithMany("OrderItems") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Web_Jarmark.Data.Models.Product", "Product") + .WithMany("OrderItems") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b => + { + b.HasOne("Web_Jarmark.Data.Models.Category", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b => + { + b.Navigation("CartItems"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.Order", b => + { + b.Navigation("OrderItems"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b => + { + b.Navigation("OrderItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Web-Jarmark/Web-Jarmark/Migrations/20261030142312_261030_kosik.cs b/Web-Jarmark/Web-Jarmark/Migrations/20261030142312_261030_kosik.cs new file mode 100644 index 0000000..dee898a --- /dev/null +++ b/Web-Jarmark/Web-Jarmark/Migrations/20261030142312_261030_kosik.cs @@ -0,0 +1,84 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Web_Jarmark.Migrations +{ + /// + public partial class _261030_kosik : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Carts", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Token = table.Column(type: "TEXT", nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + UpdatedAt = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Carts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CartItems", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + CartId = table.Column(type: "INTEGER", nullable: false), + ProductId = table.Column(type: "INTEGER", nullable: false), + Quantity = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CartItems", x => x.Id); + table.ForeignKey( + name: "FK_CartItems_Carts_CartId", + column: x => x.CartId, + principalTable: "Carts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CartItems_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_CartId_ProductId", + table: "CartItems", + columns: new[] { "CartId", "ProductId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_CartItems_ProductId", + table: "CartItems", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_Carts_Token", + table: "Carts", + column: "Token", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CartItems"); + + migrationBuilder.DropTable( + name: "Carts"); + } + } +} diff --git a/Web-Jarmark/Web-Jarmark/Migrations/ApplicationDbContextModelSnapshot.cs b/Web-Jarmark/Web-Jarmark/Migrations/ApplicationDbContextModelSnapshot.cs index 173169a..e0e1f4f 100644 --- a/Web-Jarmark/Web-Jarmark/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Web-Jarmark/Web-Jarmark/Migrations/ApplicationDbContextModelSnapshot.cs @@ -231,6 +231,55 @@ namespace Web_Jarmark.Migrations b.ToTable("AspNetUsers", (string)null); }); + modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Token") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Token") + .IsUnique(); + + b.ToTable("Carts"); + }); + + modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CartId") + .HasColumnType("INTEGER"); + + b.Property("ProductId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("CartId", "ProductId") + .IsUnique(); + + b.ToTable("CartItems"); + }); + modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b => { b.Property("Id") @@ -489,6 +538,25 @@ namespace Web_Jarmark.Migrations .IsRequired(); }); + modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b => + { + b.HasOne("Web_Jarmark.Data.Models.Cart", "Cart") + .WithMany("CartItems") + .HasForeignKey("CartId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Web_Jarmark.Data.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cart"); + + b.Navigation("Product"); + }); + modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b => { b.HasOne("Web_Jarmark.Data.Models.Order", "Order") @@ -519,6 +587,11 @@ namespace Web_Jarmark.Migrations b.Navigation("Category"); }); + modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b => + { + b.Navigation("CartItems"); + }); + modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b => { b.Navigation("Products"); diff --git a/Web-Jarmark/Web-Jarmark/jarmark.db b/Web-Jarmark/Web-Jarmark/jarmark.db index abcf3030da5c07c299872b95c72664f24bebd2ce..eb0456a99fa304b1c3353896e841b55f58b45ded 100644 GIT binary patch delta 1086 zcmb_aPfXKL81GxVmX$P*C16P)t|@MLyV2%PBc zbbC6zK9}IX?)P-~t_VV>ATS7n!+8wu!4){4w^u!fEloHs)wuS?`n+TVi8N!_%pIO$Sr*JO zsj&x-64KaoDrqcDQbZ0!WiA@%4#^y^$Fu_ph&Tdhs{znpjjEH0Dea&e__TOGsKpuD zS@_fiKG-al!@^+@6fMMD1X9||AQ;ar*edfM!8pim5i+3jpzD`od7!HNzFPr{%Wt_? zqeLxDsu=UFa!1!o&)VKo+mxT&CRH?JEOtMZEq$j50iD$}4%+MM$q!_<#rtIOc zGB_-AO8AyM!ttkpJl7vCb(G|}R^CYFol{K|>vw<|`^nNuD)BfO8<FnSb+sd)E)l{EW@p*$o(f^Xqgm2r)cj;PU2J#gWPWl)aqo zGh06EW7ZT_CYA}z%NPTB-*cblPUQN?@QBfKvY^10?VgT|t2mh$(x<=jWlY}wF^h@c ObWwl+1TEXZH~|2n;ynxi diff --git a/Web-Jarmark/Web-Jarmark/jarmark.db-shm b/Web-Jarmark/Web-Jarmark/jarmark.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10 GIT binary patch literal 32768 zcmeIuAr62r3