2026-07-02 18:09:14 -05:00
|
|
|
|
using LANCommander.Server.Data;
|
2025-03-29 20:10:35 -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;
|
2025-03-29 20:10:35 -05:00
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.Server.Services
|
|
|
|
|
|
{
|
|
|
|
|
|
public sealed class MultiplayerModeService(
|
|
|
|
|
|
ILogger<MultiplayerModeService> logger,
|
2025-11-16 12:31:25 -06:00
|
|
|
|
SettingsProvider<Settings.Settings> settingsProvider,
|
2025-03-29 20:10:35 -05:00
|
|
|
|
IFusionCache cache,
|
|
|
|
|
|
IHttpContextAccessor httpContextAccessor,
|
2026-07-02 18:09:14 -05:00
|
|
|
|
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<MultiplayerMode>(logger, settingsProvider, cache, httpContextAccessor, contextFactory)
|
2025-03-29 20:10:35 -05:00
|
|
|
|
{
|
|
|
|
|
|
public override async Task<MultiplayerMode> AddAsync(MultiplayerMode entity)
|
|
|
|
|
|
{
|
2026-07-02 20:01:04 -05:00
|
|
|
|
await cache.ExpireGameCacheAsync();
|
|
|
|
|
|
|
2025-03-29 20:10:35 -05:00
|
|
|
|
return await base.AddAsync(entity, async context =>
|
|
|
|
|
|
{
|
|
|
|
|
|
await context.UpdateRelationshipAsync(a => a.Game);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async override Task<MultiplayerMode> UpdateAsync(MultiplayerMode entity)
|
|
|
|
|
|
{
|
2026-07-02 20:01:04 -05:00
|
|
|
|
await cache.ExpireGameCacheAsync();
|
|
|
|
|
|
|
2025-03-29 20:10:35 -05:00
|
|
|
|
return await base.UpdateAsync(entity, async context =>
|
|
|
|
|
|
{
|
|
|
|
|
|
await context.UpdateRelationshipAsync(a => a.Game);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-07-02 20:01:04 -05:00
|
|
|
|
|
|
|
|
|
|
public override async Task DeleteAsync(MultiplayerMode entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
await cache.ExpireGameCacheAsync();
|
|
|
|
|
|
|
|
|
|
|
|
await base.DeleteAsync(entity);
|
|
|
|
|
|
}
|
2025-03-29 20:10:35 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|