Skip to content

Commit 73e0428

Browse files
committed
Added comments to NewMarketOrder.razor
1 parent 572d30a commit 73e0428

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

WebFrontend/Pages/NewMarketOrder.razor

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
@page "/newmarketorder/{entryId:int}"
2-
@using Model
32
@using Services
3+
@using Model
44
@inject IPortfolioService PortfolioService
55
@inject IPortfolioEntryService PortfolioEntrySerivce
66
@inject IMarketOrderService MarketOrderService
77
@inject IMatDialogService MatDialogService
88
@inject IMatToaster Toaster
9-
@inject Microsoft.AspNetCore.Components.NavigationManager NavigationManager
9+
@inject NavigationManager NavigationManager
1010

1111

1212
<style>
@@ -19,11 +19,11 @@
1919
<div class="mat-layout-grid-inner">
2020
<div class="mat-layout-grid-cell-span-2"></div>
2121
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-8">
22-
<MatButton Outlined="true" Icon="keyboard_arrow_left" Style="margin-bottom: 1rem;" OnClick='() => { NavigationManager.NavigateTo($"/entries/{ActiveEntry.Id}"); }'>Back</MatButton>
22+
<MatButton Outlined="true" Icon="keyboard_arrow_left" Style="margin-bottom: 1rem;" OnClick='() => { NavigationManager.NavigateTo($"/entries/{_activeEntry.Id}"); }'>Back</MatButton>
2323
<MatCard>
2424
<MatCardContent class="demo-mat-card-content">
2525
<h2>Create a new market order</h2>
26-
<OrderForm Currency="@ActivePortfolio.Currency" Symbol="@ActiveEntry.Symbol" OnSubmitEventHandler="@OnCreateOrderFormSubmit"></OrderForm>
26+
<OrderForm Currency="@_activePortfolio.Currency" Symbol="@_activeEntry.Symbol" OnSubmitEventHandler="@OnCreateOrderFormSubmit"></OrderForm>
2727
</MatCardContent>
2828
</MatCard>
2929
</div>
@@ -37,20 +37,28 @@
3737
[Parameter]
3838
public int EntryId { get; set; }
3939

40-
protected Portfolio ActivePortfolio = new("", "", Currency.Usd);
41-
protected PortfolioEntry ActiveEntry = new("btc", 1);
40+
// the active portfolio
41+
private Portfolio _activePortfolio = new("", "", Currency.Usd);
42+
43+
// entry to which the entry will be added
44+
private PortfolioEntry _activeEntry = new("", 1);
4245

4346
protected override void OnInitialized()
4447
{
45-
ActiveEntry = PortfolioEntrySerivce.GetPortfolioEntry(EntryId);
46-
ActivePortfolio = PortfolioService.GetPortfolio(ActiveEntry.PortfolioId);
48+
// load the portfolio entry
49+
_activeEntry = PortfolioEntrySerivce.GetPortfolioEntry(EntryId);
50+
51+
// load the portfolio the entry belongs to
52+
_activePortfolio = PortfolioService.GetPortfolio(_activeEntry.PortfolioId);
4753
}
4854

4955
private void OnCreateOrderFormSubmit(OrderForm.NewOrderModel formModel)
5056
{
51-
Console.WriteLine("OnCreateOrderFormSubmit " + formModel);
52-
MarketOrderService.CreateMarketOrder(formModel.FilledPrice, formModel.Fee, formModel.Size, formModel.OrderDate, !formModel.SellOrder, ActiveEntry.Id);
57+
// create the market order
58+
MarketOrderService.CreateMarketOrder(formModel.FilledPrice, formModel.Fee, formModel.Size, formModel.OrderDate, !formModel.SellOrder, _activeEntry.Id);
59+
// reset the form model
5360
formModel.Reset();
61+
// notify user
5462
Toaster.Add("New order successfully added", MatToastType.Success, "", "");
5563
}
5664
}

0 commit comments

Comments
 (0)