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 TestUpdateAgent()
        {
            Agent newAgent = new Agent("Test-Server", "10.10.10.10", new Type(1, "Server"), 161);

            // Add new Agent to Database
            controller.AddAgentToDatabase(newAgent, false, false);

            // Get AgentNr for new added Agent
            List <Agent> agentsAfterAdd = controller.GetAgents();
            int          agentNr        = agentsAfterAdd[agentsAfterAdd.Count - 1].AgentNr;

            // Check MonitoringType for inserted Agent
            List <MonitoringType> monitoringTypesExpectedBeforeUpdate = new List <MonitoringType>();

            monitoringTypesExpectedBeforeUpdate.Add(new MonitoringType(1, "sysDesc", "1.3.6.1.2.1.1.1"));
            monitoringTypesExpectedBeforeUpdate.Add(new MonitoringType(9, "sysName", "1.3.6.1.2.1.1.5"));
            monitoringTypesExpectedBeforeUpdate.Add(new MonitoringType(10, "sysUptime", "1.3.6.1.2.1.25.1.1"));

            List <MonitoringType> monitoringTypesActualBeforeUpdate = controller.GetMonitoringTypesForAgent(agentNr);

            for (int i = 0; i < monitoringTypesActualBeforeUpdate.Count; i++)
            {
                Assert.AreEqual(monitoringTypesExpectedBeforeUpdate[i].MonitoringTypeNr, monitoringTypesActualBeforeUpdate[i].MonitoringTypeNr);
                Assert.AreEqual(monitoringTypesExpectedBeforeUpdate[i].Description, monitoringTypesActualBeforeUpdate[i].Description);
                Assert.AreEqual(monitoringTypesExpectedBeforeUpdate[i].ObjectID, monitoringTypesActualBeforeUpdate[i].ObjectID);
            }

            // Update new Agent
            controller.UpdateAgentInDatabase(agentsAfterAdd[agentsAfterAdd.Count - 1], true, true);

            // Check MonitoringType for updated Agent
            List <MonitoringType> monitoringTypesExpectedAfterUpdate = new List <MonitoringType>();

            monitoringTypesExpectedAfterUpdate.Add(new MonitoringType(1, "sysDesc", "1.3.6.1.2.1.1.1"));
            monitoringTypesExpectedAfterUpdate.Add(new MonitoringType(9, "sysName", "1.3.6.1.2.1.1.5"));
            monitoringTypesExpectedAfterUpdate.Add(new MonitoringType(10, "sysUptime", "1.3.6.1.2.1.25.1.1"));
            monitoringTypesExpectedAfterUpdate.Add(new MonitoringType(11, "cpuUsage", "1.3.6.1.2.1.25.3.3"));
            monitoringTypesExpectedAfterUpdate.Add(new MonitoringType(12, "hrDiskStorageTable", "1.3.6.1.2.1.25.3.2"));

            List <MonitoringType> monitoringTypesActualAfterUpdate = controller.GetMonitoringTypesForAgent(agentNr);

            for (int i = 0; i < monitoringTypesActualAfterUpdate.Count; i++)
            {
                Assert.AreEqual(monitoringTypesExpectedAfterUpdate[i].MonitoringTypeNr, monitoringTypesActualAfterUpdate[i].MonitoringTypeNr);
                Assert.AreEqual(monitoringTypesExpectedAfterUpdate[i].Description, monitoringTypesActualAfterUpdate[i].Description);
                Assert.AreEqual(monitoringTypesExpectedAfterUpdate[i].ObjectID, monitoringTypesActualAfterUpdate[i].ObjectID);
            }

            // Delete new Agent
            controller.DeleteAgent(agentNr);
        }