LANCommander/LANCommander.Server.Services/ActionService.cs

38 lines
1.3 KiB
C#
Raw Permalink Normal View History

2025-03-29 17:58:10 -05:00
using AutoMapper;
using LANCommander.Server.Data;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using ZiggyCreatures.Caching.Fusion;
using Action = LANCommander.Server.Data.Models.Action;
namespace LANCommander.Server.Services
{
public sealed class ActionService(
ILogger<ActionService> logger,
SettingsProvider<Settings.Settings> settingsProvider,
2025-03-29 17:58:10 -05:00
IFusionCache cache,
IMapper mapper,
IHttpContextAccessor httpContextAccessor,
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<Action>(logger, settingsProvider, cache, mapper, httpContextAccessor, contextFactory)
2025-03-29 17:58:10 -05:00
{
public override async Task<Action> AddAsync(Action entity)
{
return await base.AddAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(a => a.Game);
await context.UpdateRelationshipAsync(a => a.Server);
});
}
public async override Task<Action> UpdateAsync(Action entity)
{
return await base.UpdateAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(a => a.Game);
await context.UpdateRelationshipAsync(a => a.Server);
});
}
}
}