Пример #1
0
        public CategoriesViewModel(Client client)
        {
            _client = client;

            Categories = new ObservableCollection<Category>(
                _client.Context.Categories.ToList());

            AddNewCategoryRequest = new InteractionRequest<IConfirmation>();
            AddCategoryCommand = new DelegateCommand(() =>
                AddNewCategoryRequest.Raise(
                    new Confirmation()
                    {
                        Title = "Nowa kategoria",
                        Content = new System.Windows.Controls.TextBox()
                        {
                            VerticalAlignment = System.Windows.VerticalAlignment.Top
                        }
                    },
                    AddCategory));
            ConfirmDeleteCategoryRequest = new InteractionRequest<IConfirmation>();
            DeleteCategoryCommand = new DelegateCommand(() =>
                ConfirmDeleteCategoryRequest.Raise(
                    new Confirmation()
                    {
                        Title = "Potwierdź",
                        Content = "Czy na pewno usunąć wybraną kategorię?"
                    },
                    DeleteCategory)
                , CanDeleteCategory);
        }
Пример #2
0
        public void WhenANotificationIsRequested_ThenTheEventIsRaisedWithTheSuppliedContext()
        {
            var request = new InteractionRequest<Notification>();
            object suppliedContext = null;
            request.Raised += (o, e) => suppliedContext = e.Context;

            var context = new Notification();

            request.Raise(context, c => { });

            Assert.AreSame(context, suppliedContext);
        }
Пример #3
0
        public void WhenANotificationIsRequested_ThenTheEventIsRaisedWithTheSuppliedContext()
        {
            var    request         = new InteractionRequest <Notification>();
            object suppliedContext = null;

            request.Raised += (o, e) => suppliedContext = e.Context;

            var context = new Notification();

            request.Raise(context, c => { });

            Assert.AreSame(context, suppliedContext);
        }
        private void ShowPrintSetupDialog()
        {
            Confirmation confirm = new Confirmation();

            confirm.Title = ApplicationStrings.PrintSetupDialogTitle;
            PrintSetupRequest.Raise(confirm,
                                    r => {
                if (r != null && r.Confirmed)
                {
                    // do something!
                }
            });     //)
        }
Пример #5
0
 public MainViewModel()
 {
     NotificationRequest = new InteractionRequest<INotification>();
     NotificationCommand = new DelegateCommand(() =>
     {
         NotificationRequest.Raise(new Notification
         {
             Title = "Notification",
             Content = "Notification message displayed"
         },
         (i) => Status = "Done");
     });
 }
        public void WhenAssociatedObjectIsUnloaded_ShouldNotReactToEventBeingRaised()
        {
            InteractionRequest <INotification> request = new InteractionRequest <INotification>();
            TestableInteractionRequestTrigger  trigger = new TestableInteractionRequestTrigger();
            MockFrameworkElement associatedObject      = new MockFrameworkElement();

            trigger.Attach(associatedObject);
            trigger.SourceObject = request;

            Assert.IsTrue(trigger.ExecutionCount == 0);

            request.Raise(new Notification());
            Assert.IsTrue(trigger.ExecutionCount == 1);

            associatedObject.RaiseUnloaded();
            request.Raise(new Notification());
            Assert.IsTrue(trigger.ExecutionCount == 1);

            trigger.Detach();
            request.Raise(new Notification());
            Assert.IsTrue(trigger.ExecutionCount == 1);
        }
Пример #7
0
        /// <summary>
        /// パネルの開閉リクエストをViewに投げる
        /// </summary>
        private void RisePanelState()
        {
            var state = new PanelStateEntity()
            {
                LeftPanelOpen   = this.LeftPanelOpen.Value,
                TopPanelOpen    = this.TopPanelOpen.Value,
                BottomPanelOpen = this.BottomPanelOpen.Value,
            };

            // Viewにリクエストを投げる
            _PanelOpenRequest.Raise(new Confirmation {
                Content = state
            });
        }
        public void Execute(object parameter)
        {
            var parameters = (object[])parameter;
            ObservableCollection <ObservableCollection <Invoice> > matchedList = (ObservableCollection <ObservableCollection <Invoice> >)parameters[0];
            ObservableCollection <Invoice> selectedMatchedList = (ObservableCollection <Invoice>)parameters[1];

            InsertInvoicesViewModel insertInvoicesViewModel = new InsertInvoicesViewModel();

            myInteractionRequest.Raise(new Confirmation()
            {
                Title   = "Insert payment details",
                Content = insertInvoicesViewModel
            },
                                       _ =>
            {
                if (_.Confirmed)
                {
                    if (insertInvoicesViewModel.UserInput != null)
                    {
                        List <string> invoiceNumbers = insertInvoicesViewModel.UserInput.ExtractInvoiceNumbers();

                        if (!invoiceNumbers.IsNullOrEmpty())
                        {
                            ObservableCollection <Invoice> foundInvoices = new ObservableCollection <Invoice>(myFacade.Invoices.Where(invoice => invoiceNumbers.Contains(invoice.InvoiceNumber)));
                            if (!foundInvoices.IsNullOrEmpty())
                            {
                                if (matchedList.Count == 0)
                                {
                                    matchedList.Add(foundInvoices);
                                    myEventAggregator.GetEvent <SelectedMatchedListChangedEvent>().Publish(foundInvoices);
                                }
                                else
                                {
                                    if (selectedMatchedList == null)
                                    {
                                        return;
                                    }

                                    foreach (Invoice invoice in foundInvoices)
                                    {
                                        selectedMatchedList.Add(invoice);
                                    }
                                    myEventAggregator.GetEvent <SelectedMatchedListChangedEvent>().Publish(selectedMatchedList);
                                }
                            }
                        }
                    }
                }
            });
        }
        internal static void RaisePropertyValueEditInteractionRequest <T>(IViewModelsFactory <IPropertyValueBaseViewModel> _vmFactory, InteractionRequest <Confirmation> confirmRequest, ICatalogEntityFactory entityFactory, Action <PropertyAndPropertyValueBase, PropertyAndPropertyValueBase> finalAction, PropertyAndPropertyValueBase originalItem, string locale) where T : PropertyValueBase
        {
            var item = originalItem.DeepClone(entityFactory as CatalogEntityFactory);

            T itemValue;

            if (!originalItem.IsMultiValue)
            {
                item.Values = new ObservableCollection <PropertyValueBase>();
                if (originalItem.Value == null)
                {
                    itemValue = (T)entityFactory.CreateEntityForType(typeof(T));
                    if (originalItem.Property != null)
                    {
                        itemValue.ValueType = originalItem.Property.PropertyValueType;
                    }
                    item.Value = itemValue;
                }
            }
            else if (originalItem.Values == null)
            {
                //itemValue = (T)entityFactory.CreateEntityForType(typeof(T));
                // item.CategoryId = InnerItem.CategoryId;
                //if (originalItem.Property != null)
                //	itemValue.ValueType = originalItem.Property.PropertyValueType;
                item.Values = new ObservableCollection <PropertyValueBase>();
            }
            //else
            //{
            //	itemValue = (T)originalItem.Value.DeepClone(entityFactory as CatalogEntityFactory);
            //}


            var itemVM = _vmFactory.GetViewModelInstance(
                new KeyValuePair <string, object>("item", item),
                new KeyValuePair <string, object>("locale", locale));

            var confirmation = new ConditionalConfirmation(itemVM.Validate)
            {
                Title = "Edit property value".Localize(), Content = itemVM
            };

            confirmRequest.Raise(confirmation, (x) =>
            {
                if (x.Confirmed)
                {
                    finalAction(originalItem, item);
                }
            });
        }
        public void RaiseNotification(DependencyObject parent)
        {
            Confirmation confirmation = new Confirmation();

            confirmation.Title = this.Title;

            InteractionRequestTrigger          trigger     = new InteractionRequestTrigger();
            InteractionRequest <INotification> interaction = new InteractionRequest <INotification>();

            trigger.SourceObject = interaction;
            trigger.Actions.Add(CreateAction());
            trigger.Attach(parent);
            interaction.Raise(confirmation, this.Callback);
        }
Пример #11
0
        private void OnDeleteSelectedSessions()
        {
            var numberOfSessions = _selectedSessions.Count;

            _confirmationRequest.Raise(
                new Confirmation
            {
                Caption = Properties.SessionManager.SessionDeleteConfirmTitle,
                Message = numberOfSessions == 1
                        ? Properties.SessionManager.SessionDeleteConfirmSingular
                        : Properties.SessionManager.SessionDeleteConfirmPlural.FormatEx(numberOfSessions)
            },
                DeleteSessions);
        }
Пример #12
0
        public void DeleteSelectedEvents()
        {
            var numberOfEvents = SelectedEvents.Count;

            _confirmationRequest.Raise(
                new Confirmation
            {
                Caption = Properties.SessionManager.EventDeleteConfirmTitle,
                Message = numberOfEvents == 1
                        ? Properties.SessionManager.EventDeleteConfirmSingular
                        : Properties.SessionManager.EventDeleteConfirmPlural.FormatEx(numberOfEvents)
            },
                DoDeleteSelectedEvents);
        }
        public void WhenSourceObjectIsSet_ShouldSubscribeToRaisedEvent()
        {
            InteractionRequest <INotification> request = new InteractionRequest <INotification>();
            TestableInteractionRequestTrigger  trigger = new TestableInteractionRequestTrigger();
            DependencyObject associatedObject          = new DependencyObject();

            trigger.Attach(associatedObject);
            trigger.SourceObject = request;

            Assert.IsTrue(trigger.ExecutionCount == 0);

            request.Raise(new Notification());
            Assert.IsTrue(trigger.ExecutionCount == 1);
        }
        private void ConfirmCreate()
        {
            if (string.IsNullOrWhiteSpace((Notification as SupplierContactCreateUpdateNotif).NewContact.Name))
            {
                //MessageBox.Show("联系人为空");
                NotificationRequest.Raise(new Notification {
                    Content = "联系人姓名为空", Title = "错误提示"
                });
                return;
            }

            //_notification.NewContact = NewContact;
            _notification.Confirmed = true;
            FinishInteraction?.Invoke();
        }
Пример #15
0
        public void WhenTheEventCallbackIsExecuted_ThenTheNotifyCallbackIsInvokedWithTheSuppliedContext()
        {
            var request = new InteractionRequest<Notification>();
            Action eventCallback = null;
            request.Raised += (o, e) => eventCallback = e.Callback;

            var context = new Notification();
            object suppliedContext = null;

            request.Raise(context, c => { suppliedContext = c; });

            eventCallback();

            Assert.AreSame(context, suppliedContext);
        }
Пример #16
0
        public void RaiseNotification(DependencyObject parent)
        {
            Confirmation tilesetConfirmation = new Confirmation();

            tilesetConfirmation.Title   = this.Title;
            tilesetConfirmation.Content = this.tilesetModel;

            InteractionRequestTrigger          trigger     = new InteractionRequestTrigger();
            InteractionRequest <INotification> interaction = new InteractionRequest <INotification>();

            trigger.SourceObject = interaction;
            trigger.Actions.Add(GetAction());
            trigger.Attach(parent);
            interaction.Raise(tilesetConfirmation, this.Callback);
        }
 private void SubscribeToEvents()
 {
     m_ApplicationClosingSubscriptionToken =
         m_EventService.GetEvent <PubSubEvent <ApplicationClosingPayload> >()
         .Subscribe(payload =>
     {
         try
         {
             IsBusy = true;
             if (IsProjectUpdated)
             {
                 var confirmation = new Confirmation()
                 {
                     Title   = Properties.Resources.Title_UnsavedChanges,
                     Content = Properties.Resources.Message_UnsavedChanges
                 };
                 m_ConfirmationInteractionRequest.Raise(confirmation);
                 if (!confirmation.Confirmed)
                 {
                     payload.IsCanceled = true;
                 }
             }
         }
         catch (Exception ex)
         {
             DispatchNotification(
                 Properties.Resources.Title_Error,
                 ex.Message);
         }
         finally
         {
             IsBusy = false;
             RaiseCanExecuteChangedAllCommands();
         }
     }, ThreadOption.PublisherThread);
 }
Пример #18
0
        public override void RaiseInteraction()
        {
            MailNotification notification = new MailNotification();

            notification.DestinationAddress = DestinationAddress;
            notification.SenderAddress      = SenderAddress;
            notification.SmtpPort           = SmtpPort;
            notification.SmtpServer         = SmtpServer;
            notification.OutLookEnable      = OutlookEnable;
            notification.GmailEnabled       = GmailEnable;
            if (InteractionRequest != null)
            {
                InteractionRequest.Raise(notification);
            }
        }
Пример #19
0
        /// <summary>
        /// Yes,Noを求めるダイアログを出すリクエストを送信し、結果を返す
        /// </summary>
        /// <param name="interactionRequest"></param>
        /// <param name="title">ダイアログのタイトル</param>
        /// <param name="content">ダイアログの内容</param>
        /// <returns></returns>
        public static bool RaiseEx(this InteractionRequest <Confirmation> interactionRequest, string title, string content)
        {
            bool res = false;

            interactionRequest.Raise(new Confirmation
            {
                Title   = title,
                Content = content
            },
                                     n =>
            {
                res = n.Confirmed;
            });
            return(res);
        }
Пример #20
0
 private void ShowRegister(RegisterValues reg)
 {
     RegisterRequest.Raise(new RegisterConfirmation(reg.Challenge, reg.Serial), x =>
     {
         if (!x.Confirmed)
         {
             App.Current.Shutdown();
             return;
         }
         ISettingsService service = _container.Resolve <ISettingsService>();
         var set    = service.Get();
         set.Serial = x.Serial;
         service.Update(set);
     });
 }
Пример #21
0
    public IdleModel() : base()
    {
        icons.Add("lexianggame");
        icons.Add("haidilao");
        icons.Add("kendeji");

        this.showWheelRequest = new InteractionRequest <WheelViewModel>(this);

        this.showWheel = new SimpleCommand(() => {
            var model = new WheelViewModel();
            showWheelRequest.Raise(model);
        });

        Icon = icons[0];
    }
        private void OpenPropertySelectionDialog()
        {
            Confirmation confirmation = new Confirmation()
            {
                Title = "Select property", Content = this
            };

            _PropertySelectionDialog.Raise(confirmation, response =>
            {
                if (response.Confirmed)
                {
                    OnExpressionSelected((HermesViewModel)response.Content);
                }
            });
        }
Пример #23
0
        public void WhenTheEventCallbackIsExecuted_ThenTheNotifyCallbackIsInvokedWithTheSuppliedContext()
        {
            var    request       = new InteractionRequest <Notification>();
            Action eventCallback = null;

            request.Raised += (o, e) => eventCallback = e.Callback;

            var    context         = new Notification();
            object suppliedContext = null;

            request.Raise(context, c => { suppliedContext = c; });

            eventCallback();

            Assert.Same(context, suppliedContext);
        }
        public WindowErrorViewModel()
        {
            OkChannelOrderList = DbHelper.GetOrderListByChannel(EnumChannel.异常道口);
            channel            = ChannelController.Instance;

            channel.OnErrUpdate += (o, c) =>
            {
                ProgramCount = channel.CountErr.Software;
                ChannelCount = channel.CountErr.Hardware;
                CountSend    = channel.CountSendErr;
            };
            ManualErrHandleRequest = new InteractionRequest <INotification>();
            ManualErrHandleCommand = new DelegateCommand(() => { ManualErrHandleRequest.Raise(new Notification {
                    Title = "异常复位处理"
                }); });
        }
        public void WhenEventIsRaised_ShouldExecuteTriggerActions()
        {
            InteractionRequest <INotification> request = new InteractionRequest <INotification>();
            TestableInteractionRequestTrigger  trigger = new TestableInteractionRequestTrigger();
            DependencyObject      associatedObject     = new DependencyObject();
            TestableTriggerAction action = new TestableTriggerAction();

            trigger.Actions.Add(action);
            trigger.Attach(associatedObject);
            trigger.SourceObject = request;

            Assert.IsTrue(action.ExecutionCount == 0);

            request.Raise(new Notification());
            Assert.IsTrue(action.ExecutionCount == 1);
        }
Пример #26
0
        private void AddCommandHandler()
        {
            DomainModelWrapper          _dsc = null;
            DomainModelResolveViewModel _modeResolveConfirmation = new DomainModelResolveViewModel(m_Logger.Log)
            {
                Title = "Resolve Uri of Information Model to Data Domain Model Description"
            };
            bool _exitLoop = false;

            do
            {
                b_ResoleUriToDomainModelPopupRequest.Raise(_modeResolveConfirmation, x => { _exitLoop = x.Confirmed; });
                if (_exitLoop & _modeResolveConfirmation.ResolvedDomainModel != null)
                {
                    _dsc = _modeResolveConfirmation.ResolvedDomainModel;
                }
                else
                {
                    _exitLoop = true;
                }
            } while (!_exitLoop);
            if (_dsc == null)
            {
                return;
            }
            DomainConfirmation _confirmation = new DomainConfirmation(_dsc, false, m_Logger.Log)
            {
                Title = "Import Data Domain Model"
            };

            do
            {
                b_EditPopupRequest.Raise(_confirmation, x => { _exitLoop = x.Confirmed; });
                if (_exitLoop)
                {
                    _exitLoop = m_domainsServices.AddDomain(_confirmation.DomainConfigurationWrapper);
                    if (!_exitLoop)
                    {
                        MessageBox.Show("The data domain exist", "Add data domain failed", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    _exitLoop = true;
                }
            } while (!_exitLoop);
        }
Пример #27
0
        public NotificationsViewModel()
        {
            Title = GetModuleTitle(Assembly.GetExecutingAssembly());

            DefaultNotificationRequest = new InteractionRequest <INotification>();
            DefaultConfirmationRequest = new InteractionRequest <IConfirmation>();
            CustomNotificationRequest  = new InteractionRequest <ICustomNotification>();
            CustomConfirmationRequest  = new InteractionRequest <ICustomConfirmation>();

            DefaultNotificationCommand = new DelegateCommand(() =>
            {
                var notification = new Notification
                {
                    Title   = "Default notification title",
                    Content = "Default notification content"
                };
                DefaultNotificationRequest.Raise(notification, DefaultNotificationCallback);
            });
            DefaultConfirmationCommand = new DelegateCommand(() =>
            {
                var confirmation = new Confirmation
                {
                    Title   = "Default confirmation title",
                    Content = "Default confirmation content"
                };
                DefaultConfirmationRequest.Raise(confirmation, DefaultConfirmationCallback);
            });
            CustomNotificationCommand = new DelegateCommand(() =>
            {
                var notification = new CustomNotification
                {
                    Title     = "Custom notification title",
                    Content   = "Custom notification content",
                    TimeStamp = DateTime.Now
                };
                CustomNotificationRequest.Raise(notification, CustomNotificationCallback);
            });
            CustomConfirmationCommand = new DelegateCommand(() =>
            {
                var confirmation = new CustomConfirmation
                {
                    Title = "Custom confirmation title"
                };
                CustomConfirmationRequest.Raise(confirmation, CustomConfirmationCallback);
            });
        }
Пример #28
0
        private void SaveAs()
        {
            SaveResourcePackAsRequest.Raise(new Notification
            {
                Title   = "Save Resource Pack",
                Content = "Save Resource Pack"
            }, (notification) =>
            {
                _loadedResourcePackFileName = notification.Content as string;
                if (_loadedResourcePackFileName == null)
                {
                    return;
                }

                DoSave();
            });
        }
Пример #29
0
        private void OnOpenConfigFile()
        {
            var notification = new OpenFileDialogNotification();

            notification.RestoreDirectory = true;
            notification.Filter           = "PathFinder config (*.json)|*.json";
            notification.FilterIndex      = 0;

            OpenFileRequest.Raise(notification,
                                  n =>
            {
                if (n.Confirmed)
                {
                    ConfigFile = n.FileName;
                }
            });
        }
Пример #30
0
        private void OnBrowseClicked()
        {
            var notification = new OpenFileDialogNotification();

            notification.RestoreDirectory = true;
            notification.Filter           = "Assemblies (*.dll,*.exe)|*.dll;*.exe";
            notification.FilterIndex      = 0;

            OpenFileRequest.Raise(notification,
                                  n =>
            {
                if (n.Confirmed)
                {
                    AssemblyToAnalyseLocation = n.FileName;
                }
            });
        }
Пример #31
0
 private void DoConfirmation()
 {
     ConfirmDialogRequest.Raise(
         new Confirmation {
         Title = "DialogTest1", Content = "This is ConfirmationDialog.OK?"
     },
         n =>
     {
         if (n.Confirmed)
         {
             System.Windows.MessageBox.Show("Yes Pressed");
         }
         else
         {
             System.Windows.MessageBox.Show("No Pressed");
         }
     });
 }
Пример #32
0
        public StartViewModel(IMessenger messenger) : base(messenger)
        {
            ApplicationContext context = Context.GetApplicationContext();

            this.localization       = context.GetService <Localization>();
            startInteractionRequest = new InteractionRequest(this);
            this.startCommand       = new SimpleCommand(() =>
            {
                this.startCommand.Enabled = false;
                startInteractionRequest.Raise();
                this.startCommand.Enabled = true;
            });

            this.cancelCommand = new SimpleCommand(() =>
            {
                this.cancelCommand.Enabled = false;
            });
        }
        private bool RaiseEditAddressRequest(Address item, string title)
        {
            var result = false;
            var itemVM = _addressVmFactory.GetViewModelInstance(new KeyValuePair <string, object>("item", item), new KeyValuePair <string, object>("countries", _allCountries));

            DisableableCommandConfirmRequest.Raise(
                new ConditionalConfirmation(itemVM.Validate)
            {
                Title   = title,
                Content = itemVM
            },
                (x) =>
            {
                result = x.Confirmed;
            });

            return(result);
        }
Пример #34
0
        private void SaveMasks()
        {
            var notification = new SaveFileDialogNotification();

            notification.RestoreDirectory = true;
            notification.Filter           = "GraphViz filter files (*.bgf)|*.bgf";
            notification.FilterIndex      = 0;
            notification.DefaultExt       = ".bgf";

            SaveFileRequest.Raise(notification,
                                  n =>
            {
                if (n.Confirmed)
                {
                    var module = myPresentation.GetModule <INodeMaskModule>();
                    myPersistanceService.Save(n.FileName, module.Items);
                }
            });
        }
		public MainWindowViewModel(PageManager pageManager, IEventAggregator ea, IFolderReactionMonitorModel monitor, IRegionManager regionManagar)
		{
			PageManager = pageManager;
			_Monitor = monitor;
			_RegionManager = regionManagar;

			MessageRequest = new InteractionRequest<Notification>();

			_CompositeDisposable = new CompositeDisposable();


			var e = ea.GetEvent<PubSubEvent<TaskbarIconBalloonMessageEventPayload>>();
			e.Subscribe(x =>
			{
				MessageRequest.Raise(new Notification()
				{
					Title = x.Title,
					Content = x.Message
				});
			});

			IsOpenSubContent = PageManager
				.ObserveProperty(x => x.IsOpenSubContent)
				.ToReactiveProperty(false);

			IsOpenSideMenu = PageManager
				.ToReactivePropertyAsSynchronized(x => x.IsOpenSideMenu);




			NotificationSource = new NotificationsSource();

			var toastEvent = ea.GetEvent<PubSubEvent<ToastNotificationEventPayload>>();
			toastEvent.Subscribe(x =>
			{
				NotificationSource.Show(x.Message, x.Type);
			});
		}
Пример #36
0
 public MainViewModel()
 {
     ConfirmationRequest = new InteractionRequest<IConfirmation>();
     ConfirmationCommand = new DelegateCommand(() =>
     {
         ConfirmationRequest.Raise(new Confirmation
         {
             Title = "Confirmation box",
             Content = "Confirmation message displayed"
         },
         (dialog) =>
         {
             if (dialog.Confirmed)
             {
                 Status = "Confirmed";
             }
             else
             {
                 Status = "Cancelled";
             }
         });
     });
 }
        public override void Delete(ICatalogRepository repository, InteractionRequest<Confirmation> commonConfirmRequest, InteractionRequest<Notification> errorNotifyRequest, Action onSuccess)
        {
            var countBuffer = new List<string>();

            // count: categories in Catalog
            int itemCount = repository.Categories.Where(x => x.CatalogId == InnerItem.CatalogId).Count();
            if (itemCount > 0)
            {
                countBuffer.Add(string.Format("contains {0} category(ies)".Localize(), itemCount));
            }

            // count: items in Catalog
            itemCount = repository.Items.Where(x => x.CatalogId == InnerItem.CatalogId).Count();
            if (itemCount > 0)
            {
                countBuffer.Add(string.Format("has {0} item(s)".Localize(), itemCount));
            }

            var content = string.Empty;
            var warnings = countBuffer.Select(x => "\n\t- " + x).ToArray();
            if (warnings.Length > 0)
            {
                content = string.Format("ATTENTION: This Catalog {0}.\n\n".Localize(), string.Join("", warnings));
            }
            content += string.Format("Are you sure you want to delete Catalog '{0}'?".Localize(), DisplayName);

            var item = LoadItem(InnerItem.CatalogId, repository);
            var itemVM = _catalogDeleteVmFactory.GetViewModelInstance(
                new KeyValuePair<string, object>("item", item),
                new KeyValuePair<string, object>("contentText", content));

            var confirmation = new ConditionalConfirmation(itemVM.Validate)
            {
                Content = itemVM,
                Title = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
            };
            commonConfirmRequest.Raise(confirmation, async (x) =>
            {
                if (x.Confirmed)
                {
                    await Task.Run(() =>
                    {
                        repository.Remove(item);

                        // report status
                        var id = Guid.NewGuid().ToString();
                        var statusUpdate = new StatusMessage { ShortText = string.Format("A Catalog '{0}' deletion in progress".Localize(), DisplayName), StatusMessageId = id };
                        EventSystem.Publish(statusUpdate);

                        try
                        {
                            repository.UnitOfWork.Commit();
                            statusUpdate = new StatusMessage { ShortText = string.Format("A Catalog '{0}' deleted successfully".Localize(), DisplayName), StatusMessageId = id, State = StatusMessageState.Success };
                            EventSystem.Publish(statusUpdate);
                        }
                        catch (Exception e)
                        {
                            statusUpdate = new StatusMessage
                            {
                                ShortText = string.Format("Failed to delete Catalog '{0}'".Localize(), DisplayName),
                                Details = e.ToString(),
                                StatusMessageId = id,
                                State = StatusMessageState.Error
                            };
                            EventSystem.Publish(statusUpdate);
                        }
                    });

                    onSuccess();
                }
            });
        }
        public override void Delete(ICatalogRepository repository, InteractionRequest<Confirmation> commonConfirmRequest, InteractionRequest<Notification> errorNotifyRequest, Action onSuccess)
        {
            var countBuffer = new List<string>();
            int itemCount;

            // count: items in category. Don't try counting items for VirtualCatalog (nor linked category in it). 
            var isThisCategoryInRealCatalog = CatalogHomeViewModel.GetCatalog(this) is catalogModel.Catalog;
            if (isThisCategoryInRealCatalog)
            {
                // checking current category and level 1 (direct) subcategories.
                itemCount = repository.Items
                                      .Where(x =>
                                          x.CategoryItemRelations.Any(y =>
                                              y.CategoryId == InnerItem.CategoryId || y.Category.ParentCategoryId == InnerItem.CategoryId))
                                      .Count();

                if (itemCount > 0)
                {
                    countBuffer.Add(string.Format("has {0} item(s), won't be deleted".Localize(), itemCount));
                }
            }

            // count: direct sub-categories
            itemCount = repository.Categories
                .Where(x => x.ParentCategoryId == InnerItem.CategoryId)
                .Count();

            if (itemCount > 0)
            {
                countBuffer.Add(string.Format("has {0} sub-category(ies), will be deleted".Localize(), itemCount));
            }

            if (isThisCategoryInRealCatalog)
            {
                // count: linked categories			
                itemCount = repository.Categories
                    .OfType<LinkedCategory>()
                    .Where(x => x.LinkedCategoryId == InnerItem.CategoryId)
                    .Count();

                if (itemCount > 0)
                {
                    countBuffer.Add(string.Format("is coupled with {0} Linked Category(ies), will be deleted".Localize(), itemCount));
                }
            }

            // construct nice message
            var typeName = ((InnerItem is Category) ? "category" : "linked category").Localize();
            var content = string.Empty;
            var warnings = countBuffer.Select(x => "\n\t- " + x).ToArray();
            if (warnings.Length > 0)
            {
                content = string.Format("ATTENTION: This {0} {1}.\n\n".Localize(), typeName, string.Join("", warnings));
            }

            content += string.Format("Are you sure you want to delete {0} '{1}'?".Localize(), typeName, DisplayName);

            var confirmation = new ConditionalConfirmation
            {
                Content = content,
                Title = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
            };

            commonConfirmRequest.Raise(confirmation, async (x) =>
            {
                if (x.Confirmed)
                {
                    await Task.Run(() =>
                    {
                        // Removing item by attaching makes DataServiceRequest exception.
                        var categoryItem = repository.Categories.Where(c => c.CategoryId == InnerItem.CategoryId).FirstOrDefault();
                        //repository.Attach(InnerItem);
                        repository.Remove(categoryItem);

                        // report status
                        var id = Guid.NewGuid().ToString();
                        var item = new StatusMessage { ShortText = string.Format("A {0} '{1}' deletion in progress".Localize(), typeName, DisplayName), StatusMessageId = id };
                        EventSystem.Publish(item);

                        try
                        {
                            if (DeleteSeoKeywords())
                            {
                                repository.UnitOfWork.Commit();
                            }
                            item = new StatusMessage { ShortText = string.Format("A {0} '{1}' deleted successfully".Localize(), typeName, DisplayName), StatusMessageId = id, State = StatusMessageState.Success };
                            EventSystem.Publish(item);
                        }
                        catch (Exception e)
                        {
                            item = new StatusMessage
                            {
                                ShortText = string.Format("Failed to delete {0} '{1}'".Localize(), typeName, DisplayName),
                                Details = e.ToString(),
                                StatusMessageId = id,
                                State = StatusMessageState.Error
                            };
                            EventSystem.Publish(item);
                        }
                    });

                    var parentHierarchyVM = (HierarchyViewModelBase)Parent;
                    parentHierarchyVM.Refresh();
                }
            });
        }
		public override void Delete(ICatalogRepository repository, InteractionRequest<Confirmation> commonConfirmRequest, InteractionRequest<Notification> errorNotifyRequest, Action onSuccess)
		{
			var content = string.Empty;

			// count: categories in VirtualCatalog
			var itemCount = repository.Categories
				.Where(x => x.CatalogId == InnerItem.CatalogId)
				.Count();

			if (itemCount > 0)
			{
				content = string.Format("ATTENTION: This Virtual Catalog contains {0} category(ies).\n\n", itemCount);
			}

			content += string.Format("Are you sure you want to delete Virtual Catalog '{0}'?", DisplayName);

			var item = repository.Catalogs.Where(x => x.CatalogId == InnerItem.CatalogId).Single();
			var itemVM = _catalogDeleteVmFactory.GetViewModelInstance(
				new KeyValuePair<string, object>("item", item),
				new KeyValuePair<string, object>("contentText", content));

			var confirmation = new ConditionalConfirmation(itemVM.Validate)
			{
				Content = itemVM,
				Title = "Delete confirmation"
			};
			commonConfirmRequest.Raise(confirmation, async (x) =>
			{
				if (x.Confirmed)
				{
					await Task.Run(() =>
						{
							repository.Remove(item);

							// report status
							var id = Guid.NewGuid().ToString();
							var statusUpdate = new StatusMessage { ShortText = string.Format("A Virtual Catalog '{0}' deletion in progress", DisplayName), StatusMessageId = id };
							EventSystem.Publish(statusUpdate);

							try
							{
								repository.UnitOfWork.Commit();
								statusUpdate = new StatusMessage { ShortText = string.Format("A Virtual Catalog '{0}' deleted successfully", DisplayName), StatusMessageId = id, State = StatusMessageState.Success };
								EventSystem.Publish(statusUpdate);
							}
							catch (Exception e)
							{
								statusUpdate = new StatusMessage
								{
									ShortText = string.Format("Failed to delete Virtual Catalog '{0}'", DisplayName),
									Details = e.ToString(),
									StatusMessageId = id,
									State = StatusMessageState.Error
								};
								EventSystem.Publish(statusUpdate);
							}
						});

					onSuccess();
				}
			});
		}