using AutoMapper; using LANCommander.Server.Data; using LANCommander.Server.Data.Models; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using ZiggyCreatures.Caching.Fusion; using LANCommander.Server.Services.Extensions; namespace LANCommander.Server.Services { public sealed class PlatformService( ILogger logger, SettingsProvider settingsProvider, IFusionCache cache, IMapper mapper, IHttpContextAccessor httpContextAccessor, IDbContextFactory contextFactory) : BaseDatabaseService(logger, settingsProvider, cache, mapper, httpContextAccessor, contextFactory) { public override async Task AddAsync(Platform entity) { await cache.ExpireGameCacheAsync(); return await base.AddAsync(entity, async context => { await context.UpdateRelationshipAsync(p => p.Games); }); } public override async Task UpdateAsync(Platform entity) { await cache.ExpireGameCacheAsync(); return await base.UpdateAsync(entity, async context => { await context.UpdateRelationshipAsync(p => p.Games); }); } public override async Task DeleteAsync(Platform entity) { await cache.ExpireGameCacheAsync(); await base.DeleteAsync(entity); } } }