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:
@@ -5,8 +5,8 @@ using System;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application;
|
||||
using Webshop.Application.DTOs.Customers;
|
||||
using Webshop.Application.DTOs.Shipping;
|
||||
using Webshop.Application.DTOs.Customers; // Für CartDto
|
||||
using Webshop.Application.DTOs.Shipping; // Für CartItemDto
|
||||
using Webshop.Application.Services.Customers.Interfaces;
|
||||
|
||||
namespace Webshop.Api.Controllers.Customer
|
||||
@@ -14,7 +14,7 @@ namespace Webshop.Api.Controllers.Customer
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/[controller]")]
|
||||
[Authorize(Roles = "Customer")]
|
||||
public class CartController : ControllerBase
|
||||
public class CartController : ControllerBase // <--- WICHTIG: Muss public sein und erben
|
||||
{
|
||||
private readonly ICartService _cartService;
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Webshop.Api.Controllers.Customer
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(CartDto), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetCart()
|
||||
{
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
@@ -32,14 +33,17 @@ namespace Webshop.Api.Controllers.Customer
|
||||
}
|
||||
|
||||
[HttpPost("items")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> AddToCart([FromBody] CartItemDto item)
|
||||
{
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var result = await _cartService.AddToCartAsync(userId!, item);
|
||||
return result.Type == ServiceResultType.Success ? Ok() : BadRequest(result.ErrorMessage);
|
||||
return result.Type == ServiceResultType.Success ? Ok() : BadRequest(new { Message = result.ErrorMessage });
|
||||
}
|
||||
|
||||
[HttpDelete("items/{productId}")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> RemoveItem(Guid productId)
|
||||
{
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
Reference in New Issue
Block a user