aufrüumen
This commit is contained in:
18
Webshop.Api/Controllers/Customers/CheckoutController.cs
Normal file
18
Webshop.Api/Controllers/Customers/CheckoutController.cs
Normal 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.Customers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/[controller]")]
|
||||
[Authorize(Roles = "Customer")]
|
||||
public class CheckoutController : ControllerBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
22
Webshop.Api/Controllers/Customers/OrdersController.cs
Normal file
22
Webshop.Api/Controllers/Customers/OrdersController.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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.Customers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/[controller]")]
|
||||
[Authorize(Roles = "Customer")]
|
||||
public class OrdersController : ControllerBase
|
||||
{
|
||||
[HttpGet("my-orders")]
|
||||
public async Task<IActionResult> GetMyOrders()
|
||||
{
|
||||
return Ok(new { Message = "Dies ist Ihr persönlicher Bestellverlauf (Platzhalter)." });
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Webshop.Api/Controllers/Customers/ProfileController.cs
Normal file
51
Webshop.Api/Controllers/Customers/ProfileController.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Customers;
|
||||
using Webshop.Application.Services.Customers.Interfaces;
|
||||
|
||||
namespace Webshop.Api.Controllers.Customers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/profile")] // Eindeutige Route f<>r das Profil
|
||||
[Authorize(Roles = "Customer")] // Nur f<>r eingeloggte Kunden!
|
||||
public class ProfileController : ControllerBase
|
||||
{
|
||||
private readonly ICustomerService _customerService;
|
||||
|
||||
public ProfileController(ICustomerService customerService)
|
||||
{
|
||||
_customerService = customerService;
|
||||
}
|
||||
|
||||
// Hilfsmethode, um die ID des eingeloggten Benutzers aus dem Token zu holen
|
||||
private string GetUserId() => User.FindFirstValue(ClaimTypes.NameIdentifier)!;
|
||||
|
||||
[HttpGet("me")] // GET /api/v1/customer/profile/me
|
||||
public async Task<ActionResult<CustomerDto>> GetMyProfile()
|
||||
{
|
||||
var userId = GetUserId();
|
||||
var profile = await _customerService.GetMyProfileAsync(userId);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
return NotFound("Kundenprofil nicht gefunden.");
|
||||
}
|
||||
return Ok(profile);
|
||||
}
|
||||
|
||||
[HttpPut("me")] // PUT /api/v1/customer/profile/me
|
||||
public async Task<IActionResult> UpdateMyProfile([FromBody] UpdateCustomerProfileDto profileDto)
|
||||
{
|
||||
var userId = GetUserId();
|
||||
var success = await _customerService.UpdateMyProfileAsync(userId, profileDto);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
return NotFound("Kundenprofil nicht gefunden.");
|
||||
}
|
||||
return NoContent(); // Standardantwort f<>r ein erfolgreiches Update
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Webshop.Api/Controllers/Customers/ReviewsController.cs
Normal file
18
Webshop.Api/Controllers/Customers/ReviewsController.cs
Normal 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.Customers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/customer/[controller]")]
|
||||
[Authorize(Roles = "Customer")]
|
||||
public class ReviewsController : ControllerBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user