private static ClientObject GetOrAddClient(ClientCollection clients, CsvData data) { ClientObject client = clients.Where(c => c.ClientID == data.ClientId).FirstOrDefault(); if (client == null) { client = new ClientObject(data.ClientId) { Email = data.Email, PreferredName = data.PreferredName }; clients.Add(client); } return(client); }
}//end validate method /// <summary> /// Verifies if a string is already present in database as a ClientCode /// </summary> /// <param name="clientCodeToCheck">the client code to check</param> /// <returns>wether the client code already exists in the database</returns> public static bool existingClientCode(string clientCodeToCheck) { bool existing = false; ClientCollection allClients = ClientRepository.GetAllClients(); var match = allClients.Where(x => x.ClientCode.Contains(clientCodeToCheck)); if (match.Any()) { existing = true; } return(existing); }