public string AddEventForType(string type, string action, string description, string customer) { DataAccess da = new DataAccess(); if (da.TypeExist(type, customer)) { if (da.ActionExistForType(type, action, customer)) { return "'" + action + "' event already exist for " + type; } else { //Tilføjer event til en type if (da.AddEventForType(type, action, description, customer)) { return "'" + action + "' event added to " + type; } else { return "failed to add '" + action + "' for " + type; } } } else { //Lav typen af enhed hos kunden if (da.AddType(type, customer)) { //Tilføjer event til en type if (da.AddEventForType(type, action, description, customer)) { return "'" + action + "' event added to " + type; } else { return "failed to add '" + action + "' for " + type; } } else { return type + " type doesn't exist & failed to add it"; } } }
//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"; } }
public string AddType(string type, string customer) { DataAccess da = new DataAccess(); if (!da.TypeExist(type, customer)) { if (da.AddType(type, customer)) { return type + " type added"; } else { return "Error, while adding type"; } } else { return "Type already exist"; } }