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

46 lines
1.5 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> AddAsync(Issue entity)
{
return await base.AddAsync(entity, async context =>
{
await context.UpdateRelationshipAsync(i => i.Game);
await context.UpdateRelationshipAsync(i => i.ResolvedBy);
});
}
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);
}
}
}