LANCommander/LANCommander.Server.Services/CompanyService.cs
2025-02-23 08:50:16 -06:00

36 lines
1.3 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 CompanyService(
ILogger<CompanyService> logger,
IFusionCache cache,
IMapper mapper,
IHttpContextAccessor httpContextAccessor,
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<Company>(logger, cache, mapper, httpContextAccessor, contextFactory)
{
public override async Task<Company> AddAsync(Company entity)
{
return await base.AddAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(c => c.DevelopedGames);
await context.UpdateRelationshipAsync(c => c.PublishedGames);
});
}
public override async Task<Company> UpdateAsync(Company entity)
{
return await base.UpdateAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(c => c.DevelopedGames);
await context.UpdateRelationshipAsync(c => c.PublishedGames);
});
}
}
}