/// <summary>
 /// Implement cancelation request. Save Item if need
 /// </summary>
 /// <param name="arg"></param>
 private void RaiseCancelInteractionRequest(object arg)
 {
     if (!IsModified)
     {
         OnCloseViewRequestedEvent(EventArgs.Empty);
     }
     else if (!HasPermission())
     {
         CloseWithoutSave();
     }
     else
     {
         CancelConfirmRequest.Raise(CancelConfirm(), (x) =>
         {
             if (x.Confirmed)
             {
                 SaveUI(true);                                                                            //check thread
             }
             else if (((RefusedConfirmation)x).Refused)
             {
                 CloseWithoutSave();
             }
             else
             {
                 // cancel closing
                 var cancelArgs = arg as System.ComponentModel.CancelEventArgs;
                 if (cancelArgs != null)
                 {
                     cancelArgs.Cancel = true;
                     OpenItemCommand.Execute();
                 }
             }
         });
     }
 }
        protected void OnCancelCommand(object arg)
        {
            if (IsModified)
            {
                CancelConfirmRequest.Raise(new RefusedConfirmation {
                    Content = "Save changes to Import job '" + DisplayName + "'?", Title = "Action confirmation"
                },
                                           (x) =>
                {
                    if (x.Confirmed)
                    {
                        //if (InnerItem.Validate())
                        //{
                        IsInitializing = true;

                        PerformTasksInBackgroundWorker((Action) delegate()
                        {
                            DoSaveChanges();
                            OnUIThread((Action) delegate() { OnCloseViewRequestedEvent(EventArgs.Empty); });
                        }, (Action) delegate() { IsInitializing = false; });
                        //}
                    }
                    else if (((RefusedConfirmation)x).Refused)
                    {
                        InnerItem = _originalItem;

                        IsModified = false;
                        OnCloseViewRequestedEvent(EventArgs.Empty);
                    }
                    else
                    {
                        // cancel closing
                        var cancelArgs = arg as System.ComponentModel.CancelEventArgs;
                        if (cancelArgs != null)
                        {
                            cancelArgs.Cancel = true;
                            OpenItemCommand.Execute();
                        }
                    }
                });
            }
            else
            {
                OnCloseViewRequestedEvent(EventArgs.Empty);
            }
        }