/// <summary> /// Opens a dialog for creating a new revision of the current product /// </summary> private async Task CreateRevision(ProductItemViewModel productItem) { var dialog = new CreateRevisionViewModel(ProductServiceModel, productItem.Product); await DialogManager.ShowDialogAsync(dialog); if (!dialog.Result || dialog.CreatedProduct == null) { return; } var createdProduct = dialog.CreatedProduct; IsBusy = true; // Get group var group = ProductGroups.Single(t => t.TypeName == dialog.CreatedProduct.Type); // Create new tree item var newItem = new ProductItemViewModel(createdProduct.Model); group.Children.Add(newItem); // Change selection productItem.IsSelected = false; newItem.IsSelected = true; // Remove old version group.Children.Remove(productItem); // To be prepared, update complete tree await UpdateTreeAsync(); // Now we are not busy anymore. IsBusy = false; }
private async Task DuplicateProduct(object obj) { var productItem = (ProductItemViewModel)SelectedItem; var dialog = new DuplicateProductDialogViewModel(ProductServiceModel, productItem.Product); await DialogManager.ShowDialogAsync(dialog); if (!dialog.Result) { return; } if (IsEditMode) { CancelEdit(); } IsBusy = true; // Get group var group = ProductGroups.Single(t => t.TypeName == dialog.ClonedProduct.Type); // Create new tree item var newItem = new ProductItemViewModel(dialog.ClonedProduct); group.Children.Add(newItem); // Change selection productItem.IsSelected = false; newItem.IsSelected = true; // To be prepared, update complete tree await UpdateTreeAsync(); // Now we are not busy anymore. IsBusy = false; }