initial commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
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<ApiResponse<List<GetPayrollProcessListResponse>>?> GetPayrollProcessListAsync()
|
||||
{
|
||||
var request = new RestRequest("api/payroll", Method.Get);
|
||||
return await ExecuteWithResponseAsync<List<GetPayrollProcessListResponse>>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<GetPayrollProcessByIdResponse>?> GetPayrollProcessByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/payroll/{id}", Method.Get);
|
||||
return await ExecuteWithResponseAsync<GetPayrollProcessByIdResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<CreatePayrollProcessResponse>?> CreatePayrollProcessAsync(CreatePayrollProcessRequest data)
|
||||
{
|
||||
var request = new RestRequest("api/payroll", Method.Post);
|
||||
request.AddJsonBody(data);
|
||||
return await ExecuteWithResponseAsync<CreatePayrollProcessResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<UpdatePayrollProcessResponse>?> UpdatePayrollProcessAsync(UpdatePayrollProcessRequest data)
|
||||
{
|
||||
var request = new RestRequest("api/payroll/update", Method.Post);
|
||||
request.AddJsonBody(data);
|
||||
return await ExecuteWithResponseAsync<UpdatePayrollProcessResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<bool> DeletePayrollProcessByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/payroll/delete/{id}", Method.Post);
|
||||
var response = await ExecuteWithResponseAsync<object>(_client, request);
|
||||
return response?.IsSuccess ?? false;
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<List<GetPayrollDetailListByProcessIdResponse>>?> GetPayrollDetailListByProcessIdAsync(string processId)
|
||||
{
|
||||
var request = new RestRequest($"api/payroll/detail/list/{processId}", Method.Get);
|
||||
return await ExecuteWithResponseAsync<List<GetPayrollDetailListByProcessIdResponse>>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<GetPayrollDetailByIdResponse>?> GetPayrollDetailByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/payroll/detail/{id}", Method.Get);
|
||||
return await ExecuteWithResponseAsync<GetPayrollDetailByIdResponse>(_client, request);
|
||||
}
|
||||
public async Task<ApiResponse<GetPayrollSlipByIdResponse>?> GetPayrollSlipByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/payroll/detail/slip/{id}", Method.Get);
|
||||
return await ExecuteWithResponseAsync<GetPayrollSlipByIdResponse>(_client, request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user