* Managed API to handle User maintenance
* Managed Users view in application
This commit is contained in:
43
FaKrosnoApi/Controllers/UserRolesController.cs
Normal file
43
FaKrosnoApi/Controllers/UserRolesController.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OrdersManagementDataModel.Dtos;
|
||||
using OrdersManagementDataModel.Services;
|
||||
|
||||
namespace FaKrosnoApi.Controllers;
|
||||
|
||||
public class UserRolesController(IUserRoleService service) : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<UserRoleDto>>> GetAll()
|
||||
{
|
||||
IEnumerable<UserRoleDto?> userRoles = await service.GetAll();
|
||||
return Ok(userRoles);
|
||||
}
|
||||
|
||||
[HttpGet("by-id")]
|
||||
public async Task<ActionResult<UserRoleDto?>> GetById([FromQuery] Guid id)
|
||||
{
|
||||
UserRoleDto? userRole = await service.GetById(id);
|
||||
return userRole != null ? Ok(userRole) : NotFound();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<UserRoleDto>> Add([FromBody] UserRoleDto userRole)
|
||||
{
|
||||
await service.Add(userRole);
|
||||
return Ok(userRole);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public async Task<ActionResult<UserRoleDto>> Update([FromBody] UserRoleDto userRole)
|
||||
{
|
||||
await service.Update(userRole);
|
||||
return Ok(userRole);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public async Task<ActionResult<UserRoleDto>> Delete([FromQuery] Guid id)
|
||||
{
|
||||
await service.Delete(id);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user