static void Main(string[] args) { //InMemoryCarManagerTest(); //CarDelete(); //BrandAdd(); //GetAllBrand(); //CollorsAdd(); //CarsAdd(); //GetCarDetail(); //UsersAdd(); CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); List <Customer> customers = new List <Customer> { new Customer { Id = 1, UserId = 1, CompanyName = "Zeynel'in şirketi" }, new Customer { Id = 2, UserId = 2, CompanyName = "Zeyn'in şirketi" }, new Customer { Id = 3, UserId = 3, CompanyName = "Zey'in şirketi" }, new Customer { Id = 4, UserId = 3, CompanyName = "Zey'in 2. şirketi" }, }; foreach (var item in customers) { customerManager.AddCustomer(item); Console.WriteLine("işlem tamam"); } }
private static void AddCustomerTest() { CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); IResult result = customerManager.AddCustomer(new Customer { UserId = 1, CompanyName = "Radin" }); Console.WriteLine(result.Message); }
private static void AddCustomer1() { CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); Customer cr2 = new Customer { UserId = 1, CompanyName = "MHMT" }; Console.WriteLine(customerManager.AddCustomer(cr2).Message); }
private static void CustomerMenu(ConsoleKeyInfo key) { CustomerManager customerManager = new CustomerManager(new IMCustomerDAL(), new RealPersonCheckManager()); ListCustomers(customerManager); Console.WriteLine("A - Add Customer"); Console.WriteLine("U - Update Customer"); Console.WriteLine("D - Delete Customer"); Console.WriteLine("M - Main Menu"); key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.A: { Console.WriteLine(); Customer customer = new Customer(); customer.Id = customerManager.GetAllCustomers().Max(x => x.Id) + 1; Console.Write("Customer FirstName : "); customer.FirstName = Console.ReadLine(); Console.Write("Customer LastName : "); customer.LastName = Console.ReadLine(); Console.Write("Customer NationalityId : "); customer.NationalityId = Console.ReadLine(); Console.Write("Customer DateOfBirth : "); customer.DateOfBirth = Convert.ToDateTime(Console.ReadLine()); Console.Write("Customer Favourite Genre : "); customer.FavouriteGenre = Console.ReadLine(); try { customerManager.AddCustomer(customer); } catch (Exception exception) { Console.WriteLine(exception.Message); } ListCustomers(customerManager); } break; case ConsoleKey.U: { Console.WriteLine(); Customer customer = new Customer(); Console.Write("Customer Id : "); if (int.TryParse(Console.ReadLine(), out int id)) { customer.Id = id; } if (customerManager.GetAllCustomers().SingleOrDefault(x => x.Id == customer.Id) != null) { Console.Write("Favourite Genre : "); customer.FavouriteGenre = Console.ReadLine(); customerManager.UpdateCustomer(customer); ListCustomers(customerManager); } else { Console.WriteLine("No such customer exists!!"); } } break; case ConsoleKey.D: { Console.WriteLine(); Console.Write("Customer Id : "); if (int.TryParse(Console.ReadLine(), out int id)) { var campaign = customerManager.GetCustomer(id); if (campaign != null) { customerManager.DeleteCustomer(campaign); ListCustomers(customerManager); } } else { Console.WriteLine("No such customer exists!!"); } } break; case ConsoleKey.M: { Console.WriteLine(""); MainMenu(); } break; default: break; } }