104 lines
3.9 KiB
C#
104 lines
3.9 KiB
C#
using Serilog;
|
|
using System.Net.Http;
|
|
using WorkFlowCheck.Common.DTO;
|
|
using WorkFlowCheck.Web.Services.Interfaces;
|
|
|
|
namespace WorkFlowCheck.Web.Services
|
|
{
|
|
public class CheckListService : BaseService, ICheckListService
|
|
{
|
|
public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor)
|
|
{
|
|
}
|
|
|
|
public async Task<List<CheckListHeaderDTO>> GetAllCheckListHeaderAsync()
|
|
{
|
|
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetAllCheckListHeaders";
|
|
var retVal = new List<CheckListHeaderDTO>();
|
|
try
|
|
{
|
|
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<CheckListHeaderDTO>>>(endpoint);
|
|
if (response != null)
|
|
{
|
|
if (response.IsSuccess)
|
|
{
|
|
return response.Data;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error(ex.Message);
|
|
}
|
|
return retVal;
|
|
}
|
|
public async Task<CheckListHeaderDTO> GetCheckListHeader(int id)
|
|
{
|
|
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetCheckListHeader/{id}";
|
|
var retVal = new CheckListHeaderDTO() { CheckListRowDTO = new List<CheckListRowDTO>() };
|
|
try
|
|
{
|
|
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<CheckListHeaderDTO>>(endpoint);
|
|
if (response != null)
|
|
{
|
|
if (response.IsSuccess)
|
|
{
|
|
return response.Data;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error(ex.Message);
|
|
}
|
|
return retVal;
|
|
}
|
|
public async Task<ApiResponseDTO<CheckListHeaderDTO>> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO) => throw new NotImplementedException();
|
|
|
|
|
|
public async Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync()
|
|
{
|
|
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetAllCheckListTemplateHeaders";
|
|
var retVal = new List<CheckListTemplateHeaderDTO>();
|
|
try
|
|
{
|
|
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<CheckListTemplateHeaderDTO>>>(endpoint);
|
|
if (response != null)
|
|
{
|
|
if (response.IsSuccess)
|
|
{
|
|
return response.Data;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error(ex.Message);
|
|
}
|
|
return retVal;
|
|
}
|
|
public async Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeader(int id)
|
|
{
|
|
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetCheckListTemplateHeader/{id}";
|
|
var retVal = new CheckListTemplateHeaderDTO() { CheckListTemplateRowDTO = new List<CheckListTemplateRowDTO>() };
|
|
try
|
|
{
|
|
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<CheckListTemplateHeaderDTO>>(endpoint);
|
|
if (response != null)
|
|
{
|
|
if (response.IsSuccess)
|
|
{
|
|
return response.Data;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error(ex.Message);
|
|
}
|
|
return retVal;
|
|
}
|
|
public async Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO) => throw new NotImplementedException();
|
|
}
|
|
}
|