2018-02-21 19:29:23 -06:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2019-05-29 16:55:35 -05:00
|
|
|
|
using SharedLibraryCore.Database.Models;
|
2018-02-21 19:29:23 -06:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace WebfrontCore.ViewComponents
|
|
|
|
|
{
|
|
|
|
|
public class PenaltyListViewComponent : ViewComponent
|
|
|
|
|
{
|
2019-03-31 19:56:31 -05:00
|
|
|
|
private const int PENALTY_COUNT = 15;
|
|
|
|
|
|
2019-05-29 16:55:35 -05:00
|
|
|
|
public async Task<IViewComponentResult> InvokeAsync(int offset, EFPenalty.PenaltyType showOnly)
|
2018-02-21 19:29:23 -06:00
|
|
|
|
{
|
2019-03-31 19:56:31 -05:00
|
|
|
|
var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(PENALTY_COUNT, offset, showOnly);
|
|
|
|
|
penalties = User.Identity.IsAuthenticated ? penalties : penalties.Where(p => !p.Sensitive).ToList();
|
2018-03-06 01:22:19 -06:00
|
|
|
|
|
2019-03-31 19:56:31 -05:00
|
|
|
|
return View("_List", penalties);
|
2018-02-21 19:29:23 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|