Provides utility functions for handling client-related operations. More...
Public Member Functions | |
Client (IConfiguration configuration) | |
Initializes a new instance of the Client class. More... | |
int | GetClientId (HttpContext httpContext, ClaimsPrincipal user) |
Returns the ClientId of the currently logged in client. More... | |
List< Dictionary< string, object > > | GetClients () |
Returns a list of all clients in the database. More... | |
Private Attributes | |
readonly IConfiguration | configuration |
The IConfiguration instance. More... | |
Provides utility functions for handling client-related operations.
BetterFinds.Utils.Client.Client | ( | IConfiguration | configuration | ) |
Initializes a new instance of the Client class.
configuration | The IConfiguration instance. |
|
inline |
Returns the ClientId of the currently logged in client.
httpContext | The HttpContext instance. |
user | The ClaimsPrincipal instance. |
Usage example:
This method checks if the user is authenticated.
If the user is authenticated, it attempts to obtain the ClientId from the session cookie.
If that fails, it retrieves the ClientId from the database using the provided HttpContext and ClaimsPrincipal instances, serving as a fallback.
This ensures that the ClientId is still obtained even if the session cookie is unavailable.
|
inline |
Returns a list of all clients in the database.
This method is used to populate the list of clients in the Auction page. Avoiding the multiple database calls that would be required to obtain the clients information. The dictionary returned by this method contains the following keys:
|
private |
The IConfiguration instance.