using System.Threading.Tasks; using Webshop.Application.DTOs.Customers; using Webshop.Application.Services.Customers.Interfaces; using Webshop.Domain.Interfaces; // Wichtig für ICustomerRepository namespace Webshop.Application.Services.Customers { public class CustomerService : ICustomerService { private readonly ICustomerRepository _customerRepository; public CustomerService(ICustomerRepository customerRepository) { _customerRepository = customerRepository; } public async Task GetMyProfileAsync(string userId) { var customer = await _customerRepository.GetByUserIdAsync(userId); if (customer == null) { return null; } // Mappe die Entity auf das CustomerDto return new CustomerDto { Id = customer.Id, UserId = customer.AspNetUserId, FirstName = customer.FirstName, LastName = customer.LastName, // Fügen Sie hier weitere Felder hinzu, die der Kunde sehen soll (Email, Phone etc.) }; } public async Task UpdateMyProfileAsync(string userId, UpdateCustomerProfileDto profileDto) { var customer = await _customerRepository.GetByUserIdAsync(userId); if (customer == null) { return false; // Kunde nicht gefunden } // Aktualisiere die Felder customer.FirstName = profileDto.FirstName; customer.LastName = profileDto.LastName; await _customerRepository.UpdateAsync(customer); return true; } } }