1
+ @page " /entrydetail"
2
+ @using Model
3
+ @using Services
4
+ @using Utils
5
+ @inject Microsoft .AspNetCore .Components .NavigationManager NavigationManager
6
+ @inject IMatDialogService MatDialogService
7
+
8
+ <style >
9
+ .demo-mat-card {
10
+ margin-bottom : 2em ;
11
+ }
12
+
13
+ .demo-mat-card-content {
14
+ padding : 1rem ;
15
+ }
16
+
17
+ .clear-margin {
18
+ margin : 0px ;
19
+ }
20
+
21
+ .clear-margin-vertical {
22
+ margin-top : 0px ;
23
+ margin-bottom : 0px ;
24
+ }
25
+ .app-fab--absolute {
26
+ position : fixed ;
27
+ bottom : 1rem ;
28
+ right : 1rem ;
29
+ }
30
+
31
+ </style >
32
+ <div class =" mat-layout-grid mat-layout-grid-align-center" >
33
+ <div class =" mat-layout-grid-inner center" >
34
+
35
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-2" ></div >
36
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-8" >
37
+ <MatCard class =" demo-mat-card" >
38
+ <MatCardContent >
39
+ <div class =" demo-mat-card-content" >
40
+ <MatHeadline6 class =" clear-margin" >
41
+ <MatChipSet Style =" align-items: center" >
42
+ <MatH5 Class =" clear-margin-vertical" >@portfolioEntryName </MatH5 >
43
+ <MatChip Style =" vertical-align: center" Label =" @(activePortfolioEntry.Symbol.ToUpper())" />
44
+ <MatH6 Class =" clear-margin-vertical" Style =" text-align: end;float: end;" >1 BTC = $30 000</MatH6 >
45
+ </MatChipSet >
46
+ </MatHeadline6 >
47
+ </div >
48
+
49
+ <MatBody2 class =" demo-mat-card-content clear-margin" >
50
+ <div class =" mat-layout-grid" >
51
+ <div class =" mat-layout-grid-inner" style =" align-items : center " >
52
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" >
53
+ <MatH4 Class =" clear-margin" >@( CurrencyUtils .Format (entrySummary .MarketValue , activePortfolio .Currency )) </MatH4 >
54
+ </div >
55
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" style =" text-align : end " >
56
+ @( entrySummary .RelativeChange * 100 m ) %
57
+ </div >
58
+ </div >
59
+ </div >
60
+ </MatBody2 >
61
+ </MatCardContent >
62
+ </MatCard >
63
+ <MatTable Items =" @tableRowsItems" Striped =" true" AllowSelection =" true" RowClass =" tester" class =" mat-elevation-z5" ShowPaging =" false" PageSize =" 9999" >
64
+ <MatTableHeader >
65
+ <th >Date</th >
66
+ <th >Size</th >
67
+ <th >Market Value</th >
68
+ <th >Change</th >
69
+ <th >Cost</th >
70
+ <th >Fee</th >
71
+ <th >Actions</th >
72
+ </MatTableHeader >
73
+ <MatTableRow >
74
+ <td >
75
+ <div style =" min-width : 9rem " >@( String .Format (" {0:d.M.yyyy HH:mm:ss}" , context .Item1 .Date )) </div >
76
+ </td >
77
+ <td >
78
+ <div style =" min-width : 9rem " >@context.Item1.Size @activePortfolioEntry.Symbol.ToUpper() </div >
79
+ </td >
80
+ <td >@CurrencyUtils.Format(context.Item2.MarketValue , activePortfolio.Currency)</td >
81
+ <td style =' color : @(context.Item2.RelativeChange >= 0 ? " #17a104" : " #FF0000" )' >
82
+ <div style =" min-width : 9rem " >@CurrencyUtils.Format(context.Item2.AbsoluteChange , activePortfolio.Currency) (@( context .Item2 .RelativeChange * 100 ) %)</div >
83
+ </td >
84
+ <td >@CurrencyUtils.Format(context.Item2.Cost , activePortfolio.Currency)</td >
85
+ <td >@CurrencyUtils.Format(context.Item1.Fee , activePortfolio.Currency)</td >
86
+ <td >
87
+ <MatIconButton Icon =" edit" OnClick =" EditMarketOrder" ></MatIconButton >
88
+ <MatIconButton Icon =" delete" OnClick =" DeletePortfolio" ></MatIconButton >
89
+ </td >
90
+ </MatTableRow >
91
+ </MatTable >
92
+ </div >
93
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-2" ></div >
94
+ </div >
95
+ </div >
96
+ <MatFAB Class =" app-fab--absolute" Icon =" @MatIconNames.Add" Label =" Add a new order" ></MatFAB >
97
+
98
+
99
+ @code
100
+ {
101
+ protected Portfolio activePortfolio = new Portfolio (" Main Portfolio" , " My main portfolio to be used" , Currency .Usd );
102
+ protected PortfolioEntry activePortfolioEntry = new (" btc" );
103
+ protected string portfolioEntryName = " Bitcoin" ;
104
+ protected ISummaryService .Summary entrySummary = new (523 m , 0 . 719 m , 1268 . 89 m , 745 . 58 m );
105
+
106
+ protected List <Tuple <MarketOrder, ISummaryService.Summary >> tableRowsItems = new ()
107
+ {
108
+ new Tuple <MarketOrder , ISummaryService .Summary >(new (18300 m , 0 . 1 m , 0 . 003266 m , DateTime .Now .AddMonths (- 6 ), false ), new (120 m , 2 m , 183 . 00 m , 60 m )),
109
+ new Tuple <MarketOrder , ISummaryService .Summary >(new (21200 , 0 . 3 m , 0 . 002866 m , DateTime .Now .AddDays (91 ), false ), new (101 m , 2 m , 123 . 00 m , 45 m )),
110
+ new Tuple <MarketOrder , ISummaryService .Summary >(new (18300 m , 0 . 1 m , 0 . 003266 m , DateTime .Now .AddMonths (- 6 ), false ), new (180 m - 30 m , 2 . 3 m , 113 . 00 m , 23 m )),
111
+ new Tuple <MarketOrder , ISummaryService .Summary >(new (18300 m , 0 . 1 m , 0 . 003266 m , DateTime .Now .AddMonths (- 6 ), false ), new (- 60 m , - 0 . 6 m , 40 . 00 m , 100 m )),
112
+ };
113
+
114
+ protected record PortfolioEntryRow (string symbol , decimal currentPrice , decimal relativeChange , decimal percentage );
115
+
116
+ protected override async Task OnInitializedAsync ()
117
+ {
118
+ // _existingPortfolios = PortfolioService.GetPortfolios();
119
+ }
120
+
121
+ public void EditMarketOrder (MouseEventArgs e )
122
+ {
123
+ NavigationManager .NavigateTo ($" editorder" );
124
+ }
125
+
126
+ async void DeletePortfolio (MouseEventArgs e )
127
+ {
128
+ var result = await MatDialogService .ConfirmAsync (" Do you really wish to delete this market order?" );
129
+ if (result )
130
+ {
131
+ }
132
+ }
133
+ }
0 commit comments