The way updates are being handled means that the auditing interceptor doesn't work as the entities are not showing in the change tracker at that stage as modified. Added the auditing to BaseDatabaseService instead.
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using LANCommander.Server.Data;
|
|
using LANCommander.Server.Data.Models;
|
|
using AutoMapper;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
using ZiggyCreatures.Caching.Fusion;
|
|
|
|
namespace LANCommander.Server.Services
|
|
{
|
|
public sealed class IssueService(
|
|
ILogger<IssueService> logger,
|
|
IFusionCache cache,
|
|
IMapper mapper,
|
|
IHttpContextAccessor httpContextAccessor,
|
|
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<Issue>(logger, cache, mapper, httpContextAccessor, contextFactory)
|
|
{
|
|
public override async Task<Issue> UpdateAsync(Issue entity)
|
|
{
|
|
return await base.UpdateAsync(entity, async context =>
|
|
{
|
|
await context.UpdateRelationshipAsync(i => i.Game);
|
|
await context.UpdateRelationshipAsync(i => i.ResolvedBy);
|
|
});
|
|
}
|
|
|
|
public async Task ResolveAsync(Guid issueId)
|
|
{
|
|
var issue = await GetAsync(issueId);
|
|
|
|
issue.ResolvedOn = DateTime.UtcNow;
|
|
// issue.ResolvedBy = await GetCurrentUserAsync();
|
|
|
|
await UpdateAsync(issue);
|
|
}
|
|
}
|
|
}
|