BetterFinds
Public Member Functions | Properties | Private Attributes | List of all members
BetterFinds.Pages.AuctionModel Class Reference

Model for the Auction page. More...

Inheritance diagram for BetterFinds.Pages.AuctionModel:
Inheritance graph
[legend]
Collaboration diagram for BetterFinds.Pages.AuctionModel:
Collaboration graph
[legend]

Public Member Functions

 AuctionModel (IConfiguration configuration, IHubContext< NotificationHub > hubContext)
 Initializes a new instance of the AuctionModel class. More...
 
IActionResult OnPost ()
 The on post method, triggered when the user submits a form on the page. More...
 
IActionResult OnGet ()
 Retrieves the auction information from the database. More...
 

Properties

decimal? BidAmount [get, set]
 The bid amount, if any. More...
 
string? PaymentMethod [get, set]
 The payment method, if any. More...
 
string? EarlySell [get, set]
 The early sell or terminate request, if any. More...
 
DateTime? ExtendedEndTime [get, set]
 The extended end time, if any. More...
 

Private Attributes

readonly IConfiguration configuration
 The IConfiguration instance. More...
 
readonly IHubContext< NotificationHubhubContext
 The IHubContext instance. More...
 

Detailed Description

Model for the Auction page.

Constructor & Destructor Documentation

◆ AuctionModel()

BetterFinds.Pages.AuctionModel.AuctionModel ( IConfiguration  configuration,
IHubContext< NotificationHub hubContext 
)
inline

Initializes a new instance of the AuctionModel class.

Parameters
configurationThe IConfiguration instance.
hubContextThe IHubContext instance.

Member Function Documentation

◆ OnGet()

IActionResult BetterFinds.Pages.AuctionModel.OnGet ( )
inline

Retrieves the auction information from the database.

Retrieves the auction information from the database and displays it on the page. It also retrieves the product information and the bids history.

It parses the auction id through the request query string. If the id is not found, it redirects to the not found error (404) page.

The auction end time is displayed in a countdown timer with javascript. The images, if any, can be iterated in right and left mouse clicks. The bid history is displayed in a collapsible table.

The seller as the option to early sell/terminate the auction, depending on the number of bids and if the auction has ended or not.

When the auction ends and there isn't any bids, the seller has the option to extend the auction.

The buyer has the option to bid if the auction has not ended yet.

The winner of the auction will be displayed after the auction has ended, and this user will have the option to complete the payment by choosing a payment method and pressing the "Pay" button.

Returns
A task that represents the auction on get operation.

◆ OnPost()

IActionResult BetterFinds.Pages.AuctionModel.OnPost ( )
inline

The on post method, triggered when the user submits a form on the page.

Similar the OnGet method, this method retrieves the auction id through the request query string.

Forms that can be submitted, varying on the auction state and current user role:

  • A new bid submitted by an user.
  • The payment method made by an user.
  • The request of a early sell/termination of the auction by the seller.
  • The extension datetime of the auction requested by the seller, if this ended with no bids.

Requirements:

As a requirement to submit a bid, the user must be logged in and the auction must not have ended. To a bid to be valid, the bid amount must be greater or the current price plus the minimum bid. Besides that, the user cannot bid on his own auction and cannot bid if he's already the highest bidder.

To complete the payment, the user must be logged in and the auction must have ended. Only the highest bidder can complete the payment. Payment options: Credit Card, PayPal, Apple Pay or Crypto Currency.

Only the seller of the auction can perform an early sell/termination of the auction. This action depends on the number of bids, being only displayed if the auction hasn't ended. If a auction has no bids, it's presented the option to terminate the auction, otherwise it's presented the option to early sell the auction.

Finally, when an auction ends and there's no bids, the seller can extend the auction. This datetime inputted must be greater than the current time, if failed to do so, an error message is displayed.

Notifications:

When a user submits a valid bid, notifications are sent to all bidders except the current one, and the seller is also notified that a new bid has been placed on his auction. The bidders are determined by the bidders group created with Utils.Bids.CreateBidderGroupAsync and when a new bid is placed, the bidder is added to the group with Utils.Bids.AddBidderToBidderGroupAsync.

Similar to the notifications described above, when the auction ends, the relevant bidders are notified that the auction has ended, and the winner is notified that he has won the auction and needs to complete the payment. If the seller didn't request an early sell/termination of the auction, he's also notified that his auction has ended.

When the buyer completes the payment, the seller is notified that the auction has been sold.

No notifications are sent when the seller requests an auction extension as there's no bidders as a requirement to this action.

Real-time updates:

When a bid is placed, the following fields are updated in real-time using SignalR:

  • Current price
  • Buyer info
  • Bid history
  • The bid amount placeholder

Note: The bid amount placeholder is only updated if the current value is lower than the new placeholder. This prevents the placeholder from being updated when the user has a bid ready to be submitted.

Upon the conclusion of the auction, the page is refreshed for all clients located on that page.

Returns
A task that represents the auction on post operation.

Member Data Documentation

◆ configuration

readonly IConfiguration BetterFinds.Pages.AuctionModel.configuration
private

The IConfiguration instance.

◆ hubContext

readonly IHubContext<NotificationHub> BetterFinds.Pages.AuctionModel.hubContext
private

The IHubContext instance.

Property Documentation

◆ BidAmount

decimal? BetterFinds.Pages.AuctionModel.BidAmount
getset

The bid amount, if any.

◆ EarlySell

string? BetterFinds.Pages.AuctionModel.EarlySell
getset

The early sell or terminate request, if any.

◆ ExtendedEndTime

DateTime? BetterFinds.Pages.AuctionModel.ExtendedEndTime
getset

The extended end time, if any.

◆ PaymentMethod

string? BetterFinds.Pages.AuctionModel.PaymentMethod
getset

The payment method, if any.


The documentation for this class was generated from the following file: