Beispiel #1
0
        public static void Main(string[] args)
        {
            var client     = new MongoClient("mongodb://localhost:27017");
            var database   = client.GetDatabase("homework");
            var repository = new PetRepository(database);

            var count = repository.GetCount();

            // AC3: При первом запуске приложение должно вставлять данные в коллекцию, если она пуста.
            if (count == 0)
            {
                repository.BulkInsert(SeedData.Pets);
            }

            bool inLoop = true;

            while (inLoop)
            {
                Console.WriteLine();
                Console.WriteLine("1. Посмотреть записи");
                Console.WriteLine("2. Сгенерировать отчет");
                Console.WriteLine("3. Выйти");
                Console.Write("> ");

                var key = Console.ReadKey();
                Console.WriteLine();
                Console.WriteLine();

                switch (key.Key)
                {
                case ConsoleKey.D1:
                    ViewRecords(repository);
                    break;

                case ConsoleKey.D2:
                    BuildReport(repository);
                    break;

                case ConsoleKey.D3:
                    inLoop = false;
                    break;
                }
            }
        }