Files
ERP_Distribution/Distribution/Features/Role/RoleController.cs
T
Kalana B. Thilakarathna 9adfff48a7 auth layer implemented
2026-10-09 09:37:05 +05:30

29 lines
784 B
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Distribution.Features.Role;
[ApiController]
[Route("api/roles")]
[Authorize("role.view")]
public class RoleController(RoleService service) : ControllerBase
{
[HttpGet]
public async Task<IActionResult> GetAll() =>
Ok(await service.GetAllAsync());
[HttpGet("{id:guid}")]
public async Task<IActionResult> GetById(Guid id)
{
var result = await service.GetByIdAsync(id);
return result is null ? NotFound() : Ok(result);
}
[HttpGet("{id:guid}/permissions")]
public async Task<IActionResult> GetPermissions(Guid id)
{
var result = await service.GetPermissionsAsync(id);
return result is null ? NotFound() : Ok(result);
}
}