WEB most jól működik Datatables-sel.

This commit is contained in:
2025-03-11 16:54:50 +01:00
parent e5b1649c42
commit 8f9e5df847
11 changed files with 370 additions and 7 deletions
@@ -0,0 +1,23 @@
namespace WorkFlowCheck.Web.Services
{
public class BaseService
{
public readonly HttpClient _httpClient;
public readonly IConfiguration _configuration;
public BaseService(HttpClient httpClient, IConfiguration configuration)
{
_httpClient = httpClient;
_configuration = configuration;
var apiBaseUrl = configuration["ApiBaseUrl"]; // API-cím elérése a konfigurációból
_httpClient.BaseAddress = new Uri(apiBaseUrl);
var apiKey = configuration["ApiKey"];
_httpClient.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
}
}
}
@@ -0,0 +1,64 @@
using Serilog;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services.Interfaces;
namespace WorkFlowCheck.Web.Services
{
public class BaseStockService : BaseService, IBaseStockService
{
public BaseStockService(HttpClient httpClient, IConfiguration configuration) : base(httpClient, configuration)
{
}
public async Task<List<CheckPointDTO>> GetAllCheckPoints()
{
string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetAllCheckPoints";
var retVal = new List<CheckPointDTO>();
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<CheckPointDTO>>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<CheckPointDTO> GetCheckPoint(int id)
{
string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetCheckPoints/{id}";
var retVal = new CheckPointDTO();
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<CheckPointDTO>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<CheckPointDTO> UpdateCheckPoint(CheckPointDTO checkPointDto)
{
return null;
}
}
}
@@ -0,0 +1,11 @@
using WorkFlowCheck.Common.DTO;
namespace WorkFlowCheck.Web.Services.Interfaces
{
public interface IBaseStockService
{
Task<List<CheckPointDTO>> GetAllCheckPoints();
Task<CheckPointDTO> GetCheckPoint(int id);
Task<CheckPointDTO> UpdateCheckPoint(CheckPointDTO checkPoint);
}
}