UserRole is benn van, de még nem tökéletes.

This commit is contained in:
2025-03-18 13:56:35 +01:00
parent 9297ff3970
commit 2fd147bb36
7 changed files with 302 additions and 10 deletions
@@ -72,7 +72,7 @@ namespace WorkFlowCheck.API.Controllers
return retVal;
}
[HttpPost("UpdateUser")]
public async Task<ApiResponseDTO<UserDTO>> UpdateUser([FromBody] UserDTO UserDTO)
public async Task<ApiResponseDTO<UserDTO>> UpdateUser([FromBody] UserDTO userDTO)
{
var retVal = new ApiResponseDTO<UserDTO>()
{
@@ -81,7 +81,7 @@ namespace WorkFlowCheck.API.Controllers
try
{
var result = await _userService.UpdateUserAsync(UserDTO);
var result = await _userService.UpdateUserAsync(userDTO);
retVal.Data = result;
}
@@ -194,7 +194,7 @@ namespace WorkFlowCheck.API.Controllers
return retVal;
}
[HttpPost("UpdateRole")]
public async Task<ApiResponseDTO<RoleDTO>> UpdateRole([FromBody] RoleDTO RoleDTO)
public async Task<ApiResponseDTO<RoleDTO>> UpdateRole([FromBody] RoleDTO roleDTO)
{
var retVal = new ApiResponseDTO<RoleDTO>()
{
@@ -203,7 +203,83 @@ namespace WorkFlowCheck.API.Controllers
try
{
var result = await _userService.UpdateRoleAsync(RoleDTO);
var result = await _userService.UpdateRoleAsync(roleDTO);
retVal.Data = result;
}
catch (Exception ex)
{
retVal.IsSuccess = false;
Log.Error(ex.Message);
}
return retVal;
}
[HttpGet("GetUserRole/{id}")]
public async Task<ApiResponseDTO<UserRoleDTO>> GetUserRole(int id)
{
var retVal = new ApiResponseDTO<UserRoleDTO>()
{
IsSuccess = true,
};
var RoleDTO = await _userService.GetUserRoleAsync(id);
if (RoleDTO != null)
{
if (RoleDTO.Id == 0)
{
retVal.IsSuccess = false;
retVal.Errors.Add("No match!");
retVal.Data = RoleDTO;
}
else
{
retVal.IsSuccess = true;
retVal.Data = RoleDTO;
}
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
return retVal;
}
[HttpGet("GetAllUserRoles")]
public async Task<ApiResponseDTO<List<UserRoleDTO>>> GetAllUserRoles()
{
var retVal = new ApiResponseDTO<List<UserRoleDTO>>()
{
IsSuccess = true,
};
var RoleDTO = await _userService.GetAllUserRoleAsync();
if (RoleDTO != null)
{
retVal.IsSuccess = true;
retVal.Data = RoleDTO;
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
return retVal;
}
[HttpPost("UpdateUserRole")]
public async Task<ApiResponseDTO<UserRoleDTO>> UpdateUserRole([FromBody] UserRoleDTO userRoleDTO)
{
var retVal = new ApiResponseDTO<UserRoleDTO>()
{
IsSuccess = true
};
try
{
var result = await _userService.UpdateUserRoleAsync(userRoleDTO);
retVal.Data = result;
}