public void Delete()
        {
            var dispatcher = RequestDispatcherFactory.CreateAsyncRequestDispatcher();

            dispatcher.Add(new DeleteUserGroupRequest {
                UserGroupId = BindingModel.Id.Value
            });
            dispatcher.ProcessRequests(DeleteUserGroup_ResponseReceived, PublishRemoteException);
        }
        public override void Initialize()
        {
            EventAggregator.Subscribe(this);

            var requestDispatcher = RequestDispatcherFactory.CreateAsyncRequestDispatcher();

            requestDispatcher.Add(new CheckPermissionsRequest {
                PermissionsToCheck = new[] { Permissions.CreateUserGroup }
            });
            requestDispatcher.Add(new GetAllUserGroupsRequest());
            requestDispatcher.ProcessRequests(ResponsesReceived, PublishRemoteException);
        }
        public void PersistChanges()
        {
            BindingModel.ValidateAll();
            if (BindingModel.HasErrors)
            {
                return;
            }

            var dispatcher = RequestDispatcherFactory.CreateAsyncRequestDispatcher();

            dispatcher.Add(new SaveUserGroupRequest
            {
                Id       = BindingModel.Id,
                Name     = BindingModel.Name,
                ParentId = BindingModel.SelectedParentUserGroup.Id != Guid.Empty ? BindingModel.SelectedParentUserGroup.Id : (Guid?)null
            });
            dispatcher.ProcessRequests(PersistChanges_ResponseReceived, PublishRemoteException);
        }
        private void LoadData(Guid?userGroupId = null)
        {
            BindingModel.Clear();

            var requestDispatcher = RequestDispatcherFactory.CreateAsyncRequestDispatcher();

            if (userGroupId.HasValue)
            {
                requestDispatcher.Add(new CheckPermissionsRequest {
                    PermissionsToCheck = new[] { Permissions.DeleteUserGroup, Permissions.EditUserGroup }
                });
                requestDispatcher.Add(new GetUserGroupRequest {
                    UserGroupId = userGroupId.Value
                });
            }
            requestDispatcher.Add(new GetSuitableParentUserGroupsRequest {
                UserGroupId = userGroupId
            });
            requestDispatcher.ProcessRequests(ResponsesReceived, PublishRemoteException);
        }