1- using AutoMapper ;
1+ using AutoMapper ;
22using Dotnet . Samples . AspNetCore . WebApi . Models ;
33using Dotnet . Samples . AspNetCore . WebApi . Repositories ;
44using Microsoft . Extensions . Caching . Memory ;
5-
65namespace Dotnet . Samples . AspNetCore . WebApi . Services ;
76
87public class PlayerService (
98 IPlayerRepository playerRepository ,
109 ILogger < PlayerService > logger ,
1110 IMemoryCache memoryCache ,
12- IMapper mapper
11+ IMapper mapper ,
12+ IHostEnvironment hostEnvironment
1313) : IPlayerService
1414{
1515 /// <summary>
@@ -27,20 +27,6 @@ IMapper mapper
2727 /// </summary>
2828 private static readonly string CacheKey_RetrieveAsync = nameof ( RetrieveAsync ) ;
2929
30- /// <summary>
31- /// The key used to store the environment variable for ASP.NET Core.
32- /// <br/>
33- /// <see href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-8.0">
34- /// Use multiple environments in ASP.NET Core
35- /// </see>
36- /// </summary>
37- private static readonly string AspNetCore_Environment = "ASPNETCORE_ENVIRONMENT" ;
38-
39- /// <summary>
40- /// The value used to check if the environment is Development.
41- /// </summary>
42- private static readonly string Development = "Development" ;
43-
4430 /* -------------------------------------------------------------------------
4531 * Create
4632 * ---------------------------------------------------------------------- */
@@ -68,7 +54,7 @@ public async Task<List<PlayerResponseModel>> RetrieveAsync()
6854 }
6955 else
7056 {
71- if ( Environment . GetEnvironmentVariable ( AspNetCore_Environment ) == Development )
57+ if ( hostEnvironment . IsDevelopment ( ) )
7258 {
7359 await SimulateRepositoryDelayAsync ( ) ;
7460 }
0 commit comments