naming
This commit is contained in:
38
Webshop.Api/Controllers/Public/CategoryController.cs
Normal file
38
Webshop.Api/Controllers/Public/CategoryController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
// src/Webshop.Api/Controllers/Public/categorysController.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/categorys")]
|
||||
[AllowAnonymous]
|
||||
public class CategoryController : ControllerBase
|
||||
{
|
||||
private readonly ICategoryService _categoryService;
|
||||
|
||||
public CategoryController(ICategoryService categoryService)
|
||||
{
|
||||
_categoryService = categoryService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<CategoryDto>>> GetActivecategorys()
|
||||
{
|
||||
var categorys = await _categoryService.GetAllActiveAsync();
|
||||
return Ok(categorys);
|
||||
}
|
||||
|
||||
[HttpGet("{slug}")]
|
||||
public async Task<ActionResult<CategoryDto>> GetCategoryBySlug(string slug)
|
||||
{
|
||||
var category = await _categoryService.GetBySlugAsync(slug);
|
||||
if (category == null) return NotFound();
|
||||
return Ok(category);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user