IW4M-Admin/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs
RaidMax 4caa4655e2 abstracting rcon parsing and event parsing
changed Event to GameEvent
finally fixed the stats NaN
check ip for bans
consolidated console, profile, and logout into dropdown
make sure game is iw4 before using :^ in say
fix pm not showing from name if in web console
show time left of temban on profile
2018-04-13 01:32:30 -05:00

38 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Objects;
using System;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace WebfrontCore.ViewComponents
{
public class PenaltyListViewComponent : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync(int offset)
{
var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(15, offset);
var penaltiesDto = penalties.Select(p => new PenaltyInfo()
{
OffenderId = p.OffenderId,
OffenderName = p.Offender.Name,
PunisherId = p.PunisherId,
PunisherName = p.Punisher.Name,
PunisherLevel = p.Punisher.Level.ToString(),
Offense = p.Offense,
Type = p.Type.ToString(),
TimePunished = Utilities.GetTimePassed(p.When, false),
TimeRemaining = DateTime.UtcNow > p.Expires ? "" : Utilities.TimeSpanText(p.Expires - DateTime.UtcNow),
Sensitive = p.Type == Penalty.PenaltyType.Flag
});
bool authorized = User.Identity.IsAuthenticated;
penaltiesDto = authorized ? penaltiesDto.ToList() : penaltiesDto.Where(p => !p.Sensitive).ToList();
return View("_List", penaltiesDto);
}
}
}