IW4M-Admin/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs
RaidMax c5375b661b huge commit for advanced stats feature.
broke data out into its own library.
may be breaking changes with existing plugins
2021-03-22 11:09:25 -05:00

21 lines
741 B
C#

using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Threading.Tasks;
using Data.Models;
namespace WebfrontCore.ViewComponents
{
public class PenaltyListViewComponent : ViewComponent
{
private const int PENALTY_COUNT = 15;
public async Task<IViewComponentResult> InvokeAsync(int offset, EFPenalty.PenaltyType showOnly, bool ignoreAutomated)
{
var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(PENALTY_COUNT, offset, showOnly, ignoreAutomated);
penalties = User.Identity.IsAuthenticated ? penalties : penalties.Where(p => !p.Sensitive).ToList();
return View("~/Views/Penalty/PenaltyInfoList.cshtml", penalties);
}
}
}