public HttpStatusCodeResult UpdateAgentInMonitor(int inputAgentNr, string inputAgentName, string inputIpAddress, string inputPortNr, string typeName, bool cpuCheck, bool discCheck) { HttpStatusCodeResult output = new HttpStatusCodeResult(System.Net.HttpStatusCode.OK); try { SNMPController controller = new SNMPController(Properties.Settings.Default.ProdDatabaseConnectionString); int portNr; if (int.TryParse(inputPortNr, out portNr)) { List <SNMPMonitor.BusinessLayer.Type> types = controller.GetTypes(); SNMPMonitor.BusinessLayer.Type type = null; foreach (SNMPMonitor.BusinessLayer.Type temp in types) { if (temp.Name == typeName) { type = temp; } } Agent updatedAgent = new Agent(inputAgentNr, inputAgentName, inputIpAddress, type, portNr, 1, "", "", ""); controller.UpdateAgentInDatabase(updatedAgent, cpuCheck, discCheck); output = new HttpStatusCodeResult(System.Net.HttpStatusCode.OK); } } catch (Exception exc) { BusinessLayer.ExceptionHandling.ExceptionCore.HandleException(BusinessLayer.ExceptionHandling.ExceptionCategory.Normal, exc); } return(output); }
public void TestGetTypes() { List <Type> typesActual = controller.GetTypes(); List <Type> typesExpected = new List <Type>() { new Type(1, "Server"), new Type(2, "Switch") }; if (typesActual.Count == 2) { for (int i = 0; i < typesActual.Count; i++) { Assert.AreEqual(typesActual[i].TypeNr, typesExpected[i].TypeNr); Assert.AreEqual(typesActual[i].Name, typesExpected[i].Name); } } else { Assert.IsFalse(true); } }