/// <summary> /// sub menu for creating a new Location and adding it to the database /// </summary> /// <param name="data">the DBcontect for the database</param> public static void AddLocation(IDataBase data) { Console.Write("Enter the a name of the location: "); string name = Console.ReadLine(); List <Location> locations = data.GetAllLocations(name: name).ToList(); if (locations.Count == 0) { try { Location location = new Location() { Id = 0, Name = name, }; data.AddLocation(location); data.Save(); } catch (ArgumentException ex) { Log.Warning("Error in database update {Message}", ex.Message); Console.WriteLine($"Error in creating new location: {ex.Message}"); } catch (DbUpdateConcurrencyException ex) { Log.Warning("Error in database update {Message}", ex.Message); Console.WriteLine($"Error in creating new location: {ex.Message}"); } catch (DbUpdateException ex) { Log.Warning("Error in database update {Message}", ex.Message); Console.WriteLine($"Error in creating new location: {ex.Message}"); } } else { Console.WriteLine("Location allready exist"); } Console.Write("Press enter to continue: "); Console.ReadLine(); }