IW4M-Admin/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs

21 lines
763 B
C#
Raw Normal View History

2018-02-21 20:29:23 -05:00
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore.Database.Models;
2018-02-21 20:29:23 -05:00
using System.Linq;
using System.Threading.Tasks;
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)
2018-02-21 20:29:23 -05:00
{
var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(PENALTY_COUNT, offset, showOnly, ignoreAutomated);
penalties = User.Identity.IsAuthenticated ? penalties : penalties.Where(p => !p.Sensitive).ToList();
2018-03-06 02:22:19 -05:00
return View("~/Views/Penalty/PenaltyInfoList.cshtml", penalties);
2018-02-21 20:29:23 -05:00
}
}
}