public static bool TargetNodeIsDropCandidate(NodeEntityBase target, NodeEntityBase candidate)
        {
            if (target.GetType() == candidate.GetType() &&
                target.Id == candidate.Id)
            {
                return(true);
            }

            if (target.ParentId == candidate.Id &&
                target.ParentType == (ParentType)System.Enum.Parse(typeof(ParentType), candidate.GetType().Name))
            {
                return(true);
            }

            return(false);
        }
        public static bool TargetNodeIsDropCandidate(NodeEntityBase target, NodeEntityBase candidate)
        {
            if (target.GetType() == candidate.GetType()
                && target.Id == candidate.Id)
            {
                return true;
            }

            if (target.ParentId == candidate.Id
                && target.ParentType == (ParentType)System.Enum.Parse(typeof(ParentType), candidate.GetType().Name))
            {
                return true;
            }

            return false;
        }
        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 = MessageTypeEnum.Error,
                    Text = ex.Message
                }, true);

                IsBusy = false;
            }
            finally
            {
                OnPropertyChanged("");
            }
        }