using Indotalent.ConfigBackEnd.Interfaces; using Indotalent.ConfigFrontEnd.Common; using Indotalent.Features.Payroll.Payrolls.Cqrs; using Indotalent.Features.Payroll.PayrollDetails.Cqrs; using Indotalent.Infrastructure.Authentication.Identity; using Indotalent.Shared.Models; using Microsoft.AspNetCore.Components; using MudBlazor; using RestSharp; namespace Indotalent.Features.Payroll.Payrolls; public class PayrollsService : BaseService { private readonly RestClient _client; public PayrollsService(IHttpClientFactory clientFactory, NavigationManager nav, ISnackbar snackbar, ICurrentUserService currentUserService, TokenProvider tokenProvider) : base(clientFactory, nav, snackbar, currentUserService, tokenProvider) { _client = new RestClient(nav.BaseUri); } public async Task>?> GetPayrollProcessListAsync() { var request = new RestRequest("api/payroll", Method.Get); return await ExecuteWithResponseAsync>(_client, request); } public async Task?> GetPayrollProcessByIdAsync(string id) { var request = new RestRequest($"api/payroll/{id}", Method.Get); return await ExecuteWithResponseAsync(_client, request); } public async Task?> CreatePayrollProcessAsync(CreatePayrollProcessRequest data) { var request = new RestRequest("api/payroll", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task?> UpdatePayrollProcessAsync(UpdatePayrollProcessRequest data) { var request = new RestRequest("api/payroll/update", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task DeletePayrollProcessByIdAsync(string id) { var request = new RestRequest($"api/payroll/delete/{id}", Method.Post); var response = await ExecuteWithResponseAsync(_client, request); return response?.IsSuccess ?? false; } public async Task>?> GetPayrollDetailListByProcessIdAsync(string processId) { var request = new RestRequest($"api/payroll/detail/list/{processId}", Method.Get); return await ExecuteWithResponseAsync>(_client, request); } public async Task?> GetPayrollDetailByIdAsync(string id) { var request = new RestRequest($"api/payroll/detail/{id}", Method.Get); return await ExecuteWithResponseAsync(_client, request); } public async Task?> GetPayrollSlipByIdAsync(string id) { var request = new RestRequest($"api/payroll/detail/slip/{id}", Method.Get); return await ExecuteWithResponseAsync(_client, request); } }