initial commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using Indotalent.ConfigBackEnd.Interfaces;
|
||||
using Indotalent.ConfigFrontEnd.Common;
|
||||
using Indotalent.Features.Performance.Evaluation.Cqrs;
|
||||
using Indotalent.Infrastructure.Authentication.Identity;
|
||||
using Indotalent.Shared.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using RestSharp;
|
||||
|
||||
namespace Indotalent.Features.Performance.Evaluation;
|
||||
|
||||
public class EvaluationService : BaseService
|
||||
{
|
||||
private readonly RestClient _client;
|
||||
|
||||
public EvaluationService(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<GetEvaluationListResponse>>?> GetEvaluationListAsync()
|
||||
{
|
||||
var request = new RestRequest("api/performance-evaluation", Method.Get);
|
||||
return await ExecuteWithResponseAsync<List<GetEvaluationListResponse>>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<GetEvaluationByIdResponse>?> GetEvaluationByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/performance-evaluation/{id}", Method.Get);
|
||||
return await ExecuteWithResponseAsync<GetEvaluationByIdResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<CreateEvaluationResponse>?> CreateEvaluationAsync(CreateEvaluationRequest data)
|
||||
{
|
||||
var request = new RestRequest("api/performance-evaluation", Method.Post);
|
||||
request.AddJsonBody(data);
|
||||
return await ExecuteWithResponseAsync<CreateEvaluationResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteEvaluationByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/performance-evaluation/delete/{id}", Method.Post);
|
||||
var response = await ExecuteWithResponseAsync<object>(_client, request);
|
||||
return response?.IsSuccess ?? false;
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<UpdateEvaluationResponse>?> UpdateEvaluationAsync(UpdateEvaluationRequest data)
|
||||
{
|
||||
var request = new RestRequest("api/performance-evaluation/update", Method.Post);
|
||||
request.AddJsonBody(data);
|
||||
return await ExecuteWithResponseAsync<UpdateEvaluationResponse>(_client, request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user