Beispiel #1
0
 private static void ListCustomers(CustomerManager customerManager)
 {
     foreach (var customer in customerManager.GetAllCustomers())
     {
         Console.WriteLine("{0} - {1} - {2} - {3}", customer.Id, customer.FirstName, customer.LastName, customer.FavouriteGenre);
     }
 }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            CarManager      carManager      = new CarManager(new EfCarDal());
            BrandManager    brandManager    = new BrandManager(new EfBrandDal());
            ColorManager    colorManager    = new ColorManager(new EfColorDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            UserManager     userManager     = new UserManager(new EfUserDal());
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());

            customerManager.Add(new Customer {
                Id = 1, CompanyName = "Tesla"
            });
            customerManager.Add(new Customer {
                Id = 1, CompanyName = "Amazon"
            });
            customerManager.Add(new Customer {
                Id = 1, CompanyName = "Trendyol"
            });


            //userManager.Add(new User { Email = "*****@*****.**", FirstName = "Rümeysa", LastName = "Yük", Password = 123456, });
            //userManager.Add(new User { Email = "*****@*****.**", FirstName = "Ahmet", LastName = "Tas", Password = 7895 });
            //userManager.Add(new User { Email = "*****@*****.**", FirstName = "Nuriye", LastName = "Ulsak", Password = 896321 });
            //userManager.Add(new User { Email = "yalı[email protected]", FirstName = "Kemal", LastName = "atcı", Password = 7852 });

            var result = carManager.GetCarDetails();

            if (result.Success)
            {
                foreach (var cust in result.Data)
                {
                    Console.WriteLine("{0} -- {1} -- {2}", cust.BrandName, cust.ColorName, cust.DailyPrice);
                }
            }
            else
            {
                Console.WriteLine(result.Message);
            }
            var result2 = customerManager.GetAllCustomers();

            foreach (var re in result2.Data)
            {
                Console.WriteLine(re.CompanyName);
            }

            var result4 = rentalManager.CheckReturnDate(23 / 11 / 2021);

            foreach (var item in result4.Message)
            {
                Console.WriteLine("Araç kıralanabilir");
            }

            //var result5 = userManager.GetAllUsers();
            //foreach (var item in result5.Data)
            //{
            //    Console.WriteLine(item.Email+item.FirstName+item.LastName+item.Password);
            //}



            //Test(carManager, brandManager, colorManager);
            //Test2(brandManager, colorManager);
        }