Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions src/Dotnet.Samples.AspNetCore.WebApi/Services/PlayerService.cs
Original file line number Diff line number Diff line change
@@ -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<PlayerService> logger,
IMemoryCache memoryCache,
IMapper mapper
IMapper mapper,
IHostEnvironment hostEnvironment
) : IPlayerService
{
/// <summary>
Expand All @@ -27,20 +27,6 @@ IMapper mapper
/// </summary>
private static readonly string CacheKey_RetrieveAsync = nameof(RetrieveAsync);

/// <summary>
/// The key used to store the environment variable for ASP.NET Core.
/// <br/>
/// <see href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-8.0">
/// Use multiple environments in ASP.NET Core
/// </see>
/// </summary>
private static readonly string AspNetCore_Environment = "ASPNETCORE_ENVIRONMENT";

/// <summary>
/// The value used to check if the environment is Development.
/// </summary>
private static readonly string Development = "Development";

/* -------------------------------------------------------------------------
* Create
* ---------------------------------------------------------------------- */
Expand Down Expand Up @@ -68,7 +54,7 @@ public async Task<List<PlayerResponseModel>> RetrieveAsync()
}
else
{
if (Environment.GetEnvironmentVariable(AspNetCore_Environment) == Development)
if (hostEnvironment.IsDevelopment())
{
await SimulateRepositoryDelayAsync();
}
Expand Down
Loading