update for database provider specific migrations

fix issues with live radar
This commit is contained in:
RaidMax
2020-11-27 21:52:52 -06:00
parent 8ef2959f63
commit 36a02b3d7b
309 changed files with 76554 additions and 1067 deletions

View File

@ -13,9 +13,11 @@ namespace WebfrontCore.Controllers
{
public class PenaltyController : BaseController
{
public PenaltyController(IManager manager) : base(manager)
private readonly IDatabaseContextFactory _contextFactory;
public PenaltyController(IManager manager, IDatabaseContextFactory contextFactory) : base(manager)
{
_contextFactory = contextFactory;
}
public IActionResult List(PenaltyType showOnly = PenaltyType.Any, bool hideAutomatedPenalties = true)
@ -47,30 +49,28 @@ namespace WebfrontCore.Controllers
{
IList<PenaltyInfo> penalties;
using (var ctx = new DatabaseContext(disableTracking: true))
{
var iqPenalties = ctx.Penalties
.AsNoTracking()
.Where(p => p.Type == PenaltyType.Ban && p.Active)
.OrderByDescending(_penalty => _penalty.When)
.Select(p => new PenaltyInfo()
{
Id = p.PenaltyId,
OffenderId = p.OffenderId,
OffenderName = p.Offender.CurrentAlias.Name,
OffenderNetworkId = (ulong)p.Offender.NetworkId,
OffenderIPAddress = Authorized ? p.Offender.CurrentAlias.IPAddress.ConvertIPtoString() : null,
Offense = p.Offense,
PunisherId = p.PunisherId,
PunisherNetworkId = (ulong)p.Punisher.NetworkId,
PunisherName = p.Punisher.CurrentAlias.Name,
PunisherIPAddress = Authorized ? p.Punisher.CurrentAlias.IPAddress.ConvertIPtoString() : null,
TimePunished = p.When,
AutomatedOffense = Authorized ? p.AutomatedOffense : null,
});
await using var ctx = _contextFactory.CreateContext(false);
var iqPenalties = ctx.Penalties
.AsNoTracking()
.Where(p => p.Type == PenaltyType.Ban && p.Active)
.OrderByDescending(_penalty => _penalty.When)
.Select(p => new PenaltyInfo()
{
Id = p.PenaltyId,
OffenderId = p.OffenderId,
OffenderName = p.Offender.CurrentAlias.Name,
OffenderNetworkId = (ulong)p.Offender.NetworkId,
OffenderIPAddress = Authorized ? p.Offender.CurrentAlias.IPAddress.ConvertIPtoString() : null,
Offense = p.Offense,
PunisherId = p.PunisherId,
PunisherNetworkId = (ulong)p.Punisher.NetworkId,
PunisherName = p.Punisher.CurrentAlias.Name,
PunisherIPAddress = Authorized ? p.Punisher.CurrentAlias.IPAddress.ConvertIPtoString() : null,
TimePunished = p.When,
AutomatedOffense = Authorized ? p.AutomatedOffense : null,
});
penalties = await iqPenalties.ToListAsync();
}
penalties = await iqPenalties.ToListAsync();
return Json(penalties);
}