order by id fix

This commit is contained in:
Tizian.Breuch
2025-08-01 14:56:40 +02:00
parent 587990295d
commit 96f082b38f
5 changed files with 64 additions and 35 deletions

View File

@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Webshop.Application.DTOs.Customers;
using Webshop.Application.DTOs.Orders;
using Webshop.Domain.Enums; // Wichtig für Enum-Konvertierung
using Webshop.Domain.Interfaces;
@@ -45,13 +46,32 @@ namespace Webshop.Application.Services.Admin
OrderNumber = order.OrderNumber,
OrderDate = order.OrderDate,
CustomerId = order.CustomerId,
// << KORREKTUR: String zu Enum parsen >>
Status = Enum.TryParse<OrderStatus>(order.OrderStatus, true, out var orderStatus) ? orderStatus : OrderStatus.Pending,
TotalAmount = order.OrderTotal,
ShippingAddress = order.ShippingAddress, // Annahme: Address DTO Mapping
BillingAddress = order.BillingAddress, // Annahme: Address DTO Mapping
// << KORREKTUR: Manuelles Mapping von Address-Entität zu AddressDto >>
ShippingAddress = new AddressDto
{
Id = order.ShippingAddress.Id,
Street = order.ShippingAddress.Street,
HouseNumber = order.ShippingAddress.HouseNumber,
City = order.ShippingAddress.City,
PostalCode = order.ShippingAddress.PostalCode,
Country = order.ShippingAddress.Country,
Type = order.ShippingAddress.Type
},
BillingAddress = new AddressDto
{
Id = order.BillingAddress.Id,
Street = order.BillingAddress.Street,
HouseNumber = order.BillingAddress.HouseNumber,
City = order.BillingAddress.City,
PostalCode = order.BillingAddress.PostalCode,
Country = order.BillingAddress.Country,
Type = order.BillingAddress.Type
},
PaymentMethod = order.PaymentMethod,
// << KORREKTUR: String zu Enum parsen >>
PaymentStatus = Enum.TryParse<PaymentStatus>(order.PaymentStatus, true, out var paymentStatus) ? paymentStatus : PaymentStatus.Pending,
OrderItems = order.OrderItems.Select(oi => new OrderItemDto
{