Exemplo n.º 1
0
 private static void PrintNotes(NotebookDto notebook)
 {
     for (int i = 0; i < notebook.Notes.Count; i++)
     {
         Console.WriteLine($"[{i}]: { notebook.Notes[i].Name}, { notebook.Notes[i].Text}");
     }
 }
        public static NotebookDto EditNotebook(NotebookDto notebook)
        {
            notebook.Changed = DateTime.Now;
            notebook.Name    = ReadLineWithMessage("Enter a name for the notebook");

            return(notebook);
        }
Exemplo n.º 3
0
 private async Task GetSections(NotebookDto notebook)
 {
     await DoOnUiDispatcherAsync(() =>
     {
         Sections.Clear();
         notebook.Sections.ForEach(s => Sections.Add(s));
     });
 }
Exemplo n.º 4
0
        public static void RemoveNotebook(NotebookDto notebookDto, DataSourceType dataSourceType)
        {
            var dataSource    = GetDataSource(dataSourceType);
            var notebookModel = Mapper.Map <Notebook>(notebookDto);

            dataSource.NotebookRepository.Remove(notebookModel);
            dataSource.NotebookRepository.SaveChanges();
        }
Exemplo n.º 5
0
 public GetSectionsForNotebook(NotebookDto notebook)
 {
     if (notebook == null)
     {
         throw new ArgumentNullException(nameof(notebook));
     }
     Notebook = notebook;
 }
Exemplo n.º 6
0
        public static void AddNotebook(NotebookDto notebookDto, DataSourceType dataSourceType)
        {
            var dataSource    = GetDataSource(dataSourceType);
            var notebookModel = Mapper.Map <Notebook>(notebookDto);

            dataSource.NotebookRepository.Add(notebookModel);
            dataSource.NotebookRepository.SaveChanges();

            notebookDto.Id = notebookModel.Id;
        }
Exemplo n.º 7
0
        public void NotebookSelected(NotebookDto notebook)
        {
            if (notebook == null)
            {
                Log.Msg(this, l => l.Warning("Selected notebook was null"));
                return;
            }

            Notebooks.ForEach(n => n.Deselect());

            notebook.Select();

            MessageBus.Publish(new NotebookSelected(notebook));
        }
Exemplo n.º 8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var editor = new NotebookEditor();

            if (editor.ShowDialog() == true && DataContext is MainWindowVM mainWindowVM)
            {
                var newNotebookDto = new NotebookDto
                {
                    Changed = DateTime.Now,
                    Created = DateTime.Now,
                    Notes   = new ObservableCollection <NoteDto>(),
                    Name    = ((NotebookVM)editor.DataContext).Name
                };

                mainWindowVM.Notebooks.Add(newNotebookDto);
                DataAccessor.AddNotebook(newNotebookDto, mainWindowVM.SelectedSource);
            }
        }
Exemplo n.º 9
0
 private void OnNotebookSelected(NotebookSelected message)
 {
     _selectedNotebook = message.Notebook;
 }
Exemplo n.º 10
0
 public SectionCreated(NotebookDto newSectionParentNotebook)
 {
     NewSectionParentNotebook = newSectionParentNotebook;
 }
Exemplo n.º 11
0
 public NotebookSelected(NotebookDto notebook)
 {
     Notebook = notebook;
 }
Exemplo n.º 12
0
 private static ImmutableArray <SectionDto> SetParentNotebook(NotebookDto notebook, ImmutableArray <SectionDto> sections)
 {
     return(sections.ForEach(s => s.ParentNotebook = notebook).ToImmutableArray());
 }
Exemplo n.º 13
0
        public async Task <ImmutableArray <SectionDto> > GetSectionsForNotebook(IActorRef actor, NotebookDto notebook)
        {
            var answer = await actor.Ask(new SectionActor.GetSectionsForNotebook(notebook));

            if (answer is SectionActor.GetSectionsForNotebookResult)
            {
                var result = answer as SectionActor.GetSectionsForNotebookResult;

                return(result.Sections);
            }

            LogFailure(answer);

            return(ImmutableArray <SectionDto> .Empty);
        }
Exemplo n.º 14
0
        public async Task <ImmutableArray <SectionDto> > GetSectionsForNotebook(NotebookDto notebook)
        {
            var actor = ActorSystem.ActorOf(ActorRegistry.Section);

            return(await GetSectionsForNotebook(actor, notebook));
        }