90 lines
2.3 KiB
C#
90 lines
2.3 KiB
C#
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
|
|
{
|
|
[Key]
|
|
public Guid Id { get; set; }
|
|
|
|
// Unique-Constraint wird via Fluent API konfiguriert
|
|
[Required]
|
|
[MaxLength(50)]
|
|
public string OrderNumber { get; set; }
|
|
|
|
[ForeignKey(nameof(Customer))]
|
|
public Guid? CustomerId { get; set; }
|
|
|
|
[MaxLength(256)]
|
|
[EmailAddress]
|
|
public string? GuestEmail { get; set; }
|
|
|
|
[MaxLength(20)]
|
|
[Phone]
|
|
public string? GuestPhoneNumber { get; set; }
|
|
|
|
[Required]
|
|
public DateTimeOffset OrderDate { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(50)]
|
|
public string OrderStatus { get; set; }
|
|
|
|
// Precision wird via Fluent API konfiguriert
|
|
[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]
|
|
[MaxLength(50)]
|
|
public string PaymentStatus { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(100)]
|
|
public string PaymentMethod { get; set; }
|
|
|
|
[ForeignKey(nameof(PaymentMethodInfo))]
|
|
public Guid? PaymentMethodId { get; set; }
|
|
|
|
[ForeignKey(nameof(ShippingMethodInfo))]
|
|
public Guid? ShippingMethodId { get; set; }
|
|
|
|
[MaxLength(255)]
|
|
public string? TransactionId { get; set; }
|
|
|
|
[Required]
|
|
[ForeignKey(nameof(BillingAddress))]
|
|
public Guid BillingAddressId { get; set; }
|
|
|
|
[Required]
|
|
[ForeignKey(nameof(ShippingAddress))]
|
|
public Guid ShippingAddressId { 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>();
|
|
} |