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

Model for the Create page. This class is decorated with the Authorize attribute. More...

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

Public Member Functions

 CreateModel (IConfiguration configuration, IHubContext< NotificationHub > hubContext)
 Initializes a new instance of the CreateModel class. More...
 
void OnGet ()
 The OnGet action. More...
 
IActionResult OnPost ()
 Creates a new auction if all requirements are met. More...
 

Properties

string Title = "" [get, set]
 The title of the auction. More...
 
string Description = "" [get, set]
 The description of the auction. More...
 
decimal Price = 0.01M [get, set]
 The starting price of the auction. More...
 
decimal MinimumBid = 0.01M [get, set]
 The minimum bid of the auction. More...
 
string EndTime = "" [get, set]
 The end time of the auction. More...
 
string? Images [get, set]
 The images of the auction. More...
 

Private Attributes

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

Detailed Description

Model for the Create page. This class is decorated with the Authorize attribute.

Constructor & Destructor Documentation

◆ CreateModel()

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

Initializes a new instance of the CreateModel class.

Parameters
configurationThe IConfiguration instance.
hubContextThe IHubContext instance.

Member Function Documentation

◆ OnGet()

void BetterFinds.Pages.CreateModel.OnGet ( )
inline

The OnGet action.

◆ OnPost()

IActionResult BetterFinds.Pages.CreateModel.OnPost ( )
inline

Creates a new auction if all requirements are met.

  • The starting price must be greater than 0.
  • The minimum bid must be greater than 0.
  • The title must be between 1 and 64 characters long.
  • The description must be between 1 and 2048 characters long.
  • The end time must be a valid date and time and greater than the current time.
  • The images must be valid, if any. See Utils.Images.IsValidImages.

If all requirements are met, the auction is created and the user is redirected to the new auction page. Otherwise, the user stays on the page and an error message is displayed.

The users on the IndexModel or SearchModel pages are notified that there's updates.

The auction is added to the background service to check for its ending.

When a auction is created it triggers the AuctionCreated event in the SignalR hub, updating relevant pages that there's updates to display.

Event trigger example:

hubContext.Clients.All.SendAsync("AuctionCreated").Wait();
readonly IHubContext< NotificationHub > hubContext
The IHubContext instance.
Definition: Create.cshtml.cs:25
Returns
A task that represents the action of creating a new auction.

Member Data Documentation

◆ configuration

readonly IConfiguration BetterFinds.Pages.CreateModel.configuration
private

The IConfiguration instance.

◆ hubContext

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

The IHubContext instance.

Property Documentation

◆ Description

string BetterFinds.Pages.CreateModel.Description = ""
getset

The description of the auction.

◆ EndTime

string BetterFinds.Pages.CreateModel.EndTime = ""
getset

The end time of the auction.

◆ Images

string? BetterFinds.Pages.CreateModel.Images
getset

The images of the auction.

◆ MinimumBid

decimal BetterFinds.Pages.CreateModel.MinimumBid = 0.01M
getset

The minimum bid of the auction.

◆ Price

decimal BetterFinds.Pages.CreateModel.Price = 0.01M
getset

The starting price of the auction.

◆ Title

string BetterFinds.Pages.CreateModel.Title = ""
getset

The title of the auction.


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