shop info

This commit is contained in:
Tizian.Breuch
2025-08-12 11:07:15 +02:00
parent 0a43b1d7e8
commit 1692fe198e
13 changed files with 387 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
// src/Webshop.Api/Controllers/Admin/AdminShopInfoController.cs
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Webshop.Application.DTOs.Shop;
using Webshop.Application.Services.Admin;
namespace Webshop.Api.Controllers.Admin
{
[ApiController]
[Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")]
public class AdminShopInfoController : ControllerBase
{
private readonly IAdminShopInfoService _shopInfoService;
public AdminShopInfoController(IAdminShopInfoService shopInfoService)
{
_shopInfoService = shopInfoService;
}
[HttpGet]
public async Task<ActionResult<AdminShopInfoDto>> GetShopInfo()
{
var info = await _shopInfoService.GetShopInfoAsync();
return Ok(info);
}
[HttpPut]
public async Task<IActionResult> UpdateShopInfo([FromBody] AdminShopInfoDto shopInfoDto)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
await _shopInfoService.UpdateShopInfoAsync(shopInfoDto);
return NoContent();
}
}
}

View File

@@ -0,0 +1,29 @@
// src/Webshop.Api/Controllers/Public/ShopInfoController.cs
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Webshop.Application.DTOs.Shop;
using Webshop.Application.Services.Public;
namespace Webshop.Api.Controllers.Public
{
[ApiController]
[Route("api/v1/public/[]controller")]
[AllowAnonymous]
public class ShopInfoController : ControllerBase
{
private readonly IShopInfoService _shopInfoService;
public ShopInfoController(IShopInfoService shopInfoService)
{
_shopInfoService = shopInfoService;
}
[HttpGet]
public async Task<ActionResult<PublicShopInfoDto>> GetPublicShopInfo()
{
var info = await _shopInfoService.GetPublicShopInfoAsync();
return Ok(info);
}
}
}

View File

@@ -105,6 +105,7 @@ builder.Services.AddScoped<IAddressRepository, AddressRepository>();
builder.Services.AddScoped<IDiscountRepository, DiscountRepository>();
builder.Services.AddScoped<IReviewRepository, ReviewRepository>();
builder.Services.AddScoped<ISettingRepository, SettingRepository>();
builder.Services.AddScoped<IShopInfoRepository, ShopInfoRepository>();
// Services
builder.Services.AddScoped<IAuthService, AuthService>();
@@ -125,6 +126,8 @@ builder.Services.AddScoped<IOrderService, OrderService>();
builder.Services.AddScoped<IAddressService, AddressService>();
builder.Services.AddScoped<ICheckoutService, CheckoutService>();
builder.Services.AddScoped<IReviewService, ReviewService>();
builder.Services.AddScoped<IAdminShopInfoService, AdminShopInfoService>();
builder.Services.AddScoped<IShopInfoService, ShopInfoService>();
// Controller und API-Infrastruktur
builder.Services.AddControllers()