private void clientsFoundListBox_SelectedIndexChanged(object sender, EventArgs e) { clientAutosListBox.Items.Clear(); sessionData.selectedClient = ClientMapper.fromModelToEntity((ClientModel)clientsFoundListBox.SelectedItem); if (sessionData.selectedClient == null) { clientCarsLabel.Visible = false; modifyAutoButton.Visible = false; deleteAutoButton.Visible = false; addAutoToClientButton.Visible = false; } else { var obtainedClient = sessionData.clientRepository.GetClient(sessionData.selectedClient.ClientId); if (obtainedClient != null) { clientCarsLabel.Visible = true; clientAutosListBox.Visible = true; modifyAutoButton.Visible = true; deleteAutoButton.Visible = true; addAutoToClientButton.Visible = true; List <Automobil> clientAutos = sessionData.clientRepository.GetAutosOfClient(obtainedClient); foreach (var auto in clientAutos) { if (!clientAutosListBox.Items.Contains(auto)) { clientAutosListBox.Items.Add(AutoMapper.FromEntityToModel(auto)); } } } } }