Ejemplo n.º 1
0
        public void Execute(object parameter)
        {
            MainWindowViewModel mwvm     = parameter as MainWindowViewModel;
            TitleStoreWindow    tsWindow = new TitleStoreWindow
            {
                Owner         = mwvm.Owner,
                SelectedTitle = new Title()
            };

            tsWindow.textBoxTitleId.IsEnabled = true;
            tsWindow.ShowDialog();

            if (tsWindow.IsSaved)
            {
                TitleServiceClient client = new TitleServiceClient();
                if (client.InsertTitle(tsWindow.SelectedTitle))
                {
                    /*
                     * dbset has no concept of index, so we cannot tell the observable collection where it was inserted
                     * if EF was local and not data virtualized, then I would just use public ObservableCollection<T> Local { get; }
                     * instead, we have to reset the page in case the add insert it into the current page - not so pretty but it works
                     */
                    //mwvm.TitleDataVirtualized.Insert(?, tsWindow.SelectedTitle);
                    mwvm.TitleDataVirtualized.ResetAsync();
                }
            }
        }
Ejemplo n.º 2
0
        public void Execute(object parameter)
        {
            MainWindowViewModel mwvm = parameter as MainWindowViewModel;

            if (mwvm.SelectedTitle != null)
            {
                TitleStoreWindow tsWindow = new TitleStoreWindow
                {
                    Owner         = mwvm.Owner,
                    SelectedTitle = mwvm.SelectedTitle
                };

                tsWindow.textBoxTitleId.IsEnabled = false;

                tsWindow.ShowDialog();

                if (tsWindow.IsSaved)
                {
                    TitleServiceClient client = new TitleServiceClient();

                    if (client.UpdateTitle(tsWindow.SelectedTitle))
                    {
                        mwvm.SelectedTitle = tsWindow.SelectedTitle;
                    }
                }
            }
            else
            {
                MessageBox.Show("No title selected for update.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }