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.Admin
{
[ApiController]
[Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")]
public class AdminCategoriesController : ControllerBase
{
}
}

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.Admin
{
[ApiController]
[Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")]
public class AdminDiscountsController : ControllerBase
{
}
}

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.Admin
{
[ApiController]
[Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")]
public class AdminOrdersController : ControllerBase
{
}
}

View File

@@ -1,13 +1,18 @@
using Microsoft.AspNetCore.Authorization;
// Auto-generiert von CreateWebshopFiles.ps1
using Microsoft.AspNetCore.Mvc;
using Webshop.Application.DTOs; // ProductDto and AdminProductDto
using Microsoft.AspNetCore.Authorization;
using Webshop.Application.DTOs;
using Webshop.Application.Services.Admin;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Webshop.Api.Controllers.Admin
{
[ApiController]
[Route("api/v1/admin/[controller]")] // z.B. /api/v1/admin/products
[Authorize(Roles = "Admin")] // Nur Benutzer mit der Rolle "Admin" dürfen zugreifen
[Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")]
public class AdminProductsController : ControllerBase
{
private readonly AdminProductService _adminProductService;
@@ -17,14 +22,14 @@ namespace Webshop.Api.Controllers.Admin
_adminProductService = adminProductService;
}
[HttpGet] // /api/v1/admin/products
[HttpGet]
public async Task<ActionResult<IEnumerable<AdminProductDto>>> GetAdminProducts()
{
var products = await _adminProductService.GetAllAdminProductsAsync();
return Ok(products);
}
[HttpGet("{id}")] // /api/v1/admin/products/{id}
[HttpGet("{id}")]
public async Task<ActionResult<AdminProductDto>> GetAdminProduct(Guid id)
{
var product = await _adminProductService.GetAdminProductByIdAsync(id);
@@ -32,7 +37,7 @@ namespace Webshop.Api.Controllers.Admin
return Ok(product);
}
[HttpPost] // /api/v1/admin/products
[HttpPost]
public async Task<ActionResult<AdminProductDto>> CreateAdminProduct([FromBody] AdminProductDto productDto)
{
if (!ModelState.IsValid) return BadRequest(ModelState);
@@ -40,18 +45,17 @@ namespace Webshop.Api.Controllers.Admin
return CreatedAtAction(nameof(GetAdminProduct), new { id = createdProduct.Id }, createdProduct);
}
[HttpPut("{id}")] // /api/v1/admin/products/{id}
[HttpPut("{id}")]
public async Task<IActionResult> UpdateAdminProduct(Guid id, [FromBody] AdminProductDto productDto)
{
if (id != productDto.Id) return BadRequest();
if (!ModelState.IsValid) return BadRequest(ModelState);
var success = await _adminProductService.UpdateAdminProductAsync(productDto);
if (!success) return NotFound();
return NoContent();
}
[HttpDelete("{id}")] // /api/v1/admin/products/{id}
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteAdminProduct(Guid id)
{
var success = await _adminProductService.DeleteAdminProductAsync(id);
@@ -59,4 +63,4 @@ namespace Webshop.Api.Controllers.Admin
return NoContent();
}
}
}
}

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.Admin
{
[ApiController]
[Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")]
public class AdminSettingsController : ControllerBase
{
}
}

View File

@@ -1,8 +1,10 @@
// src/Webshop.Api/Controllers/Admin/AdminSuppliersController.cs
// src/Webshop.Api/Controllers/Admin/AdminSuppliersController.cs
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Webshop.Application.DTOs; // SupplierDto
using Webshop.Application.Services.Admin;
using Webshop.Application.Services.Admin; // AdminSupplierService
using System.Collections.Generic; // Für IEnumerable
using System.Threading.Tasks; // Für Task
namespace Webshop.Api.Controllers.Admin
{
@@ -11,6 +13,7 @@ namespace Webshop.Api.Controllers.Admin
[Authorize(Roles = "Admin")] // Nur Admins
public class AdminSuppliersController : ControllerBase
{
// HIER MUSS NUR EINE EINZIGE DEKLARATION STEHEN
private readonly AdminSupplierService _adminSupplierService;
public AdminSuppliersController(AdminSupplierService adminSupplierService)

View File

@@ -1,13 +1,18 @@
using Microsoft.AspNetCore.Authorization;
// Auto-generiert von CreateWebshopFiles.ps1
using Microsoft.AspNetCore.Mvc;
using Webshop.Application.DTOs.Users; // UserDto
using Microsoft.AspNetCore.Authorization;
using Webshop.Application.DTOs.Users;
using Webshop.Application.Services.Admin;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Webshop.Api.Controllers.Admin
{
[ApiController]
[Route("api/v1/admin/[controller]")] // z.B. /api/v1/admin/users
[Authorize(Roles = "Admin")] // Nur Benutzer mit der Rolle "Admin" dürfen zugreifen
[Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")]
public class AdminUsersController : ControllerBase
{
private readonly AdminUserService _adminUserService;
@@ -17,20 +22,19 @@ namespace Webshop.Api.Controllers.Admin
_adminUserService = adminUserService;
}
[HttpGet] // /api/v1/admin/users
[HttpGet]
public async Task<ActionResult<IEnumerable<UserDto>>> GetAllUsers()
{
var users = await _adminUserService.GetAllUsersAsync();
return Ok(users);
}
[HttpGet("{userId}")] // /api/v1/admin/users/{userId}
[HttpGet("{userId}")]
public async Task<ActionResult<UserDto>> GetUserById(string userId)
{
var user = await _adminUserService.GetUserByIdAsync(userId);
if (user == null) return NotFound();
return Ok(user);
}
// TODO: Hier könnten weitere Methoden für User-Verwaltung (Rollen ändern, löschen etc.) hinzukommen
}
}
}

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.Customer
{
[ApiController]
[Route("api/v1/customer/[controller]")]
[Authorize(Roles = "Customer")]
public class CheckoutController : ControllerBase
{
}
}

View File

@@ -1,23 +1,22 @@
using Microsoft.AspNetCore.Authorization;
// Auto-generiert von CreateWebshopFiles.ps1
using Microsoft.AspNetCore.Mvc;
// using Webshop.Application.DTOs.Orders; // Später erstellen
// using Webshop.Application.Services.Customer; // Später erstellen
using Microsoft.AspNetCore.Authorization;
namespace Webshop.Api.Controllers.Customer // Beachten Sie den Namespace
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Webshop.Api.Controllers.Customer
{
[ApiController]
[Route("api/v1/customer/[controller]")] // z.B. /api/v1/customer/orders
[Authorize(Roles = "Customer")] // Nur Benutzer mit der Rolle "Customer" dürfen zugreifen
[Route("api/v1/customer/[controller]")]
[Authorize(Roles = "Customer")]
public class OrdersController : ControllerBase
{
// Beispiel-Endpunkt für eingeloggte Kunden
[HttpGet("my-orders")]
public async Task<IActionResult> GetMyOrders()
{
// Hier würden Sie die Bestellungen des eingeloggten Benutzers abrufen.
// Die Benutzer-ID können Sie über User.FindFirstValue(ClaimTypes.NameIdentifier) abrufen.
// return Ok(await _orderService.GetOrdersForCurrentUserAsync(User.FindFirstValue(ClaimTypes.NameIdentifier)));
return Ok(new { Message = "Dies sind Ihre Bestellungen (Platzhalter)." });
return Ok(new { Message = "Dies ist Ihr persönlicher Bestellverlauf (Platzhalter)." });
}
}
}
}

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.Customer
{
[ApiController]
[Route("api/v1/customer/[controller]")]
[Authorize(Roles = "Customer")]
public class ProfileController : ControllerBase
{
}
}

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.Customer
{
[ApiController]
[Route("api/v1/customer/[controller]")]
[Authorize(Roles = "Customer")]
public class ReviewsController : ControllerBase
{
}
}

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.
}
}
}