private static void UpdateCustomer() { Console.WriteLine("***************************"); Console.WriteLine("****** UPDATE ** *****"); Console.WriteLine("***************************"); var customer = new Customer(); Console.WriteLine("Type the customer id:"); customer.Id = Console.ReadLine(); customer = CtmManagement.RetrieveById(customer); if (customer != null) { Console.WriteLine(" ==> " + customer.GetEntityInformation()); Console.WriteLine("Type a new name, actual value is " + customer.Name); customer.Name = Console.ReadLine(); Console.WriteLine("Type a new last name, actual value is " + customer.LastName); customer.LastName = Console.ReadLine(); Console.WriteLine("Type a new age, actual value is " + customer.Age); var textAge = Console.ReadLine(); customer.Age = int.TryParse(textAge, out var age) ? age : customer.Age; CtmManagement.Update(customer); Console.WriteLine("Customer was updated"); } else { throw new Exception("Customer not registered"); } }
private static void DeleteCustomer() { var customer = new Customer(); Console.WriteLine("Type the customer id:"); customer.Id = Console.ReadLine(); customer = CtmManagement.RetrieveById(customer); if (customer != null) { Console.WriteLine(" ==> " + customer.GetEntityInformation()); Console.WriteLine("Delete? Y/N"); var delete = Console.ReadLine(); if (delete.Equals("Y", StringComparison.CurrentCultureIgnoreCase)) { CtmManagement.Delete(customer); Console.WriteLine("Customer was deleted"); } } else { throw new Exception("Customer not registered"); } }
private static void SearchCustomer() { var customer = new Customer(); Console.WriteLine("Type the customer id:"); customer.Id = Console.ReadLine(); customer = CtmManagement.RetrieveById(customer); if (customer != null) { Console.WriteLine(" ==> " + customer.GetEntityInformation()); } }