Beispiel #1
0
 private static void OutputData(MagicMirrorDto dto)
 {
     Console.WriteLine($"Hello {dto.UserName}");
     Console.WriteLine($"Today is {DateTime.Now:D}. The current time is: {DateTime.Now:t}");
     Console.WriteLine($"The current top-side temperature is {dto.DegreesCelsius} degrees Celsius with an estimated high of {dto.DegreesCelsius}. The current weather is {dto.WeatherType}");
     Console.WriteLine($"Your travel time is {dto.TravelTime} with {dto.TrafficDensity} traffic.");
     Console.WriteLine("Have a safe and productive day");
 }
Beispiel #2
0
        private static async Task <MagicMirrorDto> GenerateDto(UserSettings criteria)
        {
            _weatherService = new WeatherService();
            _trafficService = new TrafficService(criteria);
            WeatherModel weatherModel = await _weatherService.GetModelAsync();

            TrafficModel trafficModel = await _trafficService.GetModelAsync();

            var dto = new MagicMirrorDto
            {
                UserName       = criteria.UserName,
                DegreesCelsius = weatherModel.TemperatureCelsius,
                TravelTime     = trafficModel.MinutesText,
                TrafficDensity = trafficModel.TrafficDensity,
                WeatherType    = weatherModel.WeatherType
            };

            return(dto);
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            try
            {
                UserSettings criteria = GatherUserInformation();
                Console.WriteLine("Crunching the numbers...");
                Console.WriteLine();

                MagicMirrorDto dto = Task.Run(() => GenerateDto(criteria)).Result;
                OutputData(dto);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.WriteLine("Press any key to exit.");
                Console.ReadLine();
            }
        }