/// <summary> /// Verify machine doesn't already exist in Database /// </summary> /// <param name="LicensedMachineName"></param> /// <param name="DBDIR_Name"></param> public static bool MachineExist(string MachineToLookFor, string DBDIR_Name, out List <int> LicenseIDs) { DataAccess_LicensedMachinesTable DBLM = new DataAccess_LicensedMachinesTable(); List <LicensedMachines> Duplicates = new List <LicensedMachines>(); // SEARCH FOR DUPLICATES BY NAME Duplicates = DBLM.FindDuplicate(MachineToLookFor, DBDIR_Name); // DUPLICATE FOUND return true if (Duplicates.Count > 0) { List <int> DupLicenses = new List <int>(); foreach (LicensedMachines machine in Duplicates) { DupLicenses.Add(machine.LicenseId);; } LicenseIDs = DupLicenses; // Return License ID's return(true); // Return Duplicate found = true; } else // NO DUPLICATE FOUND return false { LicenseIDs = null; return(false); } }
/// <summary> /// Verify machine doesn't already exist in Database /// </summary> /// <param name="LicensedMachine"></param> /// <param name="DBDIR_Name"></param> /// <param name="LicenseIDs"></param> /// <returns></returns> public static bool MachineExist(LicensedMachines MachineBeingEdited, string MachineToLookFor, string DBDIR_Name, out List <int> LicenseIDs) { List <LicensedMachines> Duplicates = new List <LicensedMachines>(); // SEARCH FOR DUPLICATES BY NAME Duplicates = DataAccess_LicensedMachinesTable.FindDuplicate(MachineToLookFor, DBDIR_Name); // COMPARE WITH LICENSE BEING EDITED List <LicensedMachines> VerifiedDuplicates = new List <LicensedMachines>(); if (Duplicates.Count > 0) { foreach (LicensedMachines machine in Duplicates) { // Verify the machine with identical name isn't the machine currently being created/edited if (machine.Id != MachineBeingEdited.Id) { VerifiedDuplicates.Add(machine); } } } // DUPLICATE FOUND return value and true if (VerifiedDuplicates.Count > 0) { List <int> DupLicenses = new List <int>(); foreach (LicensedMachines machine in VerifiedDuplicates) { DupLicenses.Add(machine.LicenseId);; } LicenseIDs = DupLicenses; // Return License ID's return(true); // Return Duplicate found = true; } else // NO DUPLICATE FOUND return false { LicenseIDs = null; return(false); } }