Пример #1
0
        public void Run()
        {
            // Json file is included in project to be copied to executable destination directory
            _restaurantRepo.LoadFromFile("rest_hours.json");

            System.Console.WriteLine();
            System.Console.WriteLine("********** Welcome to the Restaurant Locator! **********");
            System.Console.WriteLine();

            while (true)
            {
                if (!GetDay(out ShortDayOfWeek validDay))
                {
                    return;
                }

                if (!GetTime(out DateTime hourMin))
                {
                    return;
                }

                _log.Debug($"User entered: Day: {validDay}, Hour: {hourMin.Hour}, Minute: {hourMin.Minute}");
                var validDate = new DateTime(RestOpen.CalendarYear, RestOpen.CalendarMonth, RestOpen.CalendarFirstDayOfWeek + (int)validDay, hourMin.Hour, hourMin.Minute, 0);

                var available = _restaurantRepo.Available(validDay, hourMin.Hour, hourMin.Minute);
                if (!available.Any())
                {
                    _log.Info($"No restaurants are available at {validDay} {validDate:MM/dd/yyyy h:mm tt}.");
                    System.Console.WriteLine();
                    continue;
                }

                System.Console.WriteLine();
                _log.Info($"These {available.Count} restaurants are available on {validDay} at {validDate:h:mm tt}:");
                foreach (var restaurant in available)
                {
                    System.Console.WriteLine($"{restaurant.Name}");
                    _log.Debug($"{restaurant.Name} ({restaurant.Start:MM/dd/yyyy h:mm tt} - {restaurant.End:MM/dd/yyyy h:mm tt})");
                }
                System.Console.WriteLine();
            }
        }