migration
This commit is contained in:
22
Webshop.Domain/Entities/Cart.cs
Normal file
22
Webshop.Domain/Entities/Cart.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Webshop.Domain.Entities
|
||||
{
|
||||
public class Cart
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
// Verknüpfung zum User (String, da Identity User Id ein String ist)
|
||||
public string? UserId { get; set; }
|
||||
|
||||
// Falls du auch Gast-Warenkörbe ohne Login unterstützt:
|
||||
public string? SessionId { get; set; }
|
||||
|
||||
public DateTime LastModified { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public virtual ICollection<CartItem> Items { get; set; } = new List<CartItem>();
|
||||
}
|
||||
}
|
||||
26
Webshop.Domain/Entities/CartItem.cs
Normal file
26
Webshop.Domain/Entities/CartItem.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Webshop.Domain.Entities
|
||||
{
|
||||
public class CartItem
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid CartId { get; set; }
|
||||
|
||||
[ForeignKey("CartId")]
|
||||
public virtual Cart Cart { get; set; } = default!;
|
||||
|
||||
public Guid ProductId { get; set; }
|
||||
|
||||
[ForeignKey("ProductId")]
|
||||
public virtual Product Product { get; set; } = default!;
|
||||
|
||||
public Guid? ProductVariantId { get; set; } // Optional, falls du Varianten nutzt
|
||||
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user