LANCommander/LANCommander.Server.Services/GenreService.cs
2025-02-25 21:24:11 -06:00

34 lines
1.1 KiB
C#

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 GenreService(
ILogger<GenreService> logger,
IFusionCache cache,
IMapper mapper,
IHttpContextAccessor httpContextAccessor,
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<Genre>(logger, cache, mapper, httpContextAccessor, contextFactory)
{
public override async Task<Genre> AddAsync(Genre entity)
{
return await base.AddAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(g => g.Games);
});
}
public override async Task<Genre> UpdateAsync(Genre entity)
{
return await base.UpdateAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(g => g.Games);
});
}
}
}