public UserCategoryDescriptor(Authentication authentication, IUserCategoryDescriptor descriptor, bool isSubscriptable, object owner) : base(authentication, descriptor.Target, descriptor, isSubscriptable) { this.category = descriptor.Target; this.owner = owner ?? this; this.usersReadonly = new ReadOnlyObservableCollection <UserDescriptor>(this.users); this.categoriesReadonly = new ReadOnlyObservableCollection <UserCategoryDescriptor>(this.categories); }
public static async Task <bool> MoveAsync(Authentication authentication, IUserCategoryDescriptor descriptor) { var dialog = await MoveUserCategoryViewModel.CreateInstanceAsync(authentication, descriptor); if (dialog != null && await dialog.ShowDialogAsync() == true) { return(true); } return(false); }
public static Task <RenameCategoryViewModel> CreateInstanceAsync(Authentication authentication, IUserCategoryDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Target is IUserCategory category) { return(category.Dispatcher.InvokeAsync(() => { return new RenameCategoryViewModel(authentication, category); })); } else { throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor)); } }
public static Task <MoveUserCategoryViewModel> CreateInstanceAsync(Authentication authentication, IUserCategoryDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Target is IUserCategory category) { return(category.Dispatcher.InvokeAsync(() => { var categories = category.GetService(typeof(IUserCategoryCollection)) as IUserCategoryCollection; var targetPaths = categories.Select(item => item.Path).ToArray(); return new MoveUserCategoryViewModel(authentication, category, targetPaths); })); } else { throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor)); } }
public static async Task <bool> DeleteAsync(Authentication authentication, IUserCategoryDescriptor descriptor) { var dialog = await DeleteUserCategoryViewModel.CreateInstanceAsync(authentication, descriptor); return(dialog?.ShowDialog() == true); }
public static async Task <string> NewFolderAsync(Authentication authentication, IUserCategoryDescriptor descriptor) { var dialog = await NewUserCategoryViewModel.CreateInstanceAsync(authentication, descriptor); if (dialog?.ShowDialog() == true) { return(dialog.CategoryName); } return(null); }
public static bool CanNewFolder(Authentication authentication, IUserCategoryDescriptor descriptor) { return(authentication.Authority == Authority.Admin); }
public static bool CanDelete(Authentication authentication, IUserCategoryDescriptor _) { return(authentication.Authority == Authority.Admin); }