예제 #1
0
        private void InitializeChart()
        {
            //filter by currency
            OperationDtoFilter  filter       = GetChartFilter();
            List <OperationDto> filteredList = _operationRepo.Filter(filter);

            //filter by category
            List <OperationTypeDto> categories = _operationTypeRepo.All();

            List <ChartItem> values = new List <ChartItem>();

            foreach (OperationTypeDto category in categories)
            {
                ChartItem chartItem = new ChartItem()
                {
                    Name  = category.Name,
                    Value = filteredList
                            .Where(d => d.IdOperationType == category.Id)
                            .Sum(d => d.Ammount)
                };
                values.Add(chartItem);
            }

            pieSeries.ItemsSource = values;
        }
예제 #2
0
        private void InitializeTransactions()
        {
            //unsub from events
            foreach (var item in spTransactions.Children)
            {
                EditableTransactionControl control = (EditableTransactionControl)item;
                control.btnEditOperation.Click   -= BtnEditOperation_Click;
                control.btnDeleteOperation.Click -= BtnDeleteOperation_Click;
            }

            spTransactions.Children.Clear();

            // Get present filter
            OperationDtoFilter filter = GetFilter();

            List <OperationDto> operationDtos = _operationRepo.Filter(filter);

            operationDtos = operationDtos.OrderByDescending(d => d.Date).ToList();

            foreach (OperationDto operationDto in operationDtos)
            {
                EditableTransactionControl transactionControl = new EditableTransactionControl();

                transactionControl.IdOperation = operationDto.Id;

                transactionControl.dpTransaction.Text = operationDto.Date.ToString("dd/MMM/yyyy");
                transactionControl.tbCurrency.Text    = operationDto.Account.Currency.Name;
                transactionControl.tbAccount.Text     = operationDto.Account.Name;
                transactionControl.tbAmmount.Text     = operationDto.Ammount.ToString();
                transactionControl.tbCategory.Text    = operationDto.OperationType.Name;
                transactionControl.tbDescription.Text = operationDto.Description;

                transactionControl.btnEditOperation.Click   += BtnEditOperation_Click;
                transactionControl.btnDeleteOperation.Click += BtnDeleteOperation_Click;

                spTransactions.Children.Add(transactionControl);
            }
        }