1- using Microsoft . Extensions . DependencyInjection ;
21using RealTimeWeatherMonitoringApp . Application . Interfaces . Service ;
32using RealTimeWeatherMonitoringApp . Domain . Models ;
43
54namespace RealTimeWeatherMonitoringApp . Presentation ;
65
76public class UserController
87{
9- private readonly IServiceProvider _provider ;
10- public UserController ( IServiceProvider provider ) => _provider = provider ;
8+ private readonly IBotNotificationService _botNotificationService ;
9+ private readonly IDataProcessingService < WeatherData > _weatherDataProcessor ;
1110
12- private IBotNotificationService BotNotificationService => _provider . GetRequiredService < IBotNotificationService > ( ) ;
13-
14- private IDataProcessingService < WeatherData > WeatherDataProcessor =>
15- _provider . GetRequiredService < IDataProcessingService < WeatherData > > ( ) ;
11+ public UserController (
12+ IBotNotificationService botNotificationService ,
13+ IDataProcessingService < WeatherData > weatherDataProcessor )
14+ {
15+ _botNotificationService = botNotificationService ;
16+ _weatherDataProcessor = weatherDataProcessor ;
17+ }
1618
1719 public void Start ( )
1820 {
19- BotNotificationService . OnBotNotification += ( _ , args ) =>
21+ _botNotificationService . OnBotNotification += ( _ , args ) =>
2022 Console . WriteLine ( $ "\n { args . BotName } : { args . Message } ") ;
2123
2224 while ( true )
@@ -26,7 +28,7 @@ public void Start()
2628 var input = Console . ReadLine ( ) ?? string . Empty ;
2729 if ( input . Equals ( "q" , StringComparison . CurrentCultureIgnoreCase ) ) break ;
2830
29- var result = WeatherDataProcessor . Process ( input ) ;
31+ var result = _weatherDataProcessor . Process ( input ) ;
3032 if ( result . Fail ) Console . WriteLine ( result . Message ) ;
3133 }
3234 }
0 commit comments