public bool Save(Action<bool> saved)
        {
            this.DocumentControl.saveButton.IsEnabled = false;

            if (!mDocument.IsActive)
            {
                return true;//bye bye  not allowed to save.
            }

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            AddDocumentRevisionHistoryDialog dialog = new AddDocumentRevisionHistoryDialog(mDocument.Id);
            dialog.Show();

            dialog.Closed +=
                (s1, e1) =>
                {
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        cmsWebServiceClient.SaveDocumentCompleted +=
                            (s, e) =>
                            {

                                if (e.Result.HasErrors)
                                {
                                    var errorDialog = new PopupDialog(PopupDialogType.Error, Utils.DisplayErrorMessages(e.Result.ServerErrorMessages));
                                    errorDialog.Show();
                                    return;
                                }

                                QuickDocument quickDocument = e.Result.EntityResult;

                                //Reset controls to Original Values
                                Utils.ResetOriginalValues(DocumentControl.LayoutGrid);
                                Utils.ResetOriginalValues(mDocumentVersionsControl.Content);
                                Utils.ResetOriginalValues(mDocumentRelatedIssuesControl.Content);

                                //Clear all changes on the Tab
                                Utils.ClearAllChangeEvents(EventAggregator, mDocument);
                                Utils.ResetOriginalValues((UIElement)AttachmentsTab.Content);

                                if (saved != null)
                                {
                                    saved(true);
                                }

                                //QuickDocument cachedItem = (from x in CMS.Cache.Documents where x.Id == mDocument.Id select x).FirstOrDefault();
                                //if (cachedItem != null)
                                //{
                                //    CommonUtils.CloneObject(cachedItem, quickDocument, quickDocument.Id.ToString());
                                //    cachedItem.RaisePropertyChanged("Name");
                                //    cachedItem.RaisePropertyChanged("Description");
                                //    CMS.Cache.Documents.FireProcessFilter();
                                //}
                                //else
                                //{
                                //    CMS.Cache.Documents.Add(e.Result.EntityResult);
                                //}
                            };

                        //-------------BEFORE SAVE-------------------------------------------------------
                        if (mDocument.ModifiedObjects.RelatedIssuesModified)
                        {
                            List<IssueRelatedDocument> issueRelatedDocuments = mDocument.IssueRelatedDocuments;
                            mDocumentViewModel.Document.IssueRelatedDocuments = issueRelatedDocuments;
                            mDocumentViewModel.Document.ModifiedObjects.RelatedIssuesModified = true;
                        }
                        else
                        {
                            mDocumentViewModel.Document.ModifiedObjects.RelatedIssuesModified = false;
                        }

                        if (mDocument.ModifiedObjects.EquipmentsModified)
                        {
                            List<DocumentEquipment> issueRelatedDocuments = mDocument.DocumentEquipments;
                            mDocumentViewModel.Document.DocumentEquipments = issueRelatedDocuments;
                            mDocumentViewModel.Document.ModifiedObjects.EquipmentsModified = true;
                        }
                        else
                        {
                            mDocumentViewModel.Document.ModifiedObjects.EquipmentsModified = false;
                        }

                        cmsWebServiceClient.SaveDocumentAsync(mDocument, CMS.User.Id);

                        //RevisionHistory.RevisionHistoryGridView.Items.Insert(0, dialog.AddedRevisionHistory);
                        RevisionHistory.LoadRevisionHistory(CommonUtils.TabId.Documents, mDocument.Id);
                    }

                    this.DocumentControl.saveButton.IsEnabled = true;
                };

            return true;
        }
        private void RemoveButtonHandler(object parameter)
        {
            AddDocumentRevisionHistoryDialog popupDialog = new AddDocumentRevisionHistoryDialog(mDocument.Id);
            popupDialog.Show();
            popupDialog.Closed +=
                (s2, e2) =>
                {
                    if (popupDialog.DialogResult.HasValue && popupDialog.DialogResult.Value)
                    {

                        var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
                        cmsWebServiceClient.DeleteDocumentCompleted +=
                            (s1, e1) =>
                            {
                                //QuickDocument cachedItem = (from x in CMS.Cache.Documents where x.Id == Document.Id select x).FirstOrDefault();
                                //cachedItem.IsActive = false;
                                //cachedItem.RaisePropertyChanged("Name");
                                //cachedItem.RaisePropertyChanged("Description");
                                //CMS.Cache.Documents.FireProcessFilter();

                                EventAggregator.GetEvent<PrismEvents.CloseTabPrismEvent>().Publish(Document);
                            };

                        cmsWebServiceClient.DeleteDocumentAsync(Document.Id, CMS.User.Id);
                    }
                };
        }