* Managed API to handle User maintenance

* Managed Users view in application
This commit is contained in:
2025-02-20 06:39:06 +01:00
parent cd5990039d
commit 9b8d621f42
19 changed files with 530 additions and 195 deletions

View File

@@ -0,0 +1,45 @@
using Microsoft.AspNetCore.Mvc;
using OrdersManagementDataModel.Dtos;
using OrdersManagementDataModel.Services;
namespace FaKrosnoApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class RolesController(IRoleService service) : Controller
{
[HttpGet]
public async Task<ActionResult<IEnumerable<RoleDto>>> GetAll()
{
IEnumerable<RoleDto?> roles = await service.GetAll();
return Ok(roles);
}
[HttpGet("by-id")]
public async Task<ActionResult<RoleDto?>> GetById([FromQuery] Guid id)
{
RoleDto? role = await service.GetById(id);
return role != null ? Ok(role) : NotFound();
}
[HttpGet("by-name")]
public async Task<ActionResult<RoleDto?>> GetByName([FromQuery] string name)
{
RoleDto? role = await service.GetByName(name);
return role != null ? Ok(role) : NotFound();
}
[HttpPost]
public async Task<ActionResult<RoleDto>> Add([FromBody] RoleDto role)
{
await service.Add(role);
return Ok(role);
}
[HttpDelete]
public async Task<ActionResult<RoleDto>> Delete([FromQuery] Guid id)
{
await service.Delete(id);
return Ok();
}
}