Exemple #1
0
        public MainWindowViewModel()
        {
            Logger.Info("Initializing...");

            // DB Context (SQLite)
            var context = new MainDbContext();

            // Create ViewModel collection from the models
            Companies = context.Companies
                        .ToObservable()
                        .Select(x => new CompanyViewModel(x))
                        .ToReactiveCollection();
            // SelectFileCommand is fired from click event of button through EventToReactiveCommand.
            // SelectedFilename will be set after a file selected from OpenFileDialog through OpenFileDialogConverter.
            SelectedFilename = SelectFileCommand
                               .Select(filename => filename)
                               .ToReadOnlyReactiveProperty();
            // ReactiveCommand (can execute when SelectedFilename is set)
            StartCommand = SelectedFilename.Select(x => !string.IsNullOrWhiteSpace(x)).ToReactiveCommand <string>();
            StartCommand.Subscribe(async _ =>
            {
                var res = await ConfirmationRequest.RaiseAsync(new Confirmation {
                    Title = "Demo", Content = "Are you sure?"
                });
                if (res.Confirmed)
                {
                    await NotificationRequest.RaiseAsync(new Notification {
                        Title = "Demo", Content = "Done!"
                    });
                }
            });
            Logger.Info("Initialized.");
        }
        private async Task DeleteOrderExecute()
        {
            IsLoading = true;
            var confirmation = await ConfirmationRequest.RaiseAsync(new Confirmation
            {
                Content = $"Вы действительно хотите удалить заказ по документу {SelectedOrder.NDoc}?",
                Title   = "Внимание!"
            });

            if (confirmation.Confirmed)
            {
                await _orderRepository.Delete(SelectedOrder.GetOrder().Id);
                await UpdateOrders();
            }
            IsLoading = false;
        }