2025-08-19 03:08:30 -05:00
|
|
|
|
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 ChatThreadService(
|
|
|
|
|
|
ILogger<ChatThreadService> logger,
|
2025-11-16 12:31:25 -06:00
|
|
|
|
SettingsProvider<Settings.Settings> settingsProvider,
|
2025-08-19 03:08:30 -05:00
|
|
|
|
IFusionCache cache,
|
|
|
|
|
|
IMapper mapper,
|
|
|
|
|
|
IHttpContextAccessor httpContextAccessor,
|
2025-11-16 12:31:25 -06:00
|
|
|
|
IDbContextFactory<DatabaseContext> context) : BaseDatabaseService<ChatThread>(logger, settingsProvider, cache, mapper, httpContextAccessor, context)
|
2025-08-19 03:08:30 -05:00
|
|
|
|
{
|
|
|
|
|
|
public override async Task<ChatThread> AddAsync(ChatThread entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await base.AddAsync(entity, async context =>
|
|
|
|
|
|
{
|
|
|
|
|
|
await context.UpdateRelationshipAsync(ct => ct.Messages);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<ChatThread> UpdateAsync(ChatThread entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await base.UpdateAsync(entity, async context =>
|
|
|
|
|
|
{
|
2025-10-28 22:19:48 -05:00
|
|
|
|
await context.UpdateRelationshipAsync(ct => ct.Participants);
|
2025-08-19 03:08:30 -05:00
|
|
|
|
await context.UpdateRelationshipAsync(ct => ct.Messages);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|