Exemple #1
0
        private void InitializeViewModel()
        {
            _viewModel = new TransactionsPageViewModel()
            {
                // transactions
                AddRecordCommand = new Command(() =>
                                               OpenDetails(_recordService.PrepareNew(new RecordModel()
                {
                    UserId = GlobalVariables.UserId
                }), true)),

                AddMoneyTransferCommand = new Command(() => OpenDetails(new MoneyTransferModel(), true)),
                AddChequeCommand        = new Command(() =>
                {
                    var chequeWindow   = new ChequeWindow();
                    chequeWindow.Owner = Window.GetWindow(this);
                    if (chequeWindow.ShowDialog() == true)
                    {
                        Reload();
                    }
                }),

                EditTransactionCommand   = InitTransactionEditCommand(),
                DeleteTransactionCommand = InitTransactionDeleteCommand(),

                ApplyNowPlannedTransactionCommand   = InitTransactionApplyNowCommand(),
                CreateTransactionFromPlannedCommand = InitTransactionCreateTransactionCommand(),

                DuplicateAndApplyNowTransactionCommand = InitDuplicateAndApplyNowCommand(),
                DuplicateTransactionCommand            = InitDuplicateTransactionCommand(),

                CreateTemplateFromTransactionCommand = InitCreateTemplateFromTransactionCommand(),

                // templates
                AddRecordTemplateCommand = new Command(() =>
                                                       OpenDetails(_recordTemplateService.PrepareNew(new RecordTemplateModel()
                {
                    UserId = GlobalVariables.UserId
                }), true)),

                AddMoneyTransferTemplateCommand = new Command(() => OpenDetails(new MoneyTransferTemplateModel(), true)),

                EditTemplateCommand   = InitTemplateEditCommand(),
                DeleteTemplateCommand = InitTemplateDeleteCommand(),

                ApplyNowTemplateCommand = InitTemplateApplyNowCommand(),
                CreateTransactionFromTemplateCommand = InitTemplateCreateTransactionCommand()
            };

            this.DataContext = _viewModel;
        }
Exemple #2
0
        private void InitializeViewModel()
        {
            _viewModel = new TodayTransactionsDashboardItemModel()
            {
                AddRecordCommand = new Command(() =>
                                               OpenDetails(_recordService.PrepareNew(new RecordModel()
                {
                    UserId = GlobalVariables.UserId
                }), true)),

                AddMoneyTransferCommand = new Command(() => OpenDetails(new MoneyTransferModel(), true)),
                AddChequeCommand        = new Command(() =>
                {
                    var chequeWindow   = new ChequeWindow();
                    chequeWindow.Owner = Window.GetWindow(this);
                    if (chequeWindow.ShowDialog() == true)
                    {
                        Reload();
                    }
                }),

                EditCommand = new DataGridSelectedItemCommand <ITransaction>(GridTransactions,
                                                                             (item) =>
                {
                    if (item is RecordModel)
                    {
                        OpenDetails(item as RecordModel);
                    }
                    if (item is MoneyTransferModel)
                    {
                        OpenDetails(item as MoneyTransferModel);
                    }
                }, item => !item.IsPlanned, true),

                DeleteCommand = new DataGridSelectedItemsCommand <ITransaction>(GridTransactions,
                                                                                (items) => EntityViewHelper.ConfirmAndRemove(items, _service.Delete, "Transaction", items.Select(_ => _.Description), () =>
                {
                    // remove in grid
                    foreach (var item in items.ToList())
                    {
                        _viewModel.Entities.Remove(item);
                    }
                }),
                                                                                (items) => !items.Any(_ => _.IsPlanned))
            };

            this.DataContext = _viewModel;
        }