Ejemplo n.º 1
0
 private void RaiseEditKnowledgeGroup(object knowlegeGroupViewModel)
 {
     if ((knowlegeGroupViewModel as KnowledgeGroupViewModel) != null)
     {
         SelectedKnowledgeGroup = (knowlegeGroupViewModel as KnowledgeGroupViewModel);
     }
     if (AddKnowledgeBaseGroupDialogRequest != null && (SelectedKnowledgeGroup as KnowledgeGroupViewModel) != null)
     {
         AddKnowledgeBaseGroupDialogRequest.Raise(
             new Confirmation
         {
             Title   = "Edit a group".Localize(),
             Content = (SelectedKnowledgeGroup as KnowledgeGroupViewModel)
         },
             (x) =>
         {
             if (x.Confirmed)
             {
                 if ((SelectedKnowledgeGroup as KnowledgeGroupViewModel).InnerItem != null)
                 {
                     Task.Factory.StartNew(() =>
                     {
                         ShowLoadingAnimation = true;
                         (SelectedKnowledgeGroup as KnowledgeGroupViewModel).ApplyToDB();
                     })
                     .ContinueWith(t =>
                     {
                         ShowLoadingAnimation = false;
                     });
                 }
             }
         }
             );
     }
 }
Ejemplo n.º 2
0
        private void RaiseCreateKnowledgeGroupCommand(object knowlegeGroupViewModel)
        {
            var parentVM = (knowlegeGroupViewModel as KnowledgeGroupViewModel) ?? SelectedKnowledgeGroup as KnowledgeGroupViewModel;

            if (AddKnowledgeBaseGroupDialogRequest != null)
            {
                AddKnowledgeBaseGroupDialogRequest.Raise(
                    new Confirmation
                {
                    Title   = "Add group".Localize(),
                    Content = new KnowledgeGroupViewModel(_repositoryFactory, _groupVmFactory, _repositoryFactory.GetRepositoryInstance(), _entityFactory, new KnowledgeBaseGroup()
                    {
                        ParentId = parentVM != null ? parentVM.OriginalItem.KnowledgeBaseGroupId : null
                    })
                },
                    (x) =>
                {
                    if (x.Confirmed)
                    {
                        var currentGroup = (x.Content as KnowledgeGroupViewModel);
                        if (currentGroup != null && currentGroup.InnerItem != null)
                        {
                            Task.Factory.StartNew(() =>
                            {
                                ShowLoadingAnimation = true;
                                (x.Content as KnowledgeGroupViewModel).InsertToDB();
                            })
                            .ContinueWith(t =>
                            {
                                if (t.Exception == null)
                                {
                                    OnUIThread(() =>
                                    {
                                        if (parentVM != null)
                                        {
                                            if (parentVM.IsExpanded)
                                            {
                                                parentVM.Refresh();
                                            }
                                            else
                                            {
                                                parentVM.IsExpanded = true;
                                            }
                                        }
                                        else
                                        {
                                            RootKnowledgeGroups.Add(x.Content as KnowledgeGroupViewModel);
                                        }
                                    });
                                }
                                ShowLoadingAnimation = false;
                            });
                        }
                    }
                }
                    );
            }
        }