* Managed API to handle User maintenance
* Managed Users view in application
This commit is contained in:
52
FaKrosnoApi/Controllers/FunctionsController.cs
Normal file
52
FaKrosnoApi/Controllers/FunctionsController.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OrdersManagementDataModel.Dtos;
|
||||
using OrdersManagementDataModel.Services;
|
||||
|
||||
namespace FaKrosnoApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class FunctionsController(IFunctionService service) : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<FunctionDto>>> GetAll()
|
||||
{
|
||||
IEnumerable<FunctionDto?> functions = await service.GetAll();
|
||||
return Ok(functions);
|
||||
}
|
||||
|
||||
[HttpGet("by-id")]
|
||||
public async Task<ActionResult<FunctionDto?>> GetById([FromQuery] Guid id)
|
||||
{
|
||||
FunctionDto? function = await service.GetById(id);
|
||||
return function != null ? Ok(function) : NotFound();
|
||||
}
|
||||
|
||||
[HttpGet("by-name")]
|
||||
public async Task<ActionResult<FunctionDto?>> GetByName([FromQuery] string name)
|
||||
{
|
||||
FunctionDto? function = await service.GetByName(name);
|
||||
return function != null ? Ok(function) : NotFound();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<FunctionDto>> Add([FromBody] FunctionDto function)
|
||||
{
|
||||
await service.Add(function);
|
||||
return Ok(function);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public async Task<ActionResult<FunctionDto>> Update([FromBody] FunctionDto function)
|
||||
{
|
||||
await service.Update(function);
|
||||
return Ok(function);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public async Task<ActionResult<FunctionDto>> Delete([FromQuery] Guid id)
|
||||
{
|
||||
await service.Delete(id);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
45
FaKrosnoApi/Controllers/RolesController.cs
Normal file
45
FaKrosnoApi/Controllers/RolesController.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
52
FaKrosnoApi/Controllers/UsersController.cs
Normal file
52
FaKrosnoApi/Controllers/UsersController.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OrdersManagementDataModel.Dtos;
|
||||
using OrdersManagementDataModel.Services;
|
||||
|
||||
namespace FaKrosnoApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class UsersController(IUserService service) : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<UserDto>>> GetAll()
|
||||
{
|
||||
IEnumerable<UserDto?> users = await service.GetAll();
|
||||
return Ok(users);
|
||||
}
|
||||
|
||||
[HttpGet("by-id")]
|
||||
public async Task<ActionResult<UserDto?>> GetById([FromQuery] Guid id)
|
||||
{
|
||||
UserDto? user = await service.GetById(id);
|
||||
return user != null ? Ok(user) : NotFound();
|
||||
}
|
||||
|
||||
[HttpGet("by-username")]
|
||||
public async Task<ActionResult<UserDto?>> GetByUsername([FromQuery] string username)
|
||||
{
|
||||
UserDto? user = await service.GetByUsername(username);
|
||||
return user != null ? Ok(user) : NotFound();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<UserDto>> Add([FromBody] UserDto user)
|
||||
{
|
||||
await service.Add(user);
|
||||
return Ok(user);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public async Task<ActionResult<UserDto>> Update([FromBody] UserDto user)
|
||||
{
|
||||
await service.Update(user);
|
||||
return Ok(user);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public async Task<ActionResult<UserDto>> Delete([FromQuery] Guid id)
|
||||
{
|
||||
await service.Delete(id);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user