1
1
@page " /newmarketorder/{entryId:int}"
2
- @using Model
3
2
@using Services
3
+ @using Model
4
4
@inject IPortfolioService PortfolioService
5
5
@inject IPortfolioEntryService PortfolioEntrySerivce
6
6
@inject IMarketOrderService MarketOrderService
7
7
@inject IMatDialogService MatDialogService
8
8
@inject IMatToaster Toaster
9
- @inject Microsoft . AspNetCore . Components . NavigationManager NavigationManager
9
+ @inject NavigationManager NavigationManager
10
10
11
11
12
12
<style >
19
19
<div class =" mat-layout-grid-inner" >
20
20
<div class =" mat-layout-grid-cell-span-2" ></div >
21
21
<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 >
23
23
<MatCard >
24
24
<MatCardContent class =" demo-mat-card-content" >
25
25
<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 >
27
27
</MatCardContent >
28
28
</MatCard >
29
29
</div >
37
37
[Parameter ]
38
38
public int EntryId { get ; set ; }
39
39
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 );
42
45
43
46
protected override void OnInitialized ()
44
47
{
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 );
47
53
}
48
54
49
55
private void OnCreateOrderFormSubmit (OrderForm .NewOrderModel formModel )
50
56
{
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
53
60
formModel .Reset ();
61
+ // notify user
54
62
Toaster .Add (" New order successfully added" , MatToastType .Success , " " , " " );
55
63
}
56
64
}
0 commit comments