1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

migrated to ASP.Net Core

This commit is contained in:
RaidMax
2018-02-21 19:29:23 -06:00
parent 2e0b5f2d71
commit 761ab8a114
4407 changed files with 311698 additions and 124726 deletions

View File

@ -0,0 +1,41 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.Controllers
{
public class ServerController : Controller
{
[HttpGet]
public IActionResult ClientActivity(int id)
{
var s = IW4MAdmin.Program.ServerManager.GetServers().FirstOrDefault(s2 => s2.GetHashCode() == id);
if (s == null)
return View("Error", "Invalid server!");
var serverInfo = new ServerInfo()
{
Name = s.Hostname,
ID = s.GetHashCode(),
Port = s.GetPort(),
Map = s.CurrentMap.Alias,
ClientCount = s.ClientNum,
MaxClients = s.MaxClients,
GameType = s.Gametype,
Players = s.Players.Where(p => p != null).Select(p => new PlayerInfo
{
Name = p.Name,
ClientId = p.ClientId
}).ToList(),
ChatHistory = s.ChatHistory,
PlayerHistory = s.PlayerHistory.ToArray()
};
return PartialView("_ClientActivity", serverInfo);
}
}
}