LANCommander/LANCommander.Server.Services/PlatformService.cs

46 lines
1.5 KiB
C#
Raw Permalink Normal View History

2026-07-02 18:09:14 -05:00
using LANCommander.Server.Data;
2024-08-04 18:44:33 -05:00
using LANCommander.Server.Data.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using ZiggyCreatures.Caching.Fusion;
2026-07-02 20:01:04 -05:00
using LANCommander.Server.Services.Extensions;
2024-06-30 23:10:55 -05:00
2024-08-04 18:44:33 -05:00
namespace LANCommander.Server.Services
2024-06-30 23:10:55 -05:00
{
public sealed class PlatformService(
ILogger<PlatformService> logger,
SettingsProvider<Settings.Settings> settingsProvider,
IFusionCache cache,
IHttpContextAccessor httpContextAccessor,
2026-07-02 18:09:14 -05:00
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<Platform>(logger, settingsProvider, cache, httpContextAccessor, contextFactory)
2024-06-30 23:10:55 -05:00
{
2025-02-23 08:49:43 -06:00
public override async Task<Platform> AddAsync(Platform entity)
{
2026-07-02 20:01:04 -05:00
await cache.ExpireGameCacheAsync();
2025-02-23 08:49:43 -06:00
return await base.AddAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(p => p.Games);
});
}
2025-02-02 14:58:07 -06:00
public override async Task<Platform> UpdateAsync(Platform entity)
{
2026-07-02 20:01:04 -05:00
await cache.ExpireGameCacheAsync();
2025-02-02 14:58:07 -06:00
return await base.UpdateAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(p => p.Games);
});
}
2026-07-02 20:01:04 -05:00
public override async Task DeleteAsync(Platform entity)
{
await cache.ExpireGameCacheAsync();
await base.DeleteAsync(entity);
}
2024-06-30 23:10:55 -05:00
}
}