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

View File

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