This commit is contained in:
Tizian.Breuch
2025-07-31 16:12:48 +02:00
parent 4a24f4559d
commit 2d93fda7e9
10 changed files with 264 additions and 104 deletions

View File

@@ -1,90 +1,91 @@
using System;
// src/Webshop.Domain/Entities/Order.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Webshop.Domain.Entities;
/// <summary>
/// Die Details jeder Kundenbestellung, inklusive Gastbestellungen.
/// </summary>
public class Order
namespace Webshop.Domain.Entities
{
[Key]
public Guid Id { get; set; }
public class Order
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
// Unique-Constraint wird via Fluent API konfiguriert
[Required]
[MaxLength(50)]
public string OrderNumber { get; set; }
[Required]
[MaxLength(50)]
public string OrderNumber { get; set; } = string.Empty;
[ForeignKey(nameof(Customer))]
public Guid? CustomerId { get; set; }
[ForeignKey(nameof(Customer))]
public Guid? CustomerId { get; set; }
[MaxLength(256)]
[EmailAddress]
public string? GuestEmail { get; set; }
[MaxLength(256)]
[EmailAddress]
public string? GuestEmail { get; set; }
[MaxLength(20)]
[Phone]
public string? GuestPhoneNumber { get; set; }
[MaxLength(20)]
[Phone]
public string? GuestPhoneNumber { get; set; }
[Required]
public DateTimeOffset OrderDate { get; set; }
[Required]
public DateTimeOffset OrderDate { get; set; } = DateTimeOffset.UtcNow;
[Required]
[MaxLength(50)]
public string OrderStatus { get; set; }
[Required]
[MaxLength(50)]
public string OrderStatus { get; set; } = string.Empty;
// Precision wird via Fluent API konfiguriert
[Required]
public decimal OrderTotal { get; set; }
[Required]
public decimal OrderTotal { get; set; }
[Required]
public decimal ShippingCost { get; set; }
[Required]
public decimal TaxAmount { get; set; }
[Required]
public decimal DiscountAmount { get; set; }
[Required]
public decimal ShippingCost { get; set; }
[Required]
[MaxLength(50)]
public string PaymentStatus { get; set; } = string.Empty;
[Required]
public decimal TaxAmount { get; set; }
[Required]
[MaxLength(100)]
public string PaymentMethod { get; set; } = string.Empty;
[Required]
public decimal DiscountAmount { get; set; }
[ForeignKey(nameof(PaymentMethodInfo))]
public Guid? PaymentMethodId { get; set; }
[Required]
[MaxLength(50)]
public string PaymentStatus { get; set; }
[ForeignKey(nameof(ShippingMethodInfo))]
public Guid? ShippingMethodId { get; set; }
[Required]
[MaxLength(100)]
public string PaymentMethod { get; set; }
[MaxLength(255)]
public string? TransactionId { get; set; }
[ForeignKey(nameof(PaymentMethodInfo))]
public Guid? PaymentMethodId { get; set; }
// << NEUE FELDER HINZUFÜGEN >>
[MaxLength(255)]
public string? ShippingTrackingNumber { get; set; }
public DateTimeOffset? ShippedDate { get; set; }
public DateTimeOffset? DeliveredDate { get; set; }
// << ENDE NEUE FELDER >>
[ForeignKey(nameof(ShippingMethodInfo))]
public Guid? ShippingMethodId { get; set; }
[Required]
[ForeignKey(nameof(BillingAddress))]
public Guid BillingAddressId { get; set; }
[MaxLength(255)]
public string? TransactionId { get; set; }
[Required]
[ForeignKey(nameof(ShippingAddress))]
public Guid ShippingAddressId { get; set; }
[Required]
[ForeignKey(nameof(BillingAddress))]
public Guid BillingAddressId { get; set; }
[MaxLength(1000)]
public string? CustomerNotes { get; set; }
[Required]
[ForeignKey(nameof(ShippingAddress))]
public Guid ShippingAddressId { get; set; }
[MaxLength(1000)]
public string? AdminNotes { get; set; }
[MaxLength(1000)]
public string? CustomerNotes { get; set; }
[MaxLength(1000)]
public string? AdminNotes { get; set; }
// Navigation Properties
public virtual Customer? Customer { get; set; }
public virtual Address BillingAddress { get; set; }
public virtual Address ShippingAddress { get; set; }
public virtual PaymentMethod? PaymentMethodInfo { get; set; }
public virtual ShippingMethod? ShippingMethodInfo { get; set; }
public virtual ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
// Navigation Properties
public virtual Customer? Customer { get; set; }
public virtual Address BillingAddress { get; set; } = default!;
public virtual Address ShippingAddress { get; set; } = default!;
public virtual PaymentMethod? PaymentMethodInfo { get; set; }
public virtual ShippingMethod? ShippingMethodInfo { get; set; }
public virtual ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
}
}

View File

@@ -1,14 +1,17 @@
// Auto-generiert von CreateWebshopFiles.ps1
// src/Webshop.Domain/Interfaces/IOrderRepository.cs
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Webshop.Domain.Entities;
namespace Webshop.Domain.Interfaces
{
public interface IOrderRepository
{
// Fügen Sie hier Methodensignaturen hinzu
Task<IEnumerable<Order>> GetAllAsync();
Task<Order?> GetByIdAsync(Guid id);
Task AddAsync(Order order);
Task UpdateAsync(Order order);
Task DeleteAsync(Guid id);
}
}
}