/// <summary> /// sub menu for creating a new Customer and adding it to the database /// </summary> /// <param name="data">the DBcontect for the database</param> public static void AddCustomer(IDataBase data) { Console.Write("Enter the first name of the customer: "); string firstName = Console.ReadLine(); Console.Write("Enter the last name of the customer: "); string lastName = Console.ReadLine(); List <Customer> customers = data.GetAllCustomers(firstName: firstName, lastName: lastName).ToList(); if (customers.Count == 0) { try { Customer customer = new Customer() { Id = 0, FirstName = firstName, LastName = lastName, }; data.AddCustomer(customer); data.Save(); Console.WriteLine($"Customer [{firstName}] [{lastName}] added"); } catch (ArgumentException ex) { Log.Warning("Error in database update {Message}", ex.Message); Console.WriteLine($"Error in creating new customer: {ex.Message}"); } catch (DbUpdateConcurrencyException ex) { Log.Warning("Error in database update {Message}", ex.Message); Console.WriteLine($"Error in creating new customer: {ex.Message}"); } catch (DbUpdateException ex) { Log.Warning("Error in database update {Message}", ex.Message); Console.WriteLine($"Error in creating new customer: {ex.Message}"); } } else { Console.WriteLine("Customer allready exist"); } Console.Write("Press enter to continue: "); Console.ReadLine(); }