diff --git a/Web-Jarmark/Web-Jarmark/Components/Layout/NavMenu.razor b/Web-Jarmark/Web-Jarmark/Components/Layout/NavMenu.razor
index ce1b454..7f1a868 100644
--- a/Web-Jarmark/Web-Jarmark/Components/Layout/NavMenu.razor
+++ b/Web-Jarmark/Web-Jarmark/Components/Layout/NavMenu.razor
@@ -25,8 +25,8 @@
-
- Detail vyrobku
+
+ FF
diff --git a/Web-Jarmark/Web-Jarmark/Data/ApplicationDbContext.cs b/Web-Jarmark/Web-Jarmark/Data/ApplicationDbContext.cs
index 1385807..be1a1e6 100644
--- a/Web-Jarmark/Web-Jarmark/Data/ApplicationDbContext.cs
+++ b/Web-Jarmark/Web-Jarmark/Data/ApplicationDbContext.cs
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
+using Web_Jarmark.Data;
+using Web_Jarmark.Data.Models;
namespace Web_Jarmark.Data
{
@@ -7,3 +9,19 @@ namespace Web_Jarmark.Data
{
}
}
+public class ApplicationDbContext(DbContextOptions options) : IdentityDbContext(options)
+{
+ public DbSet Categories { get; set; }
+ public DbSet Products { get; set; }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+
+ // Nastavení vazby 1:N mezi Category a Product
+ modelBuilder.Entity()
+ .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
+ }
+}
\ No newline at end of file
diff --git a/Web-Jarmark/Web-Jarmark/Data/Models/Category.cs b/Web-Jarmark/Web-Jarmark/Data/Models/Category.cs
new file mode 100644
index 0000000..02c8d06
--- /dev/null
+++ b/Web-Jarmark/Web-Jarmark/Data/Models/Category.cs
@@ -0,0 +1,15 @@
+using Microsoft.CodeAnalysis;
+
+namespace Web_Jarmark.Data.Models
+{
+ public class Category
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public string Slug { get; set; }
+ public bool IsActive { get; set; }
+
+ // Navigační vlastnost pro produkty
+ public ICollection Products { get; set; } = new List();
+ }
+}
diff --git a/Web-Jarmark/Web-Jarmark/Data/Models/Order.cs b/Web-Jarmark/Web-Jarmark/Data/Models/Order.cs
new file mode 100644
index 0000000..0a284c5
--- /dev/null
+++ b/Web-Jarmark/Web-Jarmark/Data/Models/Order.cs
@@ -0,0 +1,41 @@
+namespace Web_Jarmark.Data.Models
+{
+ public enum OrderStatus
+ {
+ Pending,
+ Paid,
+ Shipped,
+ Delivered,
+ Cancelled
+ }
+ public enum PaymentMethod
+ {
+ CreditCard,
+ PayPal,
+ BankTransfer,
+ Cash
+ }
+
+ public class Order
+ {
+ public int Id { get; set; }
+ public string Code { get; set; }
+ public OrderStatus Status { get; set; }
+ public string CustomerName { get; set; }
+ public string Email { get; set; }
+ public string Phone { get; set; }
+ public string Note { get; set; }
+ public PaymentMethod PreferredPayment { get; set; }
+ public string PaymentReference { get; set; }
+ public decimal TotalAmount { get; set; }
+ public DateTime CreatedAt { get; set; }
+ public DateTime? ExpiresAt { get; set; }
+ public DateTime? PaidAt { get; set; }
+ public DateTime? IssuedAt { get; set; }
+ public string IssuedByUserId { get; set; }
+ public DateTime? CancelledAt { get; set; }
+
+ // Navigační vlastnost pro objednávací položky
+ public ICollection OrderItems { get; set; } = new List();
+ }
+}
diff --git a/Web-Jarmark/Web-Jarmark/Data/Models/OrderItem.cs b/Web-Jarmark/Web-Jarmark/Data/Models/OrderItem.cs
new file mode 100644
index 0000000..0e9786e
--- /dev/null
+++ b/Web-Jarmark/Web-Jarmark/Data/Models/OrderItem.cs
@@ -0,0 +1,16 @@
+namespace Web_Jarmark.Data.Models
+{
+ public class OrderItem
+ {
+ public int Id { get; set; }
+ public int OrderId { get; set; }
+ public int ProductId { get; set; }
+ public string ProductName { get; set; }
+ public decimal UnitPrice { get; set; }
+ public int Quantity { get; set; }
+
+ // Navigační vlastnosti pro objednávku a produkt
+ public Order Order { get; set; }
+ public Product Product { get; set; }
+ }
+}
diff --git a/Web-Jarmark/Web-Jarmark/Data/Models/Product.cs b/Web-Jarmark/Web-Jarmark/Data/Models/Product.cs
new file mode 100644
index 0000000..60b148e
--- /dev/null
+++ b/Web-Jarmark/Web-Jarmark/Data/Models/Product.cs
@@ -0,0 +1,19 @@
+namespace Web_Jarmark.Data.Models
+{
+ public class Product
+ {
+ public int Id { get; set; }
+ public int CategoryId { get; set; }
+ public string Name { get; set; }
+ public string Description { get; set; }
+ public decimal Price { get; set; }
+ public int StockQuantity { get; set; }
+ public string ImageUrl { get; set; }
+ public bool IsVisible { get; set; }
+ public DateTime UpdatedAt { get; set; }
+
+ // Navigační vlastnosti pro kategorii a objednávky
+ public Category Category { get; set; }
+ public ICollection OrderItems { get; set; } = new List();
+ }
+}
diff --git a/Web-Jarmark/Web-Jarmark/Web-Jarmark.csproj b/Web-Jarmark/Web-Jarmark/Web-Jarmark.csproj
index e85e926..13beeb4 100644
--- a/Web-Jarmark/Web-Jarmark/Web-Jarmark.csproj
+++ b/Web-Jarmark/Web-Jarmark/Web-Jarmark.csproj
@@ -1,4 +1,4 @@
-
+
net10.0