2024-08-11 14:48:00 -05:00
|
|
|
|
using LANCommander.Server.Data;
|
|
|
|
|
|
using LANCommander.Server.Data.Models;
|
2025-02-01 02:21:34 -06:00
|
|
|
|
using AutoMapper;
|
2025-02-09 18:53:40 -06:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2025-02-01 02:21:34 -06:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-10-07 18:04:26 -05:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2024-10-30 17:44:10 -05:00
|
|
|
|
using ZiggyCreatures.Caching.Fusion;
|
2024-08-11 14:48:00 -05:00
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.Server.Services
|
|
|
|
|
|
{
|
2025-02-01 02:21:34 -06:00
|
|
|
|
public sealed class IssueService(
|
|
|
|
|
|
ILogger<IssueService> logger,
|
|
|
|
|
|
IFusionCache cache,
|
|
|
|
|
|
IMapper mapper,
|
2025-02-09 18:53:40 -06:00
|
|
|
|
IHttpContextAccessor httpContextAccessor,
|
|
|
|
|
|
IDbContextFactory<DatabaseContext> contextFactory) : BaseDatabaseService<Issue>(logger, cache, mapper, httpContextAccessor, contextFactory)
|
2024-08-11 14:48:00 -05:00
|
|
|
|
{
|
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)
|
2024-08-11 14:48:00 -05:00
|
|
|
|
{
|
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);
|
|
|
|
|
|
});
|
2024-08-11 14:48:00 -05:00
|
|
|
|
}
|
2025-02-01 02:21:34 -06:00
|
|
|
|
|
2024-08-11 14:48:00 -05:00
|
|
|
|
public async Task ResolveAsync(Guid issueId)
|
|
|
|
|
|
{
|
2024-11-12 18:32:46 -06:00
|
|
|
|
var issue = await GetAsync(issueId);
|
2024-08-11 14:48:00 -05:00
|
|
|
|
|
2024-10-23 23:19:25 -05:00
|
|
|
|
issue.ResolvedOn = DateTime.UtcNow;
|
2024-10-07 18:04:26 -05:00
|
|
|
|
// issue.ResolvedBy = await GetCurrentUserAsync();
|
2024-08-11 14:48:00 -05:00
|
|
|
|
|
2024-11-12 18:32:46 -06:00
|
|
|
|
await UpdateAsync(issue);
|
2024-08-11 14:48:00 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|