diff --git a/src/Dotnet.Samples.AspNetCore.WebApi/Services/PlayerService.cs b/src/Dotnet.Samples.AspNetCore.WebApi/Services/PlayerService.cs index bd3ed54..6907088 100644 --- a/src/Dotnet.Samples.AspNetCore.WebApi/Services/PlayerService.cs +++ b/src/Dotnet.Samples.AspNetCore.WebApi/Services/PlayerService.cs @@ -1,15 +1,15 @@ -using AutoMapper; +using AutoMapper; using Dotnet.Samples.AspNetCore.WebApi.Models; using Dotnet.Samples.AspNetCore.WebApi.Repositories; using Microsoft.Extensions.Caching.Memory; - namespace Dotnet.Samples.AspNetCore.WebApi.Services; public class PlayerService( IPlayerRepository playerRepository, ILogger logger, IMemoryCache memoryCache, - IMapper mapper + IMapper mapper, + IHostEnvironment hostEnvironment ) : IPlayerService { /// @@ -27,20 +27,6 @@ IMapper mapper /// private static readonly string CacheKey_RetrieveAsync = nameof(RetrieveAsync); - /// - /// The key used to store the environment variable for ASP.NET Core. - ///
- /// - /// Use multiple environments in ASP.NET Core - /// - ///
- private static readonly string AspNetCore_Environment = "ASPNETCORE_ENVIRONMENT"; - - /// - /// The value used to check if the environment is Development. - /// - private static readonly string Development = "Development"; - /* ------------------------------------------------------------------------- * Create * ---------------------------------------------------------------------- */ @@ -68,7 +54,7 @@ public async Task> RetrieveAsync() } else { - if (Environment.GetEnvironmentVariable(AspNetCore_Environment) == Development) + if (hostEnvironment.IsDevelopment()) { await SimulateRepositoryDelayAsync(); }