LANCommander/LANCommander.Server.Services/RatingService.cs

35 lines
1.2 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 RatingService(
ILogger<RatingService> logger,
SettingsProvider<Settings.Settings> settingsProvider,
IFusionCache cache,
IMapper mapper,
IHttpContextAccessor httpContextAccessor,
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<Rating>(logger, settingsProvider, cache, mapper, httpContextAccessor, contextFactory)
{
public override async Task<Rating> AddAsync(Rating entity)
{
return await base.AddAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(r => r.Game);
});
}
public override async Task<Rating> UpdateAsync(Rating entity)
{
return await base.UpdateAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(r => r.Game);
});
}
}
}