diff --git a/Webshop.Api/Controllers/Public/ShopInfoController.cs b/Webshop.Api/Controllers/Public/ShopInfoController.cs index 7f76e03..0fd60da 100644 --- a/Webshop.Api/Controllers/Public/ShopInfoController.cs +++ b/Webshop.Api/Controllers/Public/ShopInfoController.cs @@ -1,5 +1,6 @@ // src/Webshop.Api/Controllers/Public/ShopInfoController.cs using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; using Webshop.Application.DTOs.Shop; @@ -29,10 +30,12 @@ namespace Webshop.Api.Controllers.Public /// Diese Informationen sind für jeden Besucher sichtbar und werden typischerweise im Footer, auf der Kontaktseite oder im Impressum verwendet. /// [HttpGet] - public async Task> GetPublicShopInfo() + [ProducesResponseType(typeof(PublicShopInfoDto), StatusCodes.Status200OK)] + public async Task GetPublicShopInfo() { - var info = await _shopInfoService.GetPublicShopInfoAsync(); - return Ok(info); + var result = await _shopInfoService.GetPublicShopInfoAsync(); + // Dieser Service-Aufruf ist so konzipiert, dass er immer ein erfolgreiches Ergebnis liefert. + return Ok(result.Value); } } } \ No newline at end of file diff --git a/Webshop.Application/Services/Public/Interfaces/IShopInfoService.cs b/Webshop.Application/Services/Public/Interfaces/IShopInfoService.cs index 4d0aa24..1c104a1 100644 --- a/Webshop.Application/Services/Public/Interfaces/IShopInfoService.cs +++ b/Webshop.Application/Services/Public/Interfaces/IShopInfoService.cs @@ -1,11 +1,12 @@ // src/Webshop.Application/Services/Public/IShopInfoService.cs using System.Threading.Tasks; +using Webshop.Application; using Webshop.Application.DTOs.Shop; namespace Webshop.Application.Services.Public { public interface IShopInfoService { - Task GetPublicShopInfoAsync(); + Task> GetPublicShopInfoAsync(); } } \ No newline at end of file diff --git a/Webshop.Application/Services/Public/ShopInfoService.cs b/Webshop.Application/Services/Public/ShopInfoService.cs index 9c62225..8c36802 100644 --- a/Webshop.Application/Services/Public/ShopInfoService.cs +++ b/Webshop.Application/Services/Public/ShopInfoService.cs @@ -1,5 +1,6 @@ // src/Webshop.Application/Services/Public/ShopInfoService.cs using System.Threading.Tasks; +using Webshop.Application; using Webshop.Application.DTOs.Shop; using Webshop.Domain.Interfaces; @@ -14,17 +15,18 @@ namespace Webshop.Application.Services.Public _shopInfoRepository = shopInfoRepository; } - public async Task GetPublicShopInfoAsync() + public async Task> GetPublicShopInfoAsync() { var shopInfo = await _shopInfoRepository.GetAsync(); if (shopInfo == null) { // Gib Standardwerte zurück, wenn nichts konfiguriert ist - return new PublicShopInfoDto { ShopName = "Webshop" }; + var defaultDto = new PublicShopInfoDto { ShopName = "Webshop" }; + return ServiceResult.Ok(defaultDto); } - return new PublicShopInfoDto + var dto = new PublicShopInfoDto { ShopName = shopInfo.ShopName, Slogan = shopInfo.Slogan, @@ -38,6 +40,8 @@ namespace Webshop.Application.Services.Public InstagramUrl = shopInfo.InstagramUrl, TwitterUrl = shopInfo.TwitterUrl }; + + return ServiceResult.Ok(dto); } } } \ No newline at end of file