PaymentMethod
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
// src/Webshop.Api/Controllers/Public/PaymentMethodsController.cs
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Payments; // PaymentMethodDto
|
||||
using Webshop.Application.Services.Public; // IPaymentMethodService
|
||||
using Webshop.Application.DTOs.Payments;
|
||||
using Webshop.Application.Services.Public;
|
||||
|
||||
namespace Webshop.Api.Controllers.Public
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/public/[controller]")] // Saubere Route
|
||||
[AllowAnonymous] // Jeder darf die verfügbaren Zahlungsmethoden sehen
|
||||
[Route("api/v1/public/[controller]")]
|
||||
[AllowAnonymous]
|
||||
public class PaymentMethodsController : ControllerBase
|
||||
{
|
||||
private readonly IPaymentMethodService _paymentMethodService;
|
||||
@@ -21,10 +22,13 @@ namespace Webshop.Api.Controllers.Public
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<PaymentMethodDto>>> GetActivePaymentMethods()
|
||||
[ProducesResponseType(typeof(IEnumerable<PaymentMethodDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetActivePaymentMethods()
|
||||
{
|
||||
var paymentMethods = await _paymentMethodService.GetAllActiveAsync();
|
||||
return Ok(paymentMethods);
|
||||
var result = await _paymentMethodService.GetAllActiveAsync();
|
||||
// Ein GetAll sollte im Normalfall immer erfolgreich sein (und ggf. eine leere Liste zurückgeben).
|
||||
// Daher können wir hier direkt auf den Wert zugreifen.
|
||||
return Ok(result.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user