public ConfigurationAuthorisationViewModel(ViewModelContext viewModelContext, AuthorisationManagerServiceManager authorisationManagerServiceManager) : base(viewModelContext) { this.authorisationManagerServiceManager = authorisationManagerServiceManager; NewUserCommand = new WpfCommand(OnNewUser); NewRoleCommand = new WpfCommand(OnNewRole); NewActivityCommand = new WpfCommand(OnNewActivity); SaveCommand = new WpfCommand(OnEntitySave); DeleteCommand = new WpfCommand(OnEntityDelete); RemoveItemCommand = new WpfCommand(OnRemoveItem); DragDropCommand = new WpfCommand(OnDragDrop); SelectItemCommand = new WpfCommand(OnSelectItem); Logger.Log("ConfigurationAuthorisationViewModel initialised", Category.Info, Priority.None); }
private async void AddRole(RoleNode roleNode, NodeEntityBase target) { try { IsBusy = true; if (AuthorisationManagerServiceManager.TargetNodeIsDropCandidate(target, roleNode)) { return; } if (target is RoleNode) { var targets = Roles.Flatten <RoleNode>(t => t.Id.Equals(target.Id), Users); var result = await authorisationManagerServiceManager.AddRole(roleNode, (RoleNode)target, targets); } else if (target is UserNode) { var targets = Users.Where(t => t.Id.Equals(target.Id)); var result = await authorisationManagerServiceManager.AddRole(roleNode, (UserNode)target, targets); } else { throw new Exception( string.Format( "Invalid drop target. '{0}' can only be dropped onto a user or another role.", roleNode.Text)); } ResetStatus(); } catch (Exception ex) { ShowMessage(new Message() { MessageType = MessageType.Error, Text = ex.Message }, true); IsBusy = false; } finally { OnPropertyChanged(""); } }