initial commit
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using Indotalent.ConfigBackEnd.Interfaces;
|
||||
using Indotalent.ConfigFrontEnd.Common;
|
||||
using Indotalent.Features.Medical.MedicalRecordCategory.Cqrs;
|
||||
using Indotalent.Features.Organization.EmployeeCategory.Cqrs;
|
||||
using Indotalent.Infrastructure.Authentication.Identity;
|
||||
using Indotalent.Shared.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using RestSharp;
|
||||
|
||||
namespace Indotalent.Features.Organization.EmployeeCategory;
|
||||
|
||||
public class EmployeeCategoryService : BaseService
|
||||
{
|
||||
private readonly RestClient _client;
|
||||
|
||||
public EmployeeCategoryService(
|
||||
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<GetEmployeeCategoryListResponse>>?> GetEmployeeCategoryListAsync()
|
||||
{
|
||||
var request = new RestRequest("api/employee-category", Method.Get);
|
||||
return await ExecuteWithResponseAsync<List<GetEmployeeCategoryListResponse>>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<GetEmployeeCategoryByIdResponse>?> GetEmployeeCategoryByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/employee-category/{id}", Method.Get);
|
||||
return await ExecuteWithResponseAsync<GetEmployeeCategoryByIdResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<CreateEmployeeCategoryResponse>?> CreateEmployeeCategoryAsync(CreateEmployeeCategoryRequest data)
|
||||
{
|
||||
var request = new RestRequest("api/employee-category", Method.Post);
|
||||
request.AddJsonBody(data);
|
||||
return await ExecuteWithResponseAsync<CreateEmployeeCategoryResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteEmployeeCategoryByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/employee-category/delete/{id}", Method.Post);
|
||||
|
||||
var response = await ExecuteWithResponseAsync<object>(_client, request);
|
||||
return response?.IsSuccess ?? false;
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<UpdateEmployeeCategoryResponse>?> UpdateEmployeeCategoryAsync(UpdateEmployeeCategoryRequest data)
|
||||
{
|
||||
var request = new RestRequest("api/employee-category/update", Method.Post);
|
||||
request.AddJsonBody(data);
|
||||
return await ExecuteWithResponseAsync<UpdateEmployeeCategoryResponse>(_client, request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user