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

@@ -0,0 +1,18 @@
// Auto-generiert von CreateWebshopFiles.ps1
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Webshop.Api.Controllers.Public
{
[ApiController]
[Route("api/v1/public/[controller]")]
[AllowAnonymous]
public class CategoriesController : ControllerBase
{
}
}

View File

@@ -1,29 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using Webshop.Application.DTOs; // ProductDto
using Webshop.Application.Services.Public; // ProductCatalogService
// Auto-generiert von CreateWebshopFiles.ps1
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Webshop.Application.DTOs;
using Webshop.Application.Services.Public;
namespace Webshop.Api.Controllers.Public // Beachten Sie den Namespace
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Webshop.Api.Controllers.Public
{
[ApiController]
[Route("api/v1/public/[controller]")] // z.B. /api/v1/public/products
[AllowAnonymous] // Jeder darf hier zugreifen (Gast oder eingeloggter User)
[Route("api/v1/public/[controller]")]
[AllowAnonymous]
public class ProductsController : ControllerBase
{
private readonly ProductService _productCatalogService; // Umbenannt
private readonly ProductService _productService; // ServiceName nach Ihrer Konvention beibehalten
public ProductsController(ProductService productCatalogService) // Injiziert den umbenannten Service
public ProductsController(ProductService productService)
{
_productCatalogService = productCatalogService;
_productService = productService;
}
[HttpGet] // /api/v1/public/products
[HttpGet]
public async Task<ActionResult<IEnumerable<ProductDto>>> GetAllProducts()
{
var products = await _productCatalogService.GetAllProductsAsync(); // Ruft Service-Methode auf
var products = await _productService.GetAllProductsAsync();
return Ok(products);
}
// Keine POST, PUT, DELETE hier für öffentliche Zugriffe.
// Diese gehören in den AdminProductsController.
}
}
}