fix
All checks were successful
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Successful in 25s
All checks were successful
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Successful in 25s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Webshop.Application.DTOs.Shipping; // Oder wo CartItemDto liegt
|
||||
using Webshop.Application.DTOs.Shipping; // Wichtig für CartItemDto
|
||||
|
||||
namespace Webshop.Application.DTOs.Customers
|
||||
{
|
||||
@@ -9,6 +9,8 @@ namespace Webshop.Application.DTOs.Customers
|
||||
public Guid Id { get; set; }
|
||||
public string UserId { get; set; } = string.Empty;
|
||||
public List<CartItemDto> Items { get; set; } = new List<CartItemDto>();
|
||||
public decimal TotalEstimatedPrice { get; set; } // Optional: Summe berechnet
|
||||
|
||||
// Optional: Gesamtsumme zur Anzeige im Frontend
|
||||
public decimal TotalPrice { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application;
|
||||
using Webshop.Application.DTOs.Customers;
|
||||
using Webshop.Application.DTOs.Shipping;
|
||||
using Webshop.Application.DTOs.Customers; // <--- DIESE ZEILE HAT GEFEHLT (für CartDto)
|
||||
using Webshop.Application.DTOs.Shipping; // (für CartItemDto)
|
||||
using Webshop.Application.Services.Customers.Interfaces;
|
||||
using Webshop.Domain.Entities;
|
||||
using Webshop.Infrastructure.Data;
|
||||
@@ -20,10 +20,16 @@ namespace Webshop.Application.Services.Customers
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// Die Implementierung muss exakt so aussehen:
|
||||
public async Task<ServiceResult<CartDto>> GetCartAsync(string userId)
|
||||
{
|
||||
var cart = await GetCartEntity(userId);
|
||||
if (cart == null) return ServiceResult.Ok(new CartDto()); // Leerer Warenkorb
|
||||
|
||||
// Wenn kein Warenkorb da ist, geben wir einen leeren zurück (Success)
|
||||
if (cart == null)
|
||||
{
|
||||
return ServiceResult.Ok(new CartDto { UserId = userId });
|
||||
}
|
||||
|
||||
var dto = new CartDto
|
||||
{
|
||||
@@ -36,6 +42,7 @@ namespace Webshop.Application.Services.Customers
|
||||
Quantity = i.Quantity
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return ServiceResult.Ok(dto);
|
||||
}
|
||||
|
||||
@@ -63,7 +70,8 @@ namespace Webshop.Application.Services.Customers
|
||||
ProductVariantId = itemDto.ProductVariantId,
|
||||
Quantity = itemDto.Quantity
|
||||
};
|
||||
cart.Items.Add(newItem); // Wichtig: Muss in CartItems DbSet landen
|
||||
// WICHTIG: Zur Collection hinzufügen UND dem Context Bescheid geben
|
||||
cart.Items.Add(newItem);
|
||||
_context.CartItems.Add(newItem);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Shipping; // Für CartItemDto
|
||||
using Webshop.Application; // Für ServiceResult
|
||||
using System; // Für Guid
|
||||
using Webshop.Application.DTOs.Customers; // <--- WICHTIG für CartDto
|
||||
using Webshop.Application.DTOs.Shipping;
|
||||
using Webshop.Application;
|
||||
|
||||
namespace Webshop.Application.Services.Customers.Interfaces
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user