LANCommander/LANCommander.Server.Services/StorageLocationService.cs

39 lines
1.5 KiB
C#
Raw Permalink Normal View History

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<StorageLocationService> logger,
IFusionCache cache,
IMapper mapper,
IHttpContextAccessor httpContextAccessor,
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<StorageLocation>(logger, cache, mapper, httpContextAccessor, contextFactory)
{
2025-02-23 08:49:43 -06:00
public override async Task<StorageLocation> 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);
});
}
2025-02-02 14:58:07 -06:00
public override async Task<StorageLocation> UpdateAsync(StorageLocation entity)
{
2025-02-02 14:58:07 -06:00
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);
});
}
}
}