@@ -68,12 +68,11 @@ public async Task<IEnumerable<WeatherForecast>> Get()
68
68
throw new HttpRequestException ( $ "Invalid status code in the HttpResponseMessage: { response . StatusCode } : { error } ") ;
69
69
}
70
70
71
- var rng = new Random ( ) ;
72
71
return Enumerable . Range ( 1 , 5 ) . Select ( index => new WeatherForecast
73
72
{
74
73
Date = DateTime . Now . AddDays ( index ) ,
75
- TemperatureC = rng . Next ( - 20 , 55 ) ,
76
- Summary = Summaries [ rng . Next ( Summaries . Length ) ]
74
+ TemperatureC = Random . Shared . Next ( - 20 , 55 ) ,
75
+ Summary = Summaries [ Random . Shared . Next ( Summaries . Length ) ]
77
76
} )
78
77
. ToArray ( ) ;
79
78
}
@@ -94,12 +93,11 @@ public async Task<IEnumerable<WeatherForecast>> Get()
94
93
HttpContext . VerifyUserHasAnyAcceptedScope ( scopeRequiredByApi ) ;
95
94
var user = await _graphServiceClient . Me . Request ( ) . GetAsync ( ) ;
96
95
97
- var rng = new Random ( ) ;
98
96
return Enumerable . Range ( 1 , 5 ) . Select ( index => new WeatherForecast
99
97
{
100
98
Date = DateTime . Now . AddDays ( index ) ,
101
- TemperatureC = rng . Next ( - 20 , 55 ) ,
102
- Summary = Summaries [ rng . Next ( Summaries . Length ) ]
99
+ TemperatureC = Random . Shared . Next ( - 20 , 55 ) ,
100
+ Summary = Summaries [ Random . Shared . Next ( Summaries . Length ) ]
103
101
} )
104
102
. ToArray ( ) ;
105
103
}
@@ -116,12 +114,11 @@ public IEnumerable<WeatherForecast> Get()
116
114
HttpContext . VerifyUserHasAnyAcceptedScope ( scopeRequiredByApi ) ;
117
115
118
116
#endif
119
- var rng = new Random ( ) ;
120
117
return Enumerable . Range ( 1 , 5 ) . Select ( index => new WeatherForecast
121
118
{
122
119
Date = DateTime . Now . AddDays ( index ) ,
123
- TemperatureC = rng . Next ( - 20 , 55 ) ,
124
- Summary = Summaries [ rng . Next ( Summaries . Length ) ]
120
+ TemperatureC = Random . Shared . Next ( - 20 , 55 ) ,
121
+ Summary = Summaries [ Random . Shared . Next ( Summaries . Length ) ]
125
122
} )
126
123
. ToArray ( ) ;
127
124
}
0 commit comments