示例#1
0
        private static void AddNoteIntoNotebook()
        {
            var existingNotebooks = DataAccessor.GetNotebooks(_sourceType);

            PrintNotebooks(existingNotebooks);

            if (ExtendedConsole.TryReadInt32WithMessage("Enter the index of the notebook you are interested in", out int index))
            {
                try
                {
                    var notebook = existingNotebooks[index];
                    var note     = ExtendedConsole.ReadNote();

                    notebook.Notes.Add(note);

                    DataAccessor.UpdateNotebook(notebook, _sourceType);
                    Console.WriteLine("Note has been successfully added to notebook");
                }
                catch (IndexOutOfRangeException)
                {
                    Console.WriteLine("The index you specified is out of bounds for existing notebooks, please try again");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
        }