public async Task StartServerById(string id, int maxRamMB, int minRamMB) { var server = await _repo.GetServerById(id); if (server == null) { // TODO: Add error handling here return; } if (_runningServers.ContainsKey(id)) { // TODO: Add error handling here return; } var serverProcess = new ServerProcess(server.Id, maxRamMB, minRamMB); _runningServers.TryAdd(server.Id, serverProcess); var pId = serverProcess.StartServer(_logger, _angularHub); server.MaxRamMB = maxRamMB; server.MinRamMB = minRamMB; server.ProcessId = pId; server.IsRunning = true; server.TimesRan++; await _repo.UpsertServer(server); return; }
public async Task <IActionResult> GetServerById([Required] string id) { var server = await _repo.GetServerById(id); var serverDTO = _mapper.Map <MinecraftServerDTO>(server); return(Ok(serverDTO)); }
public async Task GetServerByIdTest() { // Arrange await _repo.AddServer(fooServer1); // Act var server = await _repo.GetServerById(fooServer1.Id); await _repo.RemoveServer(fooServer1.Id); // Assert Assert.NotNull(server); Assert.Equal(fooServer1.Id, server.Id); }