This commit is contained in:
Tizian.Breuch
2025-07-23 21:08:30 +02:00
parent d20a6d6ae6
commit ce69373adb
85 changed files with 2311 additions and 332 deletions

View File

@@ -1,12 +1,15 @@
// src/Webshop.Application/Services/Admin/AdminSupplierService.cs
using Webshop.Application.DTOs; // SupplierDto
// Auto-generiert von CreateWebshopFiles.ps1
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Webshop.Application.DTOs;
using Webshop.Domain.Entities;
using Webshop.Domain.Interfaces;
using System.Collections.Generic; // Für IEnumerable
namespace Webshop.Application.Services.Admin
{
public class AdminSupplierService
public class AdminSupplierService : IAdminSupplierService
{
private readonly ISupplierRepository _supplierRepository;
@@ -15,54 +18,10 @@ namespace Webshop.Application.Services.Admin
_supplierRepository = supplierRepository;
}
public async Task<IEnumerable<SupplierDto>> GetAllSuppliersAsync()
{
var suppliers = await _supplierRepository.GetAllSuppliersAsync();
return suppliers.Select(s => new SupplierDto
{
Id = s.Id,
Name = s.Name,
ContactPerson = s.ContactPerson,
Email = s.Email,
PhoneNumber = s.PhoneNumber,
AddressId = s.AddressId,
Notes = s.Notes
}).ToList();
}
public async Task<SupplierDto?> GetSupplierByIdAsync(Guid id)
{
var supplier = await _supplierRepository.GetSupplierByIdAsync(id);
if (supplier == null) return null;
return new SupplierDto
{
Id = supplier.Id,
Name = supplier.Name,
ContactPerson = supplier.ContactPerson,
Email = supplier.Email,
PhoneNumber = supplier.PhoneNumber,
AddressId = supplier.AddressId,
Notes = supplier.Notes
};
}
public async Task<SupplierDto> CreateSupplierAsync(SupplierDto supplierDto)
{
var newSupplier = new Supplier
{
Id = Guid.NewGuid(), // API generiert die ID
Name = supplierDto.Name,
ContactPerson = supplierDto.ContactPerson,
Email = supplierDto.Email,
PhoneNumber = supplierDto.PhoneNumber,
AddressId = supplierDto.AddressId,
Notes = supplierDto.Notes
};
await _supplierRepository.AddSupplierAsync(newSupplier);
supplierDto.Id = newSupplier.Id; // ID zurückschreiben
return supplierDto;
}
// TODO: UpdateSupplierAsync, DeleteSupplierAsync
// HIER KOMMT DER VORHERIGE ADMINSUPPLIERSERVICE CODE HIN (GetAllSuppliersAsync, CreateSupplierAsync etc.)
// Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen:
public async Task<IEnumerable<SupplierDto>> GetAllSuppliersAsync() { return new List<SupplierDto>(); }
public async Task<SupplierDto?> GetSupplierByIdAsync(Guid id) { return null; }
public async Task<SupplierDto> CreateSupplierAsync(SupplierDto supplierDto) { return null; }
}
}
}