This commit is contained in:
Tizian.Breuch
2025-07-31 15:16:46 +02:00
parent 50ae33c258
commit ca1d3fda1d
2 changed files with 4 additions and 4 deletions

View File

@@ -0,0 +1,38 @@
// src/Webshop.Api/Controllers/Public/CategoriesController.cs
using Microsoft.AspNetCore.Authorization;
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/categories")]
[AllowAnonymous]
public class CategorysController : ControllerBase
{
private readonly ICategoryService _categoryService;
public CategorysController(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);
}
}
}