2024-08-04 18:44:33 -05:00
|
|
|
|
using LANCommander.Server.Data;
|
2025-02-01 02:21:34 -06:00
|
|
|
|
using AutoMapper;
|
2024-10-07 18:04:26 -05:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
using LANCommander.Server.Services.Extensions;
|
2025-02-09 18:53:40 -06:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2025-02-01 02:21:34 -06:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-10-30 17:44:10 -05:00
|
|
|
|
using ZiggyCreatures.Caching.Fusion;
|
2023-03-18 00:44:31 -05:00
|
|
|
|
|
2024-08-04 18:44:33 -05:00
|
|
|
|
namespace LANCommander.Server.Services
|
2023-03-18 00:44:31 -05:00
|
|
|
|
{
|
2025-02-01 02:21:34 -06:00
|
|
|
|
public sealed class ServerService(
|
|
|
|
|
|
ILogger<ServerService> logger,
|
|
|
|
|
|
IFusionCache cache,
|
|
|
|
|
|
IMapper mapper,
|
2025-02-09 18:53:40 -06:00
|
|
|
|
IHttpContextAccessor httpContextAccessor,
|
2025-02-16 10:08:05 -06:00
|
|
|
|
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<Data.Models.Server>(logger, cache, mapper, httpContextAccessor, contextFactory)
|
2023-03-18 00:44:31 -05:00
|
|
|
|
{
|
2025-01-25 12:46:35 -06:00
|
|
|
|
public override async Task<Data.Models.Server> UpdateAsync(Data.Models.Server entity)
|
|
|
|
|
|
{
|
2025-02-01 02:21:34 -06:00
|
|
|
|
await cache.ExpireGameCacheAsync(entity.GameId);
|
2025-01-25 12:46:35 -06:00
|
|
|
|
|
2025-02-02 14:58:07 -06:00
|
|
|
|
return await base.UpdateAsync(entity, async context =>
|
|
|
|
|
|
{
|
|
|
|
|
|
await context.UpdateRelationshipAsync(s => s.Actions);
|
|
|
|
|
|
await context.UpdateRelationshipAsync(s => s.Game);
|
|
|
|
|
|
await context.UpdateRelationshipAsync(s => s.HttpPaths);
|
|
|
|
|
|
await context.UpdateRelationshipAsync(s => s.Pages);
|
|
|
|
|
|
await context.UpdateRelationshipAsync(s => s.Scripts);
|
|
|
|
|
|
await context.UpdateRelationshipAsync(s => s.ServerConsoles);
|
|
|
|
|
|
});
|
2025-01-25 12:46:35 -06:00
|
|
|
|
}
|
2023-03-18 00:44:31 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|