73
73
<MatBody2 class =" demo-mat-card-content clear-margin" >
74
74
<div class =" mat-layout-grid" >
75
75
<div class =" mat-layout-grid-inner" style =" align-items : center " >
76
- <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" >
77
- <MatH4 Class =" clear-margin" >@( CurrencyUtils .Format (entrySummary .MarketValue , ActivePortfolio .Currency )) </MatH4 >
78
- </div >
79
- <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" style =" text-align : end " >
80
- @( entrySummary .RelativeChange * 100 m ) %
81
- </div >
76
+ @if (entrySummary != null )
77
+ {
78
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" >
79
+ <MatH4 Class =" clear-margin" >@( CurrencyUtils .Format (entrySummary .MarketValue , ActivePortfolio .Currency )) </MatH4 >
80
+ </div >
81
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" style =" text-align : end " >
82
+ @( entrySummary .RelativeChange * 100 m ) %
83
+ </div >
84
+ }
85
+ else
86
+ {
87
+ <MatProgressCircle Indeterminate =" true" />
88
+ }
82
89
</div >
83
90
</div >
84
91
</MatBody2 >
167
174
168
175
protected override async Task OnInitializedAsync ()
169
176
{
170
- // resolve the name of the cryptocurrency (using the symbol)
177
+ // resolve the name of the cryptocurrency (using the symbol)
171
178
portfolioEntryName = await CryptoNameResolver .Resolve (ActivePortfolioEntry .Symbol );
179
+
180
+ await UpdateEntrySummary ();
181
+ }
182
+
183
+ private void SetEntryLoading ()
184
+ {
185
+ CurrentEntryAssetMarketEntry = null ;
186
+ tableRowsItems = null ;
187
+ entrySummary = null ;
188
+ StateHasChanged ();
189
+ }
190
+
191
+ private async Task UpdateEntrySummary ()
192
+ {
172
193
173
194
// fetch the price of the entry's asset
174
195
// TODO null?
179
200
180
201
// get all orders of the portfolio entry
181
202
var entryOrders = MarketOrderService .GetPortfolioEntryOrders (ActivePortfolioEntry .Id );
182
-
203
+
183
204
// compute summaries of all orders in the entry
184
- var entrySummaries = entryOrders .Select (order => SummaryService .GetMarketOrderSummary (order , CurrentEntryAssetMarketEntry .CurrentPrice ));
205
+ var entrySummaries = entryOrders .Select (order =>
206
+ SummaryService .GetMarketOrderSummary (order , CurrentEntryAssetMarketEntry .CurrentPrice ));
185
207
186
208
// zip entry orders and summaries into a table rows
187
- tableRowsItems = entryOrders .Zip (entrySummaries ).Select (tuple => new Tuple <MarketOrder , ISummaryService .Summary >(tuple .First , tuple .Second )).ToList ();
209
+ tableRowsItems = entryOrders .Zip (entrySummaries )
210
+ .Select (tuple => new Tuple <MarketOrder , ISummaryService .Summary >(tuple .First , tuple .Second )).ToList ();
188
211
189
212
// compute suummary of this entry
190
213
entrySummary = SummaryService .GetPortfolioEntrySummary (entryOrders , CurrentEntryAssetMarketEntry .CurrentPrice );
200
223
var result = await MatDialogService .ConfirmAsync (" Do you really wish to delete this market order?" );
201
224
if (result )
202
225
{
203
- // TODO update summary
204
226
MarketOrderService .DeleteMarketOrder (order );
227
+ SetEntryLoading ();
228
+ await UpdateEntrySummary ();
229
+ StateHasChanged ();
205
230
}
206
231
}
207
232
}
0 commit comments