categorys

This commit is contained in:
Tizian.Breuch
2025-07-31 15:14:51 +02:00
parent b608d116f0
commit 50ae33c258
13 changed files with 377 additions and 95 deletions

View File

@@ -1,18 +1,38 @@
// Auto-generiert von CreateWebshopFiles.ps1
using Microsoft.AspNetCore.Mvc;
// src/Webshop.Api/Controllers/Public/CategoriesController.cs
using Microsoft.AspNetCore.Authorization;
using System;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Webshop.Application.DTOs.Categorys;
using Webshop.Application.Services.Public;
namespace Webshop.Api.Controllers.Public
{
[ApiController]
[Route("api/v1/public/[controller]")]
[Route("api/v1/public/categories")]
[AllowAnonymous]
public class CategoriesController : ControllerBase
{
private readonly ICategoryService _categoryService;
public CategoriesController(ICategoryService categoryService)
{
_categoryService = categoryService;
}
[HttpGet]
public async Task<ActionResult<IEnumerable<CategoryDto>>> GetActiveCategories()
{
var categories = await _categoryService.GetAllActiveAsync();
return Ok(categories);
}
[HttpGet("{slug}")]
public async Task<ActionResult<CategoryDto>> GetCategoryBySlug(string slug)
{
var category = await _categoryService.GetBySlugAsync(slug);
if (category == null) return NotFound();
return Ok(category);
}
}
}
}