Esempio n. 1
0
        public static void Run()
        {
            // Create providers.
            IProductsProvider     productsProvider;
            IReservationsProvider reservationsProvider;
            IStocksProvider       stocksProvider;

            if (_useInMemoryDatabase)
            {
                CreateInMemoryProviders(out productsProvider, out reservationsProvider, out stocksProvider);
            }
            else
            {
                CreateDatabaseProviders(out productsProvider, out reservationsProvider, out stocksProvider);
            }

            // Create additional objects on top of the database.
            var productsManager = new ProductsManager(productsProvider, stocksProvider);

            // Initialize the database so it is not empty when qwe launch the application.
            if (_initializeDatabase)
            {
                DatabaseInitializer databaseInitializer = new DatabaseInitializer();
                databaseInitializer.InitializeDatabase(productsManager);
            }

            // has methods to act on databases through productsProvider and stocksProvider
            var reservationsManager = new ReservationsManager(stocksProvider, reservationsProvider);

            Cart                       cart    = new Cart(productsProvider, reservationsManager);
            NavigationData             navData = new NavigationData();
            ExpiredReservationsManager expiredReservationsManager = new ExpiredReservationsManager(reservationsProvider);

            navData.ProductsReader = productsProvider;
            navData.StocksReader   = stocksProvider;
            navData.Cart           = cart;

            IPage currentPage = new MainPage();

            while (currentPage != null)
            {
                string menu = currentPage.OnNavigatedTo(navData);
                Console.WriteLine(menu);

                string userInput = Console.ReadLine();
                var    newPage   = currentPage.OnUserInput(userInput);
                navData.PreviousPages.Push(currentPage);
                currentPage = newPage;

                Console.Clear();
            }
        }
Esempio n. 2
0
 private void StartMonitors()
 {
     ReservationsManager        _reservationsManager        = new ReservationsManager(ProvidersFactory.GetStocksProvider(), ProvidersFactory.GetReservationsProvider());
     ExpiredReservationsManager _expiredReservationsManager = new ExpiredReservationsManager(ProvidersFactory.GetReservationsProvider());
 }