//Check for om hvor vidt kunden / unit / rum eller typen eksisterer i forvejen public string AddUnit(string UnitID, string Room, string type, string customer) { DataAccess da = new DataAccess(); if (!da.UnitExist(UnitID)) { if (da.customerExist(customer)) { if (!da.UnitExist(UnitID, customer)) { if (da.TypeExist(type, customer)) { if (da.RoomExist(Room, customer)) { return AddUnitForCustomer(UnitID, Room, type, customer); } else { //Lav room if (da.AddRoom(Room, customer)) { return AddUnitForCustomer(UnitID, Room, type, customer); } else { return "Failed to add room"; } } } else { if (da.AddType(type, customer)) { if (da.RoomExist(Room, customer)) { return AddUnitForCustomer(UnitID, Room, type, customer); } else { //Create room if (da.AddRoom(Room, customer)) { return AddUnitForCustomer(UnitID, Room, type, customer); } else { return "Failed to add room"; } } } else { return "Failed to add type"; } } } else { return "Unit already exist in your database"; } } else { return "customer doesn't exist"; } } else { return "Unit already exist in Customer Database"; } }