예제 #1
0
 /// <summary>
 /// This handler handles the event when the <see cref="ITransactionRepository.GetTransactionsCompleted"/> 
 /// event is raised by <see cref="_transactionRepository"/>.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TransactionRepositoryGetTransactionsCompleted(object sender, GetTransactionFinishedEventArg e)
 {
     var graphData = GetGraphData(e.TransactionList);//Graph data is calculated in the background thread.
     double income = 0;
     double expense = 0;
     if (e.TransactionList != null)
     {
         income = e.TransactionList.Where(t => t.FlowType == TransactionFlowType.Income).Sum(t => t.Amount);
         expense = e.TransactionList.Where(t => t.FlowType == TransactionFlowType.Expenditure).Sum(t => t.Amount);
     }
     ThreadSafeInvoke(() =>
                          {
                              GraphItems = null;
                              _messagingService.CloseProgressMessage();
                              if (e.HasError)
                              {
                                  _messagingService.ShowMessage(UIText.ERROR_OCCURED_MSG);
                                  return;
                              }
                              if (e.TransactionList == null || !e.TransactionList.Any())
                              {
                                  _messagingService.ShowMessage(UIText.NO_DATA_EXISTS_MSG);
                                  return;
                              }
                              TotalExpenditure = expense;
                              TotalIncome = income;
                              var transactionList = e.TransactionList.Select(t => new TransactionViewModel(t));
                              GraphItems = graphData;
                              Transactions.AddRange(transactionList);
                          });
 }