public static async Task <bool> RenameAsync(Authentication authentication, IUserCategoryDescriptor descriptor)
        {
            var dialog = await RenameCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            if (dialog != null && await dialog.ShowDialogAsync() == true)
            {
                return(true);
            }
            return(false);
        }
        public static async Task <bool> RenameAsync(Authentication authentication, ITableCategoryDescriptor descriptor)
        {
            var comment = await LockAsync(authentication, descriptor, nameof(ITableCategory.RenameAsync));

            if (comment == null)
            {
                return(false);
            }
            var dialog = await RenameCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            var dialogResult = await ShowDialogAsync(dialog);

            await UnlockAsync(authentication, descriptor, comment);

            return(dialogResult);
        }
Exemple #3
0
        public async Task RenameAsync()
        {
            var categoryPaths = this.dataSet.ExtendedProperties[CremaSchema.TypeDirectory] as string[];
            var dialog        = new RenameCategoryViewModel(this.categoryPath, categoryPaths);

            if (await dialog.ShowDialogAsync() != true)
            {
                return;
            }

            var categoryName = new CategoryName(this.categoryPath)
            {
                Name = dialog.NewName,
            };

            for (var i = 0; i < categoryPaths.Length; i++)
            {
                var categoryPath = categoryPaths[i];
                if (categoryPath.StartsWith(this.categoryPath) == true)
                {
                    categoryPaths[i] = categoryName.Path + categoryPath.Substring(this.categoryPath.Length);
                }
            }

            foreach (var item in this.dataSet.Types)
            {
                var categoryPath = item.CategoryPath;
                if (categoryPath.StartsWith(this.categoryPath) == true)
                {
                    item.CategoryPath = categoryName.Path + categoryPath.Substring(this.categoryPath.Length);
                }
            }

            this.dataSet.ExtendedProperties[CremaSchema.TypeDirectory] = categoryPaths;
            this.categoryPath = categoryName.Path;
            this.categoryName = categoryName.Name;
            this.Refresh();
            if (this.selector != null)
            {
                this.selector.SelectedItem = this;
            }
        }
        public async Task RenameAsync()
        {
            var categoryPaths = CategoryTreeViewItemViewModel.GetAllCategoryPaths(this);
            var dialog        = new RenameCategoryViewModel(this.categoryPath, categoryPaths);

            if (await dialog.ShowDialogAsync() != true)
            {
                return;
            }

            var categoryName = new CategoryName(this.categoryPath)
            {
                Name = dialog.NewName,
            };

            //for (var i = 0; i < categoryPaths.Length; i++)
            //{
            //    var categoryPath = categoryPaths[i];
            //    if (categoryPath.StartsWith(this.categoryPath) == true)
            //    {
            //        categoryPaths[i] = categoryName.Path + categoryPath.Substring(this.categoryPath.Length);
            //    }
            //}

            //foreach (var item in this.dataSet.Tables)
            //{
            //    var categoryPath = item.CategoryPath;
            //    if (categoryPath.StartsWith(this.categoryPath) == true)
            //    {
            //        item.CategoryPath = categoryName.Path + categoryPath.Substring(this.categoryPath.Length);
            //    }
            //}

            this.categoryPath = categoryName.Path;
            this.categoryName = categoryName.Name;
            this.Refresh();
            if (this.selector != null)
            {
                this.selector.SelectedItem = this;
            }
        }
        public static async Task <bool> RenameAsync(Authentication authentication, IUserCategoryDescriptor descriptor)
        {
            var dialog = await RenameCategoryViewModel.CreateInstanceAsync(authentication, descriptor);

            return(dialog?.ShowDialog() == true);
        }