initial commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using Indotalent.ConfigBackEnd.Interfaces;
|
||||
using Indotalent.ConfigFrontEnd.Common;
|
||||
using Indotalent.Features.Leave.LeaveCategory.Cqrs;
|
||||
using Indotalent.Infrastructure.Authentication.Identity;
|
||||
using Indotalent.Shared.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using RestSharp;
|
||||
|
||||
namespace Indotalent.Features.Leave.LeaveCategory;
|
||||
|
||||
public class LeaveCategoryService : BaseService
|
||||
{
|
||||
private readonly RestClient _client;
|
||||
|
||||
public LeaveCategoryService(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<GetLeaveCategoryListResponse>>?> GetLeaveCategoryListAsync()
|
||||
{
|
||||
var request = new RestRequest("api/leave-category", Method.Get);
|
||||
return await ExecuteWithResponseAsync<List<GetLeaveCategoryListResponse>>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<GetLeaveCategoryByIdResponse>?> GetLeaveCategoryByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/leave-category/{id}", Method.Get);
|
||||
return await ExecuteWithResponseAsync<GetLeaveCategoryByIdResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<CreateLeaveCategoryResponse>?> CreateLeaveCategoryAsync(CreateLeaveCategoryRequest data)
|
||||
{
|
||||
var request = new RestRequest("api/leave-category", Method.Post);
|
||||
request.AddJsonBody(data);
|
||||
return await ExecuteWithResponseAsync<CreateLeaveCategoryResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteLeaveCategoryByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/leave-category/delete/{id}", Method.Post);
|
||||
var response = await ExecuteWithResponseAsync<object>(_client, request);
|
||||
return response?.IsSuccess ?? false;
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<UpdateLeaveCategoryResponse>?> UpdateLeaveCategoryAsync(UpdateLeaveCategoryRequest data)
|
||||
{
|
||||
var request = new RestRequest("api/leave-category/update", Method.Post);
|
||||
request.AddJsonBody(data);
|
||||
return await ExecuteWithResponseAsync<UpdateLeaveCategoryResponse>(_client, request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user