small fixes

This commit is contained in:
RaidMax 2021-08-14 11:30:15 -05:00
parent 67c2406325
commit fa66381193
2 changed files with 14 additions and 7 deletions

View File

@ -5,6 +5,7 @@ using SharedLibraryCore;
using SharedLibraryCore.Dtos; using SharedLibraryCore.Dtos;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Http;
namespace LiveRadar.Web.Controllers namespace LiveRadar.Web.Controllers
{ {
@ -48,16 +49,22 @@ namespace LiveRadar.Web.Controllers
public IActionResult Map(long? serverId = null) public IActionResult Map(long? serverId = null)
{ {
var server = serverId == null ? _manager.GetServers().FirstOrDefault() : _manager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId); var server = serverId == null ? _manager.GetServers().FirstOrDefault() : _manager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId);
if (server == null)
{
return NotFound();
}
var map = _config.Maps.FirstOrDefault(_map => _map.Name == server.CurrentMap.Name); var map = _config.Maps.FirstOrDefault(_map => _map.Name == server.CurrentMap.Name);
if (map != null) if (map == null)
{ {
map.Alias = server.CurrentMap.Alias; // occurs if we don't recognize the map
return Json(map); return StatusCode(StatusCodes.Status422UnprocessableEntity);
} }
// occurs if we don't recognize the map map.Alias = server.CurrentMap.Alias;
return StatusCode(500); return Json(map);
} }
[HttpGet] [HttpGet]

View File

@ -306,7 +306,7 @@ namespace SharedLibraryCore
{ {
get get
{ {
return Clients.Count(p => p != null && !p.IsBot); return Clients.ToArray().Count(p => p != null && !p.IsBot);
} }
} }
public int MaxClients { get; protected set; } public int MaxClients { get; protected set; }