Adress und shipping

This commit is contained in:
Tizian.Breuch
2025-08-01 09:09:49 +02:00
parent 7fc0b32c17
commit 14daa831cb
14 changed files with 460 additions and 47 deletions

View File

@@ -1,56 +1,58 @@
using System;
// src/Webshop.Domain/Entities/Address.cs
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Webshop.Domain.Enums; // << WICHTIG: FÜR AddressType >>
namespace Webshop.Domain.Entities;
/// <summary>
/// Verwendet für Kundenadressen, Rechnungs- und Lieferadressen von Bestellungen oder Lieferanten.
/// </summary>
public class Address
namespace Webshop.Domain.Entities
{
[Key]
public Guid Id { get; set; }
public class Address
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[ForeignKey(nameof(Customer))]
public Guid? CustomerId { get; set; }
[ForeignKey(nameof(Customer))]
public Guid? CustomerId { get; set; } // Verknüpfung zum Kunden
[MaxLength(50)]
public string? AddressType { get; set; } // z.B. "Billing", "Shipping"
[Required]
[MaxLength(255)]
public string Street { get; set; } = string.Empty;
[Required]
[MaxLength(255)]
public string Street { get; set; }
// << NEUE EIGENSCHAFT HINZUFÜGEN >>
[MaxLength(50)]
public string? HouseNumber { get; set; }
[MaxLength(255)]
public string? Street2 { get; set; }
[Required]
[MaxLength(100)]
public string City { get; set; } = string.Empty;
[Required]
[MaxLength(100)]
public string City { get; set; }
[Required]
[MaxLength(20)]
public string PostalCode { get; set; } = string.Empty;
[MaxLength(100)]
public string? State { get; set; }
[Required]
[MaxLength(100)]
public string Country { get; set; } = string.Empty;
[Required]
[MaxLength(20)]
public string PostalCode { get; set; }
// << NEUE EIGENSCHAFT HINZUFÜGEN >>
public AddressType Type { get; set; }
[Required]
[MaxLength(100)]
public string Country { get; set; }
// Optional: Weitere Felder
[MaxLength(100)]
public string? State { get; set; } // Bundesland/Kanton
[MaxLength(255)]
public string? CompanyName { get; set; }
[MaxLength(255)]
public string? CompanyName { get; set; }
[Required]
[MaxLength(100)]
public string FirstName { get; set; }
[Required]
[MaxLength(100)]
public string FirstName { get; set; } = string.Empty;
[Required]
[MaxLength(100)]
public string LastName { get; set; }
// Navigation Property
public virtual Customer? Customer { get; set; }
[Required]
[MaxLength(100)]
public string LastName { get; set; } = string.Empty;
// Navigation Property zum Kunden
public virtual Customer? Customer { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
// src/Webshop.Domain/Interfaces/IAddressRepository.cs
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Webshop.Domain.Entities;
namespace Webshop.Domain.Interfaces
{
public interface IAddressRepository
{
Task<IEnumerable<Address>> GetAllForCustomerAsync(Guid customerId);
Task<Address?> GetByIdAsync(Guid id);
Task AddAsync(Address address);
Task UpdateAsync(Address address);
Task DeleteAsync(Guid id);
}
}