Table of Contents

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

httpClient HttpClient

Fields

_httpClient

protected readonly HttpClient _httpClient

Field Value

HttpClient

_jsonOptions

protected readonly JsonSerializerOptions _jsonOptions

Field Value

JsonSerializerOptions

Properties

LastError

Contains the last error message from a failed request

public string? LastError { get; protected set; }

Property Value

string

Methods

Delete(string)

Synchronous wrapper for async DELETE operation

protected bool Delete(string endpoint)

Parameters

endpoint string

Returns

bool

DeleteAsync(string)

Performs a DELETE request

protected Task<bool> DeleteAsync(string endpoint)

Parameters

endpoint string

Returns

Task<bool>

GetAsync<T>(string)

Performs a GET request and deserializes the response

protected Task<T?> GetAsync<T>(string endpoint) where T : class

Parameters

endpoint string

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

endpoint string

Returns

Task<List<T>>

Type Parameters

T

GetList<T>(string)

Synchronous wrapper for async GET list operation

protected List<T> GetList<T>(string endpoint)

Parameters

endpoint string

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

endpoint string

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

endpoint string
data TRequest

Returns

Task<bool>

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

endpoint string
data TRequest

Returns

Task<TResponse>

Type Parameters

TRequest
TResponse

Post<TRequest>(string, TRequest)

Synchronous wrapper for async POST operation without response

protected bool Post<TRequest>(string endpoint, TRequest data)

Parameters

endpoint string
data TRequest

Returns

bool

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

endpoint string
data TRequest

Returns

TResponse

Type Parameters

TRequest
TResponse

PutAsync<TRequest>(string, TRequest)

Performs a PUT request with JSON body

protected Task<bool> PutAsync<TRequest>(string endpoint, TRequest data)

Parameters

endpoint string
data TRequest

Returns

Task<bool>

Type Parameters

TRequest

Put<TRequest>(string, TRequest)

Synchronous wrapper for async PUT operation

protected bool Put<TRequest>(string endpoint, TRequest data)

Parameters

endpoint string
data TRequest

Returns

bool

Type Parameters

TRequest