Ejemplo n.º 1
0
        /// <summary>
        /// Add note menu.
        /// </summary>
        /// <param name="diary">Struct Diary.</param>
        static void AddNote(Diary diary)
        {
            Console.WriteLine("\nAdd notes:" +
                              "\n1 - Add a note manually." +
                              "\n2 - Generate 10 notes automatically." +
                              "\n3 - Return to the Main menu.");
            Console.WriteLine("\nEnter a number from 1 to 3");
            string key  = Console.ReadLine();
            var    page = new Note();

            switch (key)
            {
            case "1":
            {
                //Adding a new note from user input data.
                diary.Add(NewNote(diary));
                MainMenu(diary);
                break;
            }

            case "2":
            {
                for (int i = 1; i <= 10; i++)
                {
                    page = new Note(diary.LastNote, $"An autogenerated note #{i}.");
                    diary.Add(page);
                }
                MainMenu(diary);
                break;
            }

            default:
            {
                MainMenu(diary);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Edit note menu.
        /// </summary>
        /// <param name="diary">Struct Diary.</param>
        static void EditNote(Diary diary)
        {
            Console.WriteLine("\nPlease enter the # of a note you want to edit.");
            uint id = 0;

            while (!uint.TryParse(Console.ReadLine(), out id))
            {
                Console.WriteLine("\nPlease enter the # of note you want to edit.");
            }

            var change = diary.GetById(id);

            Console.WriteLine(change.Print());

            Console.WriteLine("\nWould you like to change the summary of the note y/n.");
            string decision = Console.ReadLine();

            if (decision == "y")
            {
                Console.WriteLine("Please enter the new summary.");
                diary.EditNoteSummaryById(id, Console.ReadLine());
                change = diary.GetById(id);
                Console.WriteLine(change.Print());
            }

            Console.WriteLine("\nWould you like to change the text of the note y/n.");
            decision = Console.ReadLine();
            if (decision == "y")
            {
                Console.WriteLine("Please enter the new text.");
                diary.EditNoteTextById(id, Console.ReadLine());
                change = diary.GetById(id);
                Console.WriteLine(change.Print());
            }

            MainMenu(diary);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Method that saved the diary to a file.
 /// </summary>
 /// <param name="diary">Struct Diary.</param>
 private static void SaveDiary(Diary diary)
 {
     diary.Save();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Menu with sort options.
        /// </summary>
        /// <param name="diary">Struct Diary.</param>
        private static void SortNotes(Diary diary)
        {
            Console.WriteLine("\nSort notes:" +
                              "\n1 - By #." +
                              "\n2 - By summary." +
                              "\n3 - By Date and Time." +
                              "\n4 - By text." +
                              "\n5 - By author." +
                              "\n6 - By modified/unmodified notes." +
                              "\n7 - Return to the Main menu.");
            Console.WriteLine("\nEnter a number from 1 to 7");
            string option = Console.ReadLine();

            //String with user input to tell what he's gonna remove.
            switch (option)
            {
            case "1":
            {
                diary.SortById();
                MainMenu(diary);
                break;
            }

            case "2":
            {
                diary.SortBySummary();
                MainMenu(diary);
                break;
            }

            case "3":
            {
                diary.SortByDateTime();
                MainMenu(diary);
                break;
            }

            case "4":
            {
                diary.SortByText();
                MainMenu(diary);
                break;
            }

            case "5":
            {
                diary.SortByAuthor();
                MainMenu(diary);
                break;
            }

            case "6":
            {
                diary.SortByModified();
                MainMenu(diary);
                break;
            }

            default:
            {
                MainMenu(diary);
                break;
            }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Remove note menu.
        /// </summary>
        /// <param name="diary">Struct Diary.</param>
        static void RemoveNote(Diary diary)
        {
            Console.WriteLine("\nRemove notes:" +
                              "\n1 - By #." +
                              "\n2 - By summary." +
                              "\n3 - By Date and Time." +
                              "\n4 - By text." +
                              "\n5 - By author." +
                              "\n6 - By modified/unmodified notes." +
                              "\n7 - Return to the Main menu.");
            Console.WriteLine("\nEnter a number from 1 to 7");
            string key = Console.ReadLine();
            //String with user input to tell what he's gonna remove.
            string toRemove = String.Empty;

            switch (key)
            {
            case "1":
            {
                Console.WriteLine("\nPlease enter # of the note to remove it.");
                toRemove = Console.ReadLine();
                if (!String.IsNullOrEmpty(toRemove))
                {
                    diary.RemoveAll(int.Parse(toRemove));
                }
                else
                {
                    Console.WriteLine("\nNothing to remove.");
                }
                MainMenu(diary);
                break;
            }

            case "2":
                Console.WriteLine("\nPlease enter summary of the notes to remove them all.");
                toRemove = Console.ReadLine();
                if (!String.IsNullOrEmpty(toRemove))
                {
                    diary.RemoveAllBySummary(toRemove);
                }
                MainMenu(diary);
                break;

            case "3":
                Console.WriteLine("\nPlease enter Date and Time of notes to remove them.");
                toRemove = Console.ReadLine();
                if (!String.IsNullOrEmpty(toRemove))
                {
                    diary.RemoveAll(DateTime.Parse(toRemove));
                }
                MainMenu(diary);
                break;

            case "4":
                Console.WriteLine("\nPlease enter text of the notes to remove them all.");
                toRemove = Console.ReadLine();
                if (!String.IsNullOrEmpty(toRemove))
                {
                    diary.RemoveAllByText(toRemove);
                }
                MainMenu(diary);
                break;

            case "5":
                Console.WriteLine("\nPlease enter author of the notes to remove them all.");
                toRemove = Console.ReadLine();
                if (!String.IsNullOrEmpty(toRemove))
                {
                    diary.RemoveAllByAuthor(toRemove);
                }
                MainMenu(diary);
                break;

            case "6":
            {
                Console.WriteLine("\nWould you like to remove modified (true) or unmodified (false) notes? true/false.");
                toRemove = Console.ReadLine();
                diary.RemoveAll(toRemove == "true");
                MainMenu(diary);
                break;
            }

            default:
            {
                MainMenu(diary);
                break;
            }
            }
        }