public string AddLog(string unitID, DateTime timestamp, string action) { DataAccess da = new DataAccess(); //Send til generelt log table if (da.AddLogToMainTable(unitID, timestamp, action)) { //Find out which customer got the ID, then go to below IF statement if (da.UnitExist(unitID)) { string customer = da.getCustomerForUnit(unitID); //RegionH should be replaced by customer if (da.UnitExist(unitID, customer)) { if (da.EventExistForUnit(unitID, action)) { if (da.AddLog(unitID, timestamp, action)) { if (doSpecialEvent(unitID, action, customer)) { return "Log added, special event"; } else { return "Log added, no special event"; } } else { return "Log added to main table - Failed to add to customer table"; } } else { return "Log added to main table - Action not found for unit"; } } else { return "Log added to main database - Unit not found in a customer table"; } } else { return "Log added to main table - Unit not mapped to a customer"; } } //Failed to add log to main database else { return "Failed to add log to main database"; } }