try
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Webshop.Domain.Entities
|
||||
{
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
public DateTimeOffset CreatedDate { get; set; }
|
||||
public DateTimeOffset? LastActive { get; set; }
|
||||
public virtual Customer Customer { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,40 @@
|
||||
using System;
|
||||
|
||||
// src/Webshop.Domain/Entities/Customer.cs
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Collections.Generic;
|
||||
using Webshop.Domain.Identity; // Für ApplicationUser
|
||||
|
||||
namespace Webshop.Domain.Entities
|
||||
{
|
||||
public class Customer
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
[Required]
|
||||
public string AspNetUserId { get; set; }
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string FirstName { get; set; }
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string LastName { get; set; }
|
||||
public Guid Id { get; set; } = Guid.NewGuid(); // Default-Wert setzen
|
||||
|
||||
public virtual ApplicationUser User { get; set; }
|
||||
[Required]
|
||||
public string AspNetUserId { get; set; } // Fremdschlüssel zu ApplicationUser.Id
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
// << ENTFERNT: Email ist auf ApplicationUser >>
|
||||
// << ENTFERNT: PhoneNumber ist auf ApplicationUser >>
|
||||
// << ENTFERNT: CreatedDate ist auf ApplicationUser >>
|
||||
|
||||
public Guid? DefaultShippingAddressId { get; set; } // Fremdschlüssel zur Standardversandadresse
|
||||
public Guid? DefaultBillingAddressId { get; set; } // Fremdschlüssel zur Standardrechnungsadresse
|
||||
|
||||
// Navigation Property zum ApplicationUser
|
||||
public virtual ApplicationUser User { get; set; } = default!; // Muss auf ApplicationUser verweisen
|
||||
|
||||
// Navigation Properties zu Collections
|
||||
public virtual ICollection<Address> Addresses { get; set; } = new List<Address>();
|
||||
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
|
||||
public virtual ICollection<Review> Reviews { get; set; } = new List<Review>();
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Webshop.Domain/Identity/ApplicationUser.cs
Normal file
16
Webshop.Domain/Identity/ApplicationUser.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
// src/Webshop.Domain/Identity/ApplicationUser.cs
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System;
|
||||
|
||||
namespace Webshop.Domain.Identity // KORREKTER NAMESPACE
|
||||
{
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.UtcNow; // Setzt Standardwert
|
||||
public DateTimeOffset? LastActive { get; set; }
|
||||
|
||||
// Navigation Property zur Customer-Entität (One-to-One)
|
||||
// Customer ist nullable, falls nicht jeder ApplicationUser ein Customer-Profil hat
|
||||
public virtual Entities.Customer? Customer { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
// src/Webshop.Domain/Interfaces/ICustomerRepository.cs
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Domain.Entities;
|
||||
|
||||
@@ -6,7 +7,12 @@ namespace Webshop.Domain.Interfaces
|
||||
{
|
||||
public interface ICustomerRepository
|
||||
{
|
||||
Task<Customer?> GetByUserIdAsync(string userId);
|
||||
Task UpdateAsync(Customer customer);
|
||||
Task<IEnumerable<Customer>> GetAllAsync(); // Standard CRUD
|
||||
Task<Customer?> GetByIdAsync(Guid id); // Standard CRUD
|
||||
Task AddAsync(Customer entity); // Standard CRUD
|
||||
Task UpdateAsync(Customer entity); // Standard CRUD
|
||||
Task DeleteAsync(Guid id); // Standard CRUD
|
||||
|
||||
Task<Customer?> GetByUserIdAsync(string userId); // << DIESE METHODE IST NEU UND WICHTIG >>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user