Provides utility functions for handling auctions-related operations. More...
Public Member Functions | |
Auctions (IConfiguration configuration, IHubContext< NotificationHub > hubContext) | |
Initializes a new instance of the Auctions class. More... | |
List< Dictionary< string, object > > | GetAuctions (int clientId, int order, bool reversed, bool occurring) |
Returns a list of auctions based on the given parameters. More... | |
void | ParseAuctionsOptions (string sort, ref int order, ref bool reversed) |
Parses the given sort option and updates the order and reversed parameters accordingly. More... | |
void | CreateAuctionsToCheck () |
Creates a list of auctions that need to be checked by the auction background service. More... | |
void | AddAuction (DateTime endTime) |
Adds an auction end time to the AuctionEndTimes list. More... | |
void | RemoveAuction (DateTime endTime) |
Removes an auction end time from the AuctionEndTimes list. More... | |
async Task | CheckAuctionsAsync () |
Checks for auctions that ended asynchronously, notifies users and updates the database when ended auctions are found. More... | |
void | PrintAuctionsToCheck () |
Prints the AuctionEndTimes list to the console. More... | |
Private Attributes | |
readonly IConfiguration | configuration |
The IConfiguration instance. More... | |
readonly IHubContext< NotificationHub > | hubContext |
The IHubContext instance. More... | |
Static Private Attributes | |
static readonly List< DateTime > | AuctionEndTimes = [] |
The AuctionEndTimes list contains all the auction end times that need to be checked by the auction background service, initialized at the start of the application. More... | |
Provides utility functions for handling auctions-related operations.
|
inline |
Initializes a new instance of the Auctions class.
configuration | The IConfiguration instance. |
hubContext | The IHubContext instance. |
void BetterFinds.Utils.Auctions.AddAuction | ( | DateTime | endTime | ) |
Adds an auction end time to the AuctionEndTimes list.
Referenced by:
endTime | The auction end time to add. |
|
inline |
Checks for auctions that ended asynchronously, notifies users and updates the database when ended auctions are found.
Referenced by:
When an auction ends, the following notifications are created:
The respective notification count is updated for each user, and respective auction page is refreshed for all users that are currently viewing the auction page.
The auction is marked as checked in the database, to prevent it from being checked again, and it's removed from the AuctionEndTimes list.
|
inline |
Creates a list of auctions that need to be checked by the auction background service.
This method is called at the start of the application to populate the AuctionEndTimes list.
It selects all the auctions that have not ended yet and are not completed (or checked as ended), and adds their end time to the AuctionEndTimes list.
|
inline |
Returns a list of auctions based on the given parameters.
Referenced by:
The parameter clientId retrieves auctions with the following options:
The paramater order sorts the auction list, the options are:
Returned dictionary format:
clientId | The client id to retrieve auctions from. If 0, all auctions are retrieved. |
order | The order to sort the auctions by. |
reversed | Whether to reverse the order of the auctions. |
occurring | Whether to retrieve only auctions that are occurring. |
|
inline |
Parses the given sort option and updates the order and reversed parameters accordingly.
This method is used to parse the sort option selected by the user in pages that have the option to sort the auctions.
Referenced by:
The parameter sort can be one of the following:
The parameter order is updated with the order to sort the auctions by.
The parameter reversed is updated with whether to reverse the order of the auctions.
sort | The sort option to parse. |
order | The order returned by the method. |
reversed | The reversed returned by the method. |
|
inline |
Prints the AuctionEndTimes list to the console.
Used for debugging purposes.
Referenced by:
void BetterFinds.Utils.Auctions.RemoveAuction | ( | DateTime | endTime | ) |
Removes an auction end time from the AuctionEndTimes list.
Referenced by:
endTime | The auction end time to remove. |
|
staticprivate |
The AuctionEndTimes
list contains all the auction end times that need to be checked by the auction background service, initialized at the start of the application.
This property can only be set from within the class.
This list is populated by the CreateAuctionsToCheck method.
|
private |
The IConfiguration instance.
|
private |
The IHubContext instance.