Class RemoteRepositoryBase
- Namespace
- Core.CliniCore.Repositories.Remote
- Assembly
- Core.CliniCore.dll
Base class for remote repositories that communicate with the API via HTTP. Provides shared HttpClient configuration and JSON serialization helpers.
public abstract class RemoteRepositoryBase
- Inheritance
-
RemoteRepositoryBase
- Derived
- Inherited Members
Constructors
RemoteRepositoryBase(HttpClient)
protected RemoteRepositoryBase(HttpClient httpClient)
Parameters
httpClientHttpClient
Fields
_httpClient
protected readonly HttpClient _httpClient
Field Value
_jsonOptions
protected readonly JsonSerializerOptions _jsonOptions
Field Value
Properties
LastError
Contains the last error message from a failed request
public string? LastError { get; protected set; }
Property Value
Methods
Delete(string)
Synchronous wrapper for async DELETE operation
protected bool Delete(string endpoint)
Parameters
endpointstring
Returns
DeleteAsync(string)
Performs a DELETE request
protected Task<bool> DeleteAsync(string endpoint)
Parameters
endpointstring
Returns
GetAsync<T>(string)
Performs a GET request and deserializes the response
protected Task<T?> GetAsync<T>(string endpoint) where T : class
Parameters
endpointstring
Returns
- Task<T>
Type Parameters
T
GetListAsync<T>(string)
Performs a GET request and deserializes to a list
protected Task<List<T>> GetListAsync<T>(string endpoint)
Parameters
endpointstring
Returns
Type Parameters
T
GetList<T>(string)
Synchronous wrapper for async GET list operation
protected List<T> GetList<T>(string endpoint)
Parameters
endpointstring
Returns
- List<T>
Type Parameters
T
Get<T>(string)
Synchronous wrapper for async GET operation
protected T? Get<T>(string endpoint) where T : class
Parameters
endpointstring
Returns
- T
Type Parameters
T
PostAsync<TRequest>(string, TRequest)
Performs a POST request without expecting a response body
protected Task<bool> PostAsync<TRequest>(string endpoint, TRequest data)
Parameters
endpointstringdataTRequest
Returns
Type Parameters
TRequest
PostAsync<TRequest, TResponse>(string, TRequest)
Performs a POST request with JSON body
protected Task<TResponse?> PostAsync<TRequest, TResponse>(string endpoint, TRequest data) where TResponse : class
Parameters
endpointstringdataTRequest
Returns
- Task<TResponse>
Type Parameters
TRequestTResponse
Post<TRequest>(string, TRequest)
Synchronous wrapper for async POST operation without response
protected bool Post<TRequest>(string endpoint, TRequest data)
Parameters
endpointstringdataTRequest
Returns
Type Parameters
TRequest
Post<TRequest, TResponse>(string, TRequest)
Synchronous wrapper for async POST operation
protected TResponse? Post<TRequest, TResponse>(string endpoint, TRequest data) where TResponse : class
Parameters
endpointstringdataTRequest
Returns
- TResponse
Type Parameters
TRequestTResponse
PutAsync<TRequest>(string, TRequest)
Performs a PUT request with JSON body
protected Task<bool> PutAsync<TRequest>(string endpoint, TRequest data)
Parameters
endpointstringdataTRequest
Returns
Type Parameters
TRequest
Put<TRequest>(string, TRequest)
Synchronous wrapper for async PUT operation
protected bool Put<TRequest>(string endpoint, TRequest data)
Parameters
endpointstringdataTRequest
Returns
Type Parameters
TRequest