66 lines
2.6 KiB
C#
66 lines
2.6 KiB
C#
using Indotalent.ConfigBackEnd.Interfaces;
|
|
using Indotalent.ConfigFrontEnd.Common;
|
|
using Indotalent.Features.Thirdparty.PatientContact.Cqrs;
|
|
using Indotalent.Infrastructure.Authentication.Identity;
|
|
using Indotalent.Shared.Models;
|
|
using Microsoft.AspNetCore.Components;
|
|
using MudBlazor;
|
|
using RestSharp;
|
|
|
|
namespace Indotalent.Features.Thirdparty.PatientContact;
|
|
|
|
public class PatientContactService : BaseService
|
|
{
|
|
private readonly RestClient _client;
|
|
|
|
public PatientContactService(
|
|
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<GetPatientContactListResponse>>?> GetPatientContactListAsync()
|
|
{
|
|
var request = new RestRequest("api/patient-contact", Method.Get);
|
|
return await ExecuteWithResponseAsync<List<GetPatientContactListResponse>>(_client, request);
|
|
}
|
|
|
|
public async Task<ApiResponse<GetPatientContactByIdResponse>?> GetPatientContactByIdAsync(string id)
|
|
{
|
|
var request = new RestRequest($"api/patient-contact/{id}", Method.Get);
|
|
return await ExecuteWithResponseAsync<GetPatientContactByIdResponse>(_client, request);
|
|
}
|
|
|
|
public async Task<ApiResponse<LookupPatientContactResponse>?> GetPatientContactLookupAsync()
|
|
{
|
|
var request = new RestRequest("api/patient-contact/lookup", Method.Get);
|
|
return await ExecuteWithResponseAsync<LookupPatientContactResponse>(_client, request);
|
|
}
|
|
|
|
public async Task<ApiResponse<CreatePatientContactResponse>?> CreatePatientContactAsync(CreatePatientContactRequest data)
|
|
{
|
|
var request = new RestRequest("api/patient-contact", Method.Post);
|
|
request.AddJsonBody(data);
|
|
return await ExecuteWithResponseAsync<CreatePatientContactResponse>(_client, request);
|
|
}
|
|
|
|
public async Task<bool> DeletePatientContactByIdAsync(string id)
|
|
{
|
|
var request = new RestRequest($"api/patient-contact/delete/{id}", Method.Post);
|
|
|
|
var response = await ExecuteWithResponseAsync<object>(_client, request);
|
|
return response?.IsSuccess ?? false;
|
|
}
|
|
|
|
public async Task<ApiResponse<UpdatePatientContactResponse>?> UpdatePatientContactAsync(UpdatePatientContactRequest data)
|
|
{
|
|
var request = new RestRequest("api/patient-contact/update", Method.Post);
|
|
request.AddJsonBody(data);
|
|
return await ExecuteWithResponseAsync<UpdatePatientContactResponse>(_client, request);
|
|
}
|
|
} |