static void DeleteEntry(DefaultContainer container) { string userInput = " "; int cleanInput = 0; Console.WriteLine($"Give the ID of the entity you wish to remove \n"); userInput = Console.ReadLine(); while (!int.TryParse(userInput, out cleanInput)) { Console.Write("This is not valid input. Please enter an integer value: \n"); userInput = Console.ReadLine(); } foreach (var p in container.Contact) { if (p.Index == cleanInput) { container.DeleteObject(p); var serviceResponse = container.SaveChanges(); foreach (var operationResponse in serviceResponse) { Console.WriteLine("Response: {0}", operationResponse.StatusCode); } } } Console.WriteLine($"Your result: removed a entity \n"); }
static void AddEntry(DefaultContainer container) { bool answer = false; string input1 = ""; string colour = ""; int cleanNum1 = 0; int iD = 0; var p = new ContactRecord(); //Console.Write("Type the number of cars made, and then press Enter: \n"); //input1 = Console.ReadLine(); //while (!int.TryParse(input1, out cleanNum1)) //{ // Console.Write("This is not valid input. Please enter an integer value: \n"); // input1 = Console.ReadLine(); //} Console.Write("Type the job title, and then press Enter: \n"); colour = Console.ReadLine(); //Console.Write("Is the car APK certifeid? Type true or false, and then press Enter: \n"); //input1 = Console.ReadLine().ToLower(); iD = GetCorrectID(container); if (string.Equals(input1, "true")) { answer = true; } p.Index = iD; p.JobTitle = colour; //p.AmountMade = cleanNum1; //p.Colour = colour; //p.TimeWhenAddedToDatabase = DateTime.Now; //p.APK = answer; //container.AddObject("cars", p); container.AddObject("Contact", p); var serviceResponse = container.SaveChanges(); foreach (var operationResponse in serviceResponse) { Console.WriteLine("Response: {0}", operationResponse.StatusCode); } Console.WriteLine($"Your result: Added a car"); }