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; namespace LANCommander.Server.Services { public sealed class StorageLocationService( ILogger logger, IFusionCache cache, IMapper mapper, IHttpContextAccessor httpContextAccessor, IDbContextFactory contextFactory) : BaseDatabaseService(logger, cache, mapper, httpContextAccessor, contextFactory) { public override async Task AddAsync(StorageLocation entity) { return await base.AddAsync(entity, async context => { await context.UpdateRelationshipAsync(sl => sl.Archives); await context.UpdateRelationshipAsync(sl => sl.GameSaves); await context.UpdateRelationshipAsync(sl => sl.Media); }); } public override async Task UpdateAsync(StorageLocation entity) { return await base.UpdateAsync(entity, async context => { await context.UpdateRelationshipAsync(sl => sl.Archives); await context.UpdateRelationshipAsync(sl => sl.GameSaves); await context.UpdateRelationshipAsync(sl => sl.Media); }); } } }