61 lines
2.4 KiB
C#
61 lines
2.4 KiB
C#
using Indotalent.ConfigBackEnd.Interfaces;
|
|
using Indotalent.ConfigFrontEnd.Common;
|
|
using Indotalent.Features.Medical.MedicalRecordGroup.Cqrs;
|
|
using Indotalent.Features.Organization.EmployeeGroup.Cqrs;
|
|
using Indotalent.Infrastructure.Authentication.Identity;
|
|
using Indotalent.Shared.Models;
|
|
using Microsoft.AspNetCore.Components;
|
|
using MudBlazor;
|
|
using RestSharp;
|
|
|
|
namespace Indotalent.Features.Organization.EmployeeGroup;
|
|
|
|
public class EmployeeGroupService : BaseService
|
|
{
|
|
private readonly RestClient _client;
|
|
|
|
public EmployeeGroupService(
|
|
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<GetEmployeeGroupListResponse>>?> GetEmployeeGroupListAsync()
|
|
{
|
|
var request = new RestRequest("api/employee-group", Method.Get);
|
|
return await ExecuteWithResponseAsync<List<GetEmployeeGroupListResponse>>(_client, request);
|
|
}
|
|
|
|
public async Task<ApiResponse<GetEmployeeGroupByIdResponse>?> GetEmployeeGroupByIdAsync(string id)
|
|
{
|
|
var request = new RestRequest($"api/employee-group/{id}", Method.Get);
|
|
return await ExecuteWithResponseAsync<GetEmployeeGroupByIdResponse>(_client, request);
|
|
}
|
|
|
|
public async Task<ApiResponse<CreateEmployeeGroupResponse>?> CreateEmployeeGroupAsync(CreateEmployeeGroupRequest data)
|
|
{
|
|
var request = new RestRequest("api/employee-group", Method.Post);
|
|
request.AddJsonBody(data);
|
|
return await ExecuteWithResponseAsync<CreateEmployeeGroupResponse>(_client, request);
|
|
}
|
|
|
|
public async Task<bool> DeleteEmployeeGroupByIdAsync(string id)
|
|
{
|
|
var request = new RestRequest($"api/employee-group/delete/{id}", Method.Post);
|
|
|
|
var response = await ExecuteWithResponseAsync<object>(_client, request);
|
|
return response?.IsSuccess ?? false;
|
|
}
|
|
|
|
public async Task<ApiResponse<UpdateEmployeeGroupResponse>?> UpdateEmployeeGroupAsync(UpdateEmployeeGroupRequest data)
|
|
{
|
|
var request = new RestRequest("api/employee-group/update", Method.Post);
|
|
request.AddJsonBody(data);
|
|
return await ExecuteWithResponseAsync<UpdateEmployeeGroupResponse>(_client, request);
|
|
}
|
|
} |