2025-07-25 17:57:33 -05:00
|
|
|
|
using AutoMapper;
|
|
|
|
|
|
using LANCommander.Server.Data;
|
|
|
|
|
|
using LANCommander.Server.Data.Models;
|
|
|
|
|
|
using LANCommander.Server.Services.Extensions;
|
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
|
using ZiggyCreatures.Caching.Fusion;
|
|
|
|
|
|
using LANCommander.Server.Services.Models;
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.Server.Services
|
|
|
|
|
|
{
|
|
|
|
|
|
public class GameCustomFieldService(
|
|
|
|
|
|
ILogger<GameCustomFieldService> logger,
|
2025-11-16 12:31:25 -06:00
|
|
|
|
SettingsProvider<Settings.Settings> settingsProvider,
|
2025-07-25 17:57:33 -05:00
|
|
|
|
IFusionCache cache,
|
|
|
|
|
|
IMapper mapper,
|
|
|
|
|
|
IHttpContextAccessor httpContextAccessor,
|
2025-11-16 12:31:25 -06:00
|
|
|
|
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<GameCustomField>(logger, settingsProvider, cache, mapper, httpContextAccessor, contextFactory)
|
2025-07-25 17:57:33 -05:00
|
|
|
|
{
|
|
|
|
|
|
public override async Task<GameCustomField> AddAsync(GameCustomField entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await base.AddAsync(entity, async context =>
|
|
|
|
|
|
{
|
|
|
|
|
|
await context.UpdateRelationshipAsync(cf => cf.Game);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<ExistingEntityResult<GameCustomField>> AddMissingAsync(Expression<Func<GameCustomField, bool>> predicate, GameCustomField entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
await cache.ExpireGameCacheAsync(entity.Id);
|
|
|
|
|
|
|
|
|
|
|
|
return await base.AddMissingAsync(predicate, entity);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<GameCustomField> UpdateAsync(GameCustomField entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
await cache.ExpireGameCacheAsync(entity.Id);
|
|
|
|
|
|
|
|
|
|
|
|
var update = await base.UpdateAsync(entity, async context =>
|
|
|
|
|
|
{
|
|
|
|
|
|
await context.UpdateRelationshipAsync(g => g.Game);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return update;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task DeleteAsync(GameCustomField gameCustomField)
|
|
|
|
|
|
{
|
|
|
|
|
|
gameCustomField = await GetAsync(gameCustomField.Id);
|
|
|
|
|
|
|
|
|
|
|
|
await cache.ExpireGameCacheAsync(gameCustomField.GameId);
|
|
|
|
|
|
await base.DeleteAsync(gameCustomField);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|