Exemple #1
0
        private static void ShowMeanings(DateBase Glossary)
        {
            Console.Clear();
            Console.WriteLine("How should the Meanings be sorted:\n");
            Console.WriteLine("1.By alphabet");
            Console.WriteLine("2.By date");
            Console.WriteLine("3.By category");
            switch (ConsoleRepresentation.ReadChoise(1, 3))
            {
            case 0:
                Console.WriteLine("Wrong input.");
                break;

            case 1:
                //get IEnumerable of all words from glossary sorted by first letter of words, showing them in console in format word-meaning-category
                ConsoleRepresentation.ShowWordByQueryResult(Glossary.GetAllMeaningsSorted((int)SortOptions.byMeanings), (int)PresentOptions.Word_Meaning_Category);
                break;

            case 2:
                ConsoleRepresentation.ShowWordByQueryResult(Glossary.GetAllMeaningsSorted((int)SortOptions.byDate), (int)PresentOptions.Word_Meaning_Category);
                break;

            case 3:
                ConsoleRepresentation.ShowWordByQueryResult(Glossary.GetAllMeaningsSorted((int)SortOptions.byCategory), (int)PresentOptions.Word_Meaning_Category);
                break;
            }
        }
Exemple #2
0
        private static void SearchMeanings(DateBase Glossary)
        {
            Console.WriteLine("***Glossary search***");
            Console.WriteLine("1.By category");
            Console.WriteLine("2.By markers");
            Console.WriteLine("3.By date");
            switch (ConsoleRepresentation.ReadChoise(1, 3))
            {
            case 0:
                Console.WriteLine("Choose number from 1 to 3");
                break;

            case 1:
                Console.Clear();
                Console.WriteLine("*Search by category*");
                Console.Write("Category: ");
                string categorySearch = Console.ReadLine();
                //search words with matched category in glossary, represents it in console in format word - meaning - date
                ConsoleRepresentation.ShowWordByQueryResult(Glossary.GetMeaningsByCategory(categorySearch), (int)PresentOptions.Word_Meaning_Date);
                break;

            case 2:
                Console.WriteLine("*Search by markers*");
                Console.WriteLine("How many markers do you want to use for search \n(number of markers 0 - 3)");
                //read number of markers, by which use want to search
                int numberOfMarkersForSearch = ConsoleRepresentation.ReadChoise(1, 3);
                //read markers from console
                List <string> markers = ConsoleRepresentation.ReadMarkers(numberOfMarkersForSearch);
                switch (numberOfMarkersForSearch)
                {
                //seach words in glossary by string markers and represents it in console
                case 1:
                    ConsoleRepresentation.ShowWordByQueryResult(Glossary.SearchByMarker(markers[0]), (int)PresentOptions.Word_Meaning_Category);
                    break;

                case 2:
                    ConsoleRepresentation.ShowWordByQueryResult(Glossary.SearchByMarker(markers[0], markers[1]), (int)PresentOptions.Word_Meaning_Category);
                    break;

                case 3:
                    ConsoleRepresentation.ShowWordByQueryResult(Glossary.SearchByMarker(markers[0], markers[1], markers[2]), (int)PresentOptions.Word_Meaning_Category);
                    break;
                }
                break;

            case 3:
                Console.Clear();
                Console.WriteLine("*Search by date*");
                Console.Write("Date:\n(dd.mm.yyyy) ");
                DateTime date = DateTime.Now;
                try
                {
                    date = Convert.ToDateTime(Console.ReadLine());
                    //try to show all words, which were added at inputed date
                    ConsoleRepresentation.ShowWordByQueryResult(Glossary.GetMeaningsByDate(date), (int)PresentOptions.Word_Meaning_Category);
                }
                catch
                {
                    Console.WriteLine("Wrong date input...\nPress Enter to try again.");
                    Console.ReadLine();
                }
                break;
            }
        }