Beispiel #1
0
        public void EditProperties()
        {
            StoryPropertiesDialog dialog = new StoryPropertiesDialog(DialogOwner, Model, UniverseVm.Categories);
            bool?result = dialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                Model.Save();
                UniverseVm.UpdateStoryInTree(this);
            }
        }
Beispiel #2
0
        public void CreateStory()
        {
            Story story = new Story(Model.Connection);

            story.UniverseId = Model.id;

            StoryPropertiesDialog dialog = new StoryPropertiesDialog(DialogOwner, story, Categories);
            bool?result = dialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                if (story.CategoryId == null)
                {
                    if (SubItems.Count > 0)
                    {
                        story.SortIndex = SubItems.Max(i => i.SortIndex) + 1;
                    }
                    else
                    {
                        story.SortIndex = 0;
                    }
                }
                else
                {
                    if (Stories.Count(i => i.Model.CategoryId == story.CategoryId) > 0)
                    {
                        story.SortIndex = Stories.Where(i => i.Model.CategoryId == story.CategoryId).Max(i => i.SortIndex + 1);
                    }
                    else
                    {
                        story.SortIndex = 0;
                    }
                }
                story.Create();
                StoryViewModel storyVm = new StoryViewModel(story);
                storyVm.UniverseVm = this;
                Stories.Add(storyVm);
                UpdateStoryInTree(storyVm);
            }
        }