This commit is contained in:
2025-03-16 20:31:49 +01:00
parent 9d113d0b49
commit 0e06382eee
4 changed files with 107 additions and 10 deletions
@@ -23,7 +23,7 @@ namespace WorkFlowCheck.API.Controllers
{
IsSuccess = true,
};
var checkListHeaderDTO = await _checkListService.GetCheckListHeader(id );
var checkListHeaderDTO = await _checkListService.GetCheckListHeaderAsync(id );
if (checkListHeaderDTO != null)
{
@@ -50,7 +50,7 @@ namespace WorkFlowCheck.API.Controllers
try
{
var response = await _checkListService.StartNew(request);
var response = await _checkListService.StartNewCheckListAsync(request);
}
catch (Exception ex)
{
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.BL.Services.Interfaces;
using Serilog;
using WorkFlowCheck.BL.Services;
namespace WorkFlowCheck.API.Controllers
{
@@ -16,9 +17,9 @@ namespace WorkFlowCheck.API.Controllers
{
_userService = userService;
}
[HttpGet("{id}")]
public async Task<ApiResponseDTO<UserDTO>> Get(int id)
[HttpGet("GetUser/{id}")]
public async Task<ApiResponseDTO<UserDTO>> GetUser(int id)
{
var retVal = new ApiResponseDTO<UserDTO>()
{
@@ -48,7 +49,6 @@ namespace WorkFlowCheck.API.Controllers
return retVal;
}
[HttpGet("GetAllUser")]
public async Task<ApiResponseDTO<List<UserDTO>>> GetAllUser()
{
@@ -71,7 +71,27 @@ namespace WorkFlowCheck.API.Controllers
return retVal;
}
[HttpPost("UpdateUser")]
public async Task<ApiResponseDTO<UserDTO>> UpdateUser([FromBody] UserDTO UserDTO)
{
var retVal = new ApiResponseDTO<UserDTO>()
{
IsSuccess = true
};
try
{
var result = await _userService.UpdateUserAsync(UserDTO);
retVal.Data = result;
}
catch (Exception ex)
{
retVal.IsSuccess = false;
Log.Error(ex.Message);
}
return retVal;
}
[HttpPost("Authenticate")]
public async Task<ApiResponseDTO<UserDTO>> Authenticate([FromBody] UserDTO userDTO)
{
@@ -119,5 +139,82 @@ namespace WorkFlowCheck.API.Controllers
}
return retVal;
}
[HttpGet("GetRole/{id}")]
public async Task<ApiResponseDTO<RoleDTO>> GetRole(int id)
{
var retVal = new ApiResponseDTO<RoleDTO>()
{
IsSuccess = true,
};
var RoleDTO = await _userService.GetRoleAsync(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("GetAllRole")]
public async Task<ApiResponseDTO<List<RoleDTO>>> GetAllRole()
{
var retVal = new ApiResponseDTO<List<RoleDTO>>()
{
IsSuccess = true,
};
var RoleDTO = await _userService.GetAllRoleAsync();
if (RoleDTO != null)
{
retVal.IsSuccess = true;
retVal.Data = RoleDTO;
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
return retVal;
}
[HttpPost("UpdateRole")]
public async Task<ApiResponseDTO<RoleDTO>> UpdateRole([FromBody] RoleDTO RoleDTO)
{
var retVal = new ApiResponseDTO<RoleDTO>()
{
IsSuccess = true
};
try
{
var result = await _userService.UpdateRoleAsync(RoleDTO);
retVal.Data = result;
}
catch (Exception ex)
{
retVal.IsSuccess = false;
Log.Error(ex.Message);
}
return retVal;
}
}
}