예제 #1
0
        /// <summary>
        /// Entry point to call methods that operate on Azure Cosmos DB resources in this sample
        /// </summary>
        private async Task GetStartedDemoAsync()
        {
            // Create a new instance of the Cosmos Client
            this.cosmosClient = new CosmosClient(SensitiveData.ENDPOINT_URI, SensitiveData.PRIMARY_KEY);
            await this.CreateDatabaseAsync();

            await this.CreateContainerAsync();

            encryptService = new EncryptService();

            addCustomer       = new AddCustomer(customerContainer, encryptService);
            searchCustomer    = new SearchCustomer(customerContainer);
            reserveApartment  = new ReserveApartment(customerContainer, apartmentContainer, reservationContainer, encryptService);
            deleteReservation = new DeleteReservation(reservationContainer);

            Console.WriteLine();
            Console.WriteLine("Hello :)");
            Console.WriteLine("I am an intelligent system to manage apartments and clients of a holiday resort.");

            var input = "";

            do
            {
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("xxxxxxxxxxxxxxx   MENU   xxxxxxxxxxxxxxx");
                Console.WriteLine();
                Console.WriteLine("Please press s to search a customer.");
                Console.WriteLine("Please press a to add a customer.");
                Console.WriteLine("Please press r to reserve a apartment.");
                Console.WriteLine("Please press d to delete a reservation.");
                Console.WriteLine();
                Console.WriteLine("xxxxxxxxxxxxxxx   MENU   xxxxxxxxxxxxxxx");
                Console.WriteLine();
                Console.WriteLine();
                Console.Write("User input: ");
                var action = Console.ReadLine();

                switch (action)
                {
                case "s":
                    searchCustomer.Start();
                    break;

                case "a":
                    addCustomer.Start();
                    break;

                case "r":
                    reserveApartment.Start();
                    break;

                case "d":
                    deleteReservation.Start();
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine("Incorrect input!");
                    break;
                }

                Console.WriteLine();
                Console.Write("Do want to continue? (y|n) ");
                input = Console.ReadLine();
                if (input == null)
                {
                    break;
                }
            } while (input.Equals("y"));
        }