LANCommander/LANCommander.Server.Services/IssueService.cs

51 lines
1.7 KiB
C#
Raw Permalink Normal View History

using System.Configuration;
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(
UserService userService,
ILogger<IssueService> logger,
SettingsProvider<Settings.Settings> settingsProvider,
IFusionCache cache,
IMapper mapper,
IHttpContextAccessor httpContextAccessor,
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<Issue>(logger, settingsProvider, cache, mapper, httpContextAccessor, contextFactory)
{
2025-02-23 08:49:43 -06:00
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);
});
}
2025-02-02 14:58:07 -06:00
public override async Task<Issue> UpdateAsync(Issue entity)
{
2025-02-02 14:58:07 -06:00
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, Guid userId)
{
var issue = await GetAsync(issueId);
var user = await userService.GetAsync(userId);
2024-10-23 23:19:25 -05:00
issue.ResolvedOn = DateTime.UtcNow;
issue.ResolvedBy = user;
await UpdateAsync(issue);
}
}
}