2019-02-26 22:25:27 -05:00
|
|
|
|
using IW4MAdmin.Plugins.Stats;
|
|
|
|
|
using IW4MAdmin.Plugins.Stats.Helpers;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2019-12-02 16:52:36 -05:00
|
|
|
|
namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
|
2019-02-26 22:25:27 -05:00
|
|
|
|
{
|
|
|
|
|
public class TopPlayersViewComponent : ViewComponent
|
|
|
|
|
{
|
|
|
|
|
public async Task<IViewComponentResult> InvokeAsync(int count, int offset, long? serverId = null)
|
|
|
|
|
{
|
|
|
|
|
if (serverId == 0)
|
|
|
|
|
{
|
|
|
|
|
serverId = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var server = Plugin.ServerManager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId);
|
|
|
|
|
|
|
|
|
|
if (server != null)
|
|
|
|
|
{
|
2019-08-23 19:34:31 -04:00
|
|
|
|
serverId = StatManager.GetIdForServer(server);
|
2019-02-26 22:25:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return View("_List", await Plugin.Manager.GetTopStats(offset, count, serverId));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|