private static CustomerManager AddNewCustomer()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            var             addedCustomer   = customerManager.Add(new Customer {
                CustomerId = 2, UserId = 2, CompanyName = "XCompany"
            });

            Console.WriteLine(addedCustomer.Message);
            var result = customerManager.GetAll();

            if (result.Success == true)
            {
                foreach (var customer in result.Data)
                {
                    Console.WriteLine(customer.CustomerId + " / " + customer.UserId + " / " + customer.CompanyName);
                }
            }
            return(customerManager);
        }
        public static void CustomerAdd()
        {
            Customer        _customer       = new Customer();
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            Console.WriteLine("-------------MÜŞTERİ EKLEME İŞLEMİ--------------");
            Console.Write("Şirket Adı = ");
            _customer.CompanyName = Console.ReadLine();
            var result = customerManager.Add(_customer);

            if (result.Success == true)
            {
                Console.WriteLine(result.Message);
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Exemple #3
0
        static void CustomerInsert(CustomerManager customerManager)
        {
            Customer insertedCustomer = new Customer();

            Console.WriteLine("Müşteri ekleme bilgilerini giriniz,");
            Console.Write("UserId : ");
            insertedCustomer.UserId = int.Parse(Console.ReadLine());
            Console.Write("CompanyName : ");
            insertedCustomer.CompanyName = Console.ReadLine();
            var result = customerManager.Add(insertedCustomer);

            if (result.Success)
            {
                Console.WriteLine(result.Message);
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Exemple #4
0
        private static void CustomerAdded()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            var             result          = customerManager.Add(
                new Customer {
                UserId      = 2,
                CompanyName = "Öğrenci"
            });

            if (result.Succes == true)
            {
                Console.WriteLine(result.Message);
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine(result.Message);
                Console.ReadLine();
            }
        }
Exemple #5
0
        //private static void UserTest()
        //{
        //    UserManager user = new UserManager(new EfUserDal());
        //    var result = user.Add(new User
        //    {
        //        UserId=6,
        //        FirstName = "Deniz",
        //        LastName = "Azaklı",
        //        Email = "*****@*****.**",
        //        Password = "******"
        //    });

        //    if (result.Success == true)
        //    {
        //        Console.WriteLine(result.Message);
        //    }
        //    else
        //    {
        //        Console.WriteLine(result.Message);
        //    }
        //}

        private static Core.Utilities.Results.IResult CustomerTest()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            var             result          = customerManager.Add(new Customer
            {
                CustomerId  = 6,
                CompanyName = "Trainer"
            });

            if (result.Success == true)
            {
                Console.WriteLine(result.Message);
            }
            else
            {
                Console.WriteLine(result.Message);
            }

            return(result);
        }
Exemple #6
0
        private static void CustomerTest()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            //********Added * *******
            var addedCustomer = customerManager.Add(new Customer {
                UserId = 3, CompanyName = "Serkan A.Ş"
            });

            if (addedCustomer.Success == true)
            {
                foreach (var customer in customerManager.GetAll().Data)
                {
                    Console.WriteLine($"Müşteri İsmi :{customer.CompanyName}");
                }
            }
            else
            {
                Console.WriteLine(addedCustomer.Message);
            }
        }
Exemple #7
0
        static void Main(string[] args)
        {
            //CarTest();
            //BrandTest();
            //ColorTest();

            //GetCarDetailsTest();

            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            string[] customers = { "Ateş Holding", "Su Holding", "Hava Holding" };
            for (int i = 1; i < 4; i++)
            {
                Customer customer = new Customer {
                    Id = i, CompanyName = customers[i - 1], UserId = i
                };

                var result = customerManager.Add(customer);
            }
        }
Exemple #8
0
        static void Main(string[] args)
        {
            //GetCarByBrandId();


            //   GetCarDetails();

            // CarManager carManager = new CarManager(new EfCarDal());

            //carManager.Add{ };

            //   ColorAdd();
            // ColorGetById();
            //colorManager.Delete(new Color { ColorId = 11, ColorName = "Yeşil" });

            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            var result = customerManager.Add(new Customer {
                Id = 1, UserId = 2, CompanyName = "ABC A.Ş."
            });
        }
Exemple #9
0
        private static void CustomerAddTest()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            UserTest();

            Console.Write("User Id giriniz:");
            int customerUI = int.Parse(Console.ReadLine());

            Console.Write("Company Name giriniz:");
            string customerCN = Console.ReadLine();
            var    result     = customerManager.Add(
                new Customer {
                UserId = customerUI, CompanyName = customerCN
            });

            if (result.Success)
            {
                Console.WriteLine(result.Message);
            }
        }
        //private static void AddUsers()
        //{
        //    UserManager userManager = new UserManager(new EfUserDal());
        //    List<User> users = new List<User>
        //    {
        //        new User { FirstName = "Ali", LastName = "Aydın", Email = "*****@*****.**", Password = "******" },
        //        new User { FirstName = "Hüseyin", LastName = "Yılmaz", Email = "*****@*****.**", Password = "******" },
        //        new User { FirstName = "Mehmet", LastName = "Güner", Email = "*****@*****.**", Password = "******" },
        //    };

        //    foreach (var item in users)
        //    {
        //        userManager.Add(item);
        //    }
        //}

        private static void AddCustomers()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            List <Customer> customers       = new List <Customer>
            {
                new Customer {
                    CompanyName = "AB Company", UserId = 1
                },
                new Customer {
                    CompanyName = "BC Company", UserId = 2
                },
                new Customer {
                    CompanyName = "CD Company", UserId = 3
                },
            };

            foreach (var item in customers)
            {
                customerManager.Add(item);
            }
        }
Exemple #11
0
        private static void CustomersOperations()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal(), new UserManager(new EfUserDal()));

            Customer customer1 = new Customer()
            {
                UserId      = 9,
                CompanyName = "Vesely airlines"
            };
            Customer customer2 = new Customer()
            {
                CustomerId = 5
            }; Customer customer3 = new Customer()

            {
                CustomerId  = 7,
                UserId      = 2,
                CompanyName = "De dust"
            };
            Console.WriteLine("--- Add ---");
            customerManager.Add(customer1);
            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.CustomerId + " " + customer.UserId + " " + customer.CompanyName);
            }
            Console.WriteLine("--- Delete ---");
            customerManager.Delete(customer2);
            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.CustomerId + " " + customer.UserId + " " + customer.CompanyName);
            }
            Console.WriteLine("--- Update ---");
            customerManager.Update(customer3);
            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.CustomerId + " " + customer.UserId + " " + customer.CompanyName);
            }
            Console.WriteLine("--- GetId ---");
            Console.WriteLine(customerManager.GetById(6).Data.CompanyName);
        }
Exemple #12
0
        private static void AddCustomer()
        {
            int    userIdToAdd        = 1;
            string companyNameToAdd   = "test co";
            string userFirstNameToAdd = "test";
            string userLastNameToAdd  = "testo";

            UserManager     userManager     = new UserManager(new EfUserDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            User userToAdd = new User
            {
                Id        = userIdToAdd,
                FirstName = userFirstNameToAdd,
                LastName  = userLastNameToAdd,
            };

            userManager.Add(userToAdd);

            Customer customerToAdd = new Customer
            {
                Id          = userIdToAdd,
                UsersId     = userIdToAdd,
                CompanyName = companyNameToAdd,
            };


            customerManager.Add(customerToAdd);

            Console.WriteLine("GetAll Methodu Testi:");
            foreach (var user in userManager.GetAll().Data)
            {
                Console.WriteLine(user.Id);
            }

            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.Id);
            }
        }
Exemple #13
0
        private static void UserTest()
        {
            User user1 = new User {
                Id = 2, FirstName = "Zehra", LastName = "Özdemir", Email = "*****@*****.**", Password = "******"
            };
            IUserService userService = new UserManager(new EfUserDal());

            userService.Add(user1);

            ICustomerService customerService = new CustomerManager(new EfCustomerDal());
            Customer         customer1       = new Customer {
                UserId = 2, CompanyName = "Huawei"
            };

            customerService.Add(customer1);
            var result2 = customerService.GetAll();

            foreach (var customer in result2.Data)
            {
                Console.WriteLine(customer.UserId + customer.CompanyName);
            }
        }
Exemple #14
0
        private static void CustomerTest()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            customerManager.Add(new Customer {
                UserId = 2, CompanyName = "Yavuz Holding"
            });

            var result = customerManager.GetAll();

            if (result.Success)
            {
                foreach (var customer in result.Data)
                {
                    Console.WriteLine(customer.CompanyName);
                }
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Exemple #15
0
        private static void CustomerAdd(CustomerManager customerManager)
        {
            List <Customer> customers = new List <Customer>
            {
                new Customer {
                    UserId = 2, CompanyName = "Turkcell"
                },
                new Customer {
                    UserId = 5, CompanyName = "Tesla"
                },
                new Customer {
                    UserId = 1, CompanyName = "Apple"
                },
                new Customer {
                    UserId = 4, CompanyName = "Google"
                }
            };

            foreach (Customer customer in customers)
            {
                customerManager.Add(customer);
            }
        }
Exemple #16
0
        static void Main(string[] args)
        {
            UserManager     userManager     = new UserManager(new EfUserDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());
            CarManager      carManager      = new CarManager(new EfCarDal());

            Console.WriteLine("Araba Kiralama Servisimize Hosgeldiniz\nLütfenAşağıdaki Seçenlerden Birini Seçiniz.\nKullanıcı Ekleme-1\nMusteri Ekleme-2\nKiralama -3");
            int okunanDeger = Convert.ToInt32(Console.ReadLine());

            switch (okunanDeger)
            {
            case 1:
                //userManager.Add(AddUser(userManager));
                break;

            case 2:
                customerManager.Add(AddCustomer(customerManager));
                break;

            case 3:
                rentalManager.Add(AddRental(rentalManager, carManager, customerManager));
                break;

            case 4:
                break;

            case 5:
                ArabalarıListele(carManager);
                break;

            default:
                break;
            }

            Console.ReadKey();
        }
Exemple #17
0
        private static void CustomerAdd(CustomerManager customerManager)
        {
            Console.Write("Kullanıcı ID : ");
            string _nullUserId = Console.ReadLine();

            if (_nullUserId == null)
            {
                Console.WriteLine("Lütfen Kullanıcı ID DEğeri Giriniz!");
            }
            else
            {
                int _userIdForAdd = Convert.ToInt32(_nullUserId);
                Console.Write("Şirket Adı : ");
                string _companyNameForAdd = Console.ReadLine();

                Customer customer = new Customer
                {
                    UserId      = _userIdForAdd,
                    CompanyName = _companyNameForAdd
                };
                var result = customerManager.Add(customer);
                Console.WriteLine(result.Message);
            }
        }
Exemple #18
0
        private static void CustomerManagerAll()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            var             result          = customerManager.Add(new Customer
            {
                UserId      = 13,
                CompanyName = "Arçelik"
            });

            Console.WriteLine(result.Message);
            var result1 = customerManager.Delete(new Customer {
                CustomerId = 14
            });

            Console.WriteLine(result1.Message);
            var result2 = customerManager.Update(new Customer {
                CustomerId = 15, CompanyName = "Beko", UserId = 17
            });

            Console.WriteLine(result2.Message);
            var result3 = customerManager.GetAll();

            if (result3.Success == true)
            {
                foreach (var item in result3.Data)
                {
                    Console.WriteLine("{0}\n{1}\n{2}\n", item.UserId, item.CustomerId, item.CompanyName);
                }
            }
            var result4 = customerManager.GetById(2);

            if (result4.Success == true)
            {
                Console.WriteLine(result4.Message);
            }
        }
Exemple #19
0
        private static void CustomerTest(CustomerManager customerManager)
        {
            List <Customer> customers = new List <Customer>
            {
                new Customer {
                    UserId = 1, CompanyName = "ABC Yayın Evi"
                },
                new Customer {
                    UserId = 2, CompanyName = "DEF Telekomünikasyon"
                },
                new Customer {
                    UserId = 3, CompanyName = "XYZ Lojistik"
                },
            };

            foreach (var customer in customers)
            {
                customerManager.Add(customer);
            }
            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.UserId + " " + customer.CompanyName);
            }
        }
Exemple #20
0
        static void Main(string[] args)
        {
            //AracEkle();

            UserManager userManager = new UserManager(new EfUserDal());
            var         userList    = userManager.GetAll();

            if (!userList.Data.Any())
            {
                User user = new User
                {
                    Email     = "*****@*****.**",
                    FirstName = "Ahmet",
                    LastName  = "Yıldız",
                    Status    = true,
                };
                userManager.Add(user);
                userList = userManager.GetAll();
            }

            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            var             customerList    = customerManager.GetAll();

            if (!customerList.Data.Any())
            {
                Customer customer = new Customer
                {
                    UserId      = userList.Data.Single().Id,
                    CompanyName = "XYZ A.Ş"
                };
                customerManager.Add(customer);
                customerList = customerManager.GetAll();
            }

            var carManager = new CarManager(new EfCarDal());
            var carList    = carManager.GetAll();

            if (!carList.Data.Any())
            {
                AracEkle();
                carList = carManager.GetAll();
            }


            RentalManager rentalManager = new RentalManager(new EfRentalDal());
            Rental        rental1       = new Rental
            {
                CarId      = carList.Data.First().Id,
                CustomerId = customerList.Data.First().Id,
                RentDate   = DateTime.Now,
            };

            Console.WriteLine(rentalManager.Add(rental1).Message);

            Rental rental2 = new Rental
            {
                CarId      = carList.Data.First().Id,
                CustomerId = customerList.Data.First().Id,
                RentDate   = new DateTime(2021, 4, 10)
            };

            Console.WriteLine(rentalManager.Add(rental2).Message);
        }
        private static void RentalTest()
        {
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            UserManager     userManager     = new UserManager(new EfUserDal());
            CarManager      carManager      = new CarManager(new EfCarDal());

            Rental newRental1 = new Rental
            {
                Id         = 1,
                CarId      = 2,
                CustomerId = 1,
                RentDate   = new DateTime(2021, 3, 2),
                ReturnDate = new DateTime(2021, 3, 8)
            };

            Customer newCustomer1 = new Customer
            {
                Id     = 1,
                UserId = 1,
            };

            Rental newRental2 = new Rental
            {
                Id         = 2,
                CarId      = 3,
                CustomerId = 2,
                RentDate   = new DateTime(2021, 3, 4),
                ReturnDate = new DateTime(2021, 3, 11)
            };

            Customer newCustomer2 = new Customer
            {
                Id     = 2,
                UserId = 2,
            };

            customerManager.Add(newCustomer2);
            rentalManager.Add(newRental2);

            var result = rentalManager.GetRentalDetails();

            if (result.Success == true)
            {
                Console.WriteLine("\n#################### Güncel Kiralama Listesi ####################\n");

                foreach (var rental in result.Data)
                {
                    Console.WriteLine("Araç numarası: " + rental.CarId + "\n" +
                                      "Araç Marka ve Modeli: " + rental.CarName + "\n" +
                                      "Araç Model Yılı: " + rental.ModelYear + "\n" +
                                      "Aracın günlük ücreti: " + rental.DailyPrice + "\n" +
                                      "Kiralayan kişinin adı: " + rental.FirstName + "\n" +
                                      "Kiralayan kişinin soyadı: " + rental.LastName + "\n" +
                                      "Kiralanma tarihi: " + rental.RentDate + "\n" +
                                      "Geri teslim tarihi: " + rental.ReturnDate + "\n" +
                                      "--------------------------------------------------------\n");
                }
            }

            else
            {
                Console.WriteLine(result.Message + "\n");
            }
        }
Exemple #22
0
        static void Main(string[] args)
        {
            #region Tests
            //ColorTest();
            //BrandTest();
            //CarTest();
            //newCarAdd(carManager);
            //MyFirstWork();
            //CustomerTest();
            // RentalTest();
            #endregion

            //--------------------------CONSOLE SIMULATION-----------------------
            CarManager      carManager      = new CarManager(new EfCarDal());
            BrandManager    brandManager    = new BrandManager(new EfBrandDal());
            ColorManager    colorManager    = new ColorManager(new EfColorDal());
            UserManager     userManager     = new UserManager(new EfUserDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());

Again:
            Console.WriteLine("--------------ReCapProject MENU--------------");
            Console.WriteLine("1. Car List");
            Console.WriteLine("2. Brand List");
            Console.WriteLine("3. Color List");
            Console.WriteLine("4. Add a rent Car");
            Console.WriteLine("5. Add  Brand");
            Console.WriteLine("6. Add Color");
            Console.WriteLine("7. Delete Car");
            Console.WriteLine("8. Update Car");
            Console.WriteLine("9. Vehicle List in Price Range");
            Console.WriteLine("10. Update Brand");
            Console.WriteLine("11. Update Color ");
            Console.WriteLine("12. Add User");
            Console.WriteLine("13. Delete User");
            Console.WriteLine("14. Update User");
            Console.WriteLine("15. User List");
            Console.WriteLine("16. Add Customer");
            Console.WriteLine("17. Delete Customer");
            Console.WriteLine("18. Update Customer");
            Console.WriteLine("19. A rent a car");
            Console.WriteLine("20. Update Rented Vehicle Information");
            Console.WriteLine("21. Rented Car List");
            Console.WriteLine("22. Customer List");
            Console.WriteLine("23. System Exit");
            string mainMenu;
            int    choice = 0;
            try
            {
                choice = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception)
            {
                Console.WriteLine("wrong character !");
            }
            switch (choice)
            {
            case 1:
            {
                var result = carManager.GetCarDetails();
                if (result.Success)
                {
                    Console.WriteLine("----------------Car List-------------");
                    foreach (var carDto in carManager.GetCarDetails().Data)
                    {
                        Console.WriteLine(carDto.BrandName + " | " + carDto.ColorName + " | " + carDto.DailyPrice + " | " + carDto.Description);
                        Console.WriteLine("---------------------------------------------");
                    }
                }

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 2:
            {
                var result = brandManager.GetAll();
                if (result.Success)
                {
                    Console.WriteLine("----------------Brand List-------------");
                    foreach (var brand in brandManager.GetAll().Data)
                    {
                        Console.WriteLine("Id: " + brand.BrandId + " | " + brand.BrandName);
                        Console.WriteLine("---------------------------------------------");
                    }
                }

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 3:
            {
                Console.WriteLine("------------------Color List----------------");
                var result = colorManager.GetAll();
                if (result.Success)
                {
                    foreach (var color in colorManager.GetAll().Data)
                    {
                        Console.WriteLine("Id: " + color.ColorId + " | " + color.ColorName);
                        Console.WriteLine("---------------------------------------------");
                    }
                }



                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 4:
            {
                string modelYear, description;
                int    brand = 0, color = 0, dailyPrice = 0;
                Console.WriteLine("Enter the information of the vehicle you want to add");
                Console.WriteLine("Enter the brand's BrandId value.");
                brand = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the ColorId value of the color");
                color = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter your modelYear");
                modelYear = Console.ReadLine();
                Console.WriteLine("Enter the rental fee");
                dailyPrice = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter description");
                description = Console.ReadLine();
                Car car1 = new Car {
                    BrandId = brand, ColorId = color, ModelYear = modelYear, DailyPrice = dailyPrice, Descriptions = description
                };
                carManager.Add(car1);
                Console.WriteLine("The vehicle has been successfully added by the system.");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }


                break;
            }

            case 5:
            {
                string brand;
                Console.WriteLine("Write the brand you want to add");
                brand = Console.ReadLine();
                Brand brand1 = new Brand {
                    BrandName = brand
                };
                brandManager.Add(brand1);
                Console.WriteLine("Brand addition process has been done successfully");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 6:
            {
                string color;
                Console.WriteLine("Write the color you want to add");
                color = Console.ReadLine();
                Color color1 = new Color {
                    ColorName = color
                };
                colorManager.Add(color1);
                Console.WriteLine("Added color has been done successfully");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 7:
            {
                int id = 0;
                Console.WriteLine("Enter the Id value of the vehicle you want to delete");
                id = Convert.ToInt32(Console.ReadLine());
                Car car2 = new Car {
                    CarId = id
                };
                carManager.Delete(car2);
                Console.WriteLine("Deletion completed successfully.");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }


                break;
            }

            case 8:
            {
                string modelYear, description;
                int    brand = 0, color = 0, dailyPrice = 0, id = 0;
                Console.WriteLine("Enter the information of the vehicle you want to update");
                Console.WriteLine("Enter the Id value of the vehicle you want to update");
                id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the brand's BrandId value.");
                brand = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the ColorId value of the color");
                color = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter your modelYear");
                modelYear = Console.ReadLine();
                Console.WriteLine("Enter the rental fee");
                dailyPrice = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter description");
                description = Console.ReadLine();
                Car car1 = new Car {
                    CarId = id, BrandId = brand, ColorId = color, ModelYear = modelYear, DailyPrice = dailyPrice, Descriptions = description
                };
                Console.WriteLine("Update process completed successfully");
                carManager.Update(car1);

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 9:
            {
                int minMoney = 0, maxMoney = 0;
                Console.WriteLine("Enter the value range you want to rent");
                Console.WriteLine("Enter the minimum fee");
                minMoney = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the maximum fee");
                maxMoney = Convert.ToInt32(Console.ReadLine());
                var result = carManager.GetByDailyPrice(minMoney, maxMoney);
                if (result.Success)
                {
                    foreach (var i in carManager.GetByDailyPrice(minMoney, maxMoney).Data)
                    {
                        Console.WriteLine("Id: " + i.CarId + " | " + brandManager.GetById(i.BrandId).Data.BrandName + " | " + colorManager.GetById(i.ColorId).Data.ColorName + " | " + i.ModelYear + " | " + i.DailyPrice + " | " + i.Description);
                    }
                }

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 10:
            {
                string brand;
                int    id = 0;
                Console.WriteLine("Id");
                id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Write the new brand");
                brand = Console.ReadLine();
                Brand brand1 = new Brand {
                    BrandId = id, BrandName = brand
                };
                brandManager.Update(brand1);
                Console.WriteLine("Brand update has been done successfully");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }

                break;
            }

            case 11:
            {
                string color;
                int    id = 0;
                Console.WriteLine("Enter the Id value of the color you want to update.");
                id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Write the new color");
                color = Console.ReadLine();
                Color color1 = new Color {
                    ColorId = id, ColorName = color
                };
                colorManager.Update(color1);
                Console.WriteLine("Color update has been done successfully");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 12:
            {
                string name, surname, email, password;
                Console.WriteLine("Enter your user's name");
                name = Console.ReadLine();
                Console.WriteLine("Enter user's surname.");
                surname = Console.ReadLine();
                Console.WriteLine("enter eMail");
                email = Console.ReadLine();
                Console.WriteLine("enter password");
                password = Console.ReadLine();
                //User user = new User { FirstName = name, LastName = surname, Email = email, Password = password };
                //userManager.Add(user);
                Console.WriteLine("The user has been successfully added");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }

                break;
            }

            case 13:
            {
                int id = 0;
                Console.WriteLine("Enter the ID of the user you want to delete ");
                id = Convert.ToInt32(Console.ReadLine());
                User user = new User {
                    Id = id
                };
                userManager.Delete(user);
                Console.WriteLine("The user was deleted successfully ");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 14:
            {
                int    id = 0;
                string name, surname, email, password;
                Console.WriteLine("Enter the ID of the user you want to update.");
                id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter name");
                name = Console.ReadLine();
                Console.WriteLine("enter surname");
                surname = Console.ReadLine();
                Console.WriteLine("Enter email.");
                email = Console.ReadLine();
                Console.WriteLine("enter password");
                password = Console.ReadLine();
                //User user = new User { FirstName = name, LastName = surname, Email = email, Password = password };
                //userManager.Update(user);
                Console.WriteLine("User information has been successfully updated");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 15:
            {
                foreach (var user in userManager.GetAll().Data)
                {
                    Console.WriteLine("Id: " + user.Id + " | " + user.FirstName + " | " + user.LastName +
                                      " | " + user.Email + " | ");        // + user.Password);
                    Console.WriteLine("---------------------------------------------");
                }
                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 16:
            {
                int    userId;
                string companyName;
                Console.WriteLine("Enter the user ID of the customer you want to add ");
                userId = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter name of company");
                companyName = Console.ReadLine();
                Customer customer = new Customer {
                    UserId = userId, CompanyName = companyName
                };
                customerManager.Add(customer);
                Console.WriteLine("The customer has been successfully added ");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 17:
            {
                int id = 0;
                Console.WriteLine("Enter the ID of the customer you want to delete.");
                id = Convert.ToInt32(Console.ReadLine());
                Customer customer = new Customer {
                    Id = id
                };
                customerManager.Delete(customer);
                Console.WriteLine("The customer was deleted successfully.");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 18:
            {
                int    userId, id;
                string companyName;
                Console.WriteLine("Enter the ID of the customer you want to update");
                id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the user ID of the customer you want to update.");
                userId = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter name of company");
                companyName = Console.ReadLine();
                Customer customer = new Customer {
                    Id = id, UserId = userId, CompanyName = companyName
                };
                customerManager.Update(customer);
                Console.WriteLine("Customer information has been updated successfully.");

                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 19:
            {
                DateTime rentDate, returnDate;
                int      carId = 0, customerId = 0;
                Console.WriteLine("Enter the Id value of the vehicle you want to rent.");
                carId = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the id value of the customer you want to rent");
                customerId = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the start date");
                rentDate = DateTime.Parse(Console.ReadLine());
                Console.WriteLine("Enter the end date");
                returnDate = DateTime.Parse(Console.ReadLine());
                Rental rental = new Rental {
                    CarId = carId, CustomerId = customerId, RentDate = rentDate, ReturnDate = returnDate
                };
                var result = rentalManager.Add(rental);
                if (result.Success)
                {
                    rentalManager.Add(rental);
                }
                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 20:
            {
                DateTime rentDate, returnDate;
                int      carId = 0, customerId = 0;
                Console.WriteLine("Enter the Id value of the vehicle you want to update.");
                carId = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the ID of the customer you want to update");
                customerId = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter start date");
                rentDate = DateTime.Parse(Console.ReadLine());
                Console.WriteLine("enter end date");
                returnDate = DateTime.Parse(Console.ReadLine());
                Rental rental = new Rental {
                    CarId = carId, CustomerId = customerId, RentDate = rentDate, ReturnDate = returnDate
                };
                var result = rentalManager.Update(rental);
                if (result.Success)
                {
                    rentalManager.Update(rental);
                }
                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 21:
            {
                Console.WriteLine("----------------Rented Car List-------------");
                foreach (var rentalDto in rentalManager.GetAll().Data)
                {
                    Console.WriteLine("Id: " + rentalDto.RentalId + " | Customer Id :" + rentalDto.CustomerId + " | " + rentalDto.CarId + " | " + rentalDto.RentDate + " | " + rentalDto.ReturnDate);
                    Console.WriteLine("---------------------------------------------");
                }
                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 22:
            {
                Console.WriteLine("----------------Customer List-------------");

                foreach (var customerDto in customerManager.GetCarDetails().Data)
                {
                    Console.WriteLine("Id: " + customerDto.Id + " | User name :" + customerDto.UserName);
                    Console.WriteLine("---------------------------------------------");
                }
                Console.WriteLine("Would you like to return to the main menu? Yes==y||No==n");
                mainMenu = Console.ReadLine();
                if (mainMenu == "y")
                {
                    goto Again;
                }
                break;
            }

            case 23:
            {
                Console.WriteLine("Press to any key");
                Console.WriteLine("End...");
                Environment.Exit(0);
                break;
            }

            default:
            {
                Console.WriteLine("Wrong choose please try again later !");
                goto Again;
            }
            }
        }
        static void Main(string[] args)
        {
            UserManager userManager = new UserManager(new EfUserDal());
            User        user        = new User {
                FirstName = "Namık", LastName = "Yılmaz", Email = "*****@*****.**"
            };

            userManager.Add(user);
            var result = userManager.Add(user);

            foreach (var results in result.Message)
            {
                Console.WriteLine(result.Message);
            }


            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            customerManager.Add(new Customer {
                UserId = (userManager.GetByUser(user).Data.UserId), CompanyName = " Güçü var  Şirket"
            });
            var result1 = customerManager.GetAll();

            foreach (var results in result1.Message)
            {
                Console.WriteLine(result1.Message);
            }


            /*
             * RentalManager rentalManager = new RentalManager(new EfRentalDal(), new EfCarDal( ), new EfCustomerDal());
             * var result2 = rentalManager.GetRentalDetails();
             * foreach (var results in result2.Message)
             * {
             *  Console.WriteLine(result2.Message);
             * }
             *
             * rentalManager.Add(new Rental { CarId = 3010, RentDate = new DateTime(2021, 02, 16) });
             *
             * foreach (var results in result2.Data)
             * {
             *  Console.WriteLine("{0}|{1}|{2}|{3}|{4}|{5}",
             *      results.CarId, results.CarName, results.FirstName, results.LastName, results.CompanyName, results.RentDate, results.ReturnDate);
             * }
             *
             */



            //CarManager carManager = new CarManager(new EfCarDal());

            //var result = carManager.GetCarDetails();

            //Console.WriteLine(result.Message);
            //Console.WriteLine();

            //if (result.Success==true)
            //{
            //    foreach (var car in carManager.GetCarDetails().Data)
            //    {
            //        Console.WriteLine("Araç Id No" + " - " + "Araç İsim" + " - " + "Marka Id No" + " - " + "Marka" + " - " + "Model" + " - " + "Renk Id No" + " - " + "Renk" + " - " + "Özellikler" + " - " + "Günlük Fiyat");

            //        Console.WriteLine();
            //        Console.WriteLine(car.Id + " - " + car.Name + " - " + car.BrandId + " - " + car.BrandName + " - " + car.BrandModel + " - " + car.ColorId + " - " + car.ColorName + " - " + car.Description + " - " + car.DailyPrice);
            //    }
            //}
            //else
            //{
            //    Console.WriteLine(result.Message);
            //}



            //CarManager carManager = new CarManager(new EfCarDal());

            //Console.WriteLine("--------Tümünü Listele-----------");
            //foreach (var car in carManager.GetAll())
            //{
            //    Console.WriteLine(car.ModelYear + " " + " Model" + " " + car.Description + " " + "Fiyatı: " + car.DailyPrice + " TL");
            //}
            //Console.WriteLine();

            //Console.WriteLine("--------Marka ID ile çağırma-----------");
            //foreach (var car in carManager.GetCarsByBrandId(2006))
            //{
            //    Console.WriteLine(car.ModelYear + " " + " Model" + " " + car.Description + " " + "Fiyatı: " + car.DailyPrice + " TL");
            //}
            //Console.WriteLine();


            //Console.WriteLine("--------Renk ID ile çağırma-----------");
            //foreach (var car in carManager.GetCarsByColorId(1007))
            //{
            //    Console.WriteLine(car.ModelYear + " " + " Model" + " " + car.Description + " " + "Fiyatı: " + car.DailyPrice + " TL");
            //}
            //Console.WriteLine();



            //CarManager carManager = new CarManager(new EfCarDal());

            //carManager.Add(new Car { Name = "Mercedes-Benz", ModelYear = "2020", BrandId = 1, ColorId = 1, DailyPrice = 380.94M, Description = "63S V8 Turbo 635 PS 4 Matic+" });
            //carManager.Add(new Car { Name = "Mercedes-Benz", ModelYear = "2013", BrandId = 2, ColorId = 2, DailyPrice = 229.50M, Description = "Dizel / Manuel / Hatchback 5 kapı" });
            //carManager.Add(new Car { Name = "Mercedes-Benz", ModelYear = "2013", BrandId = 3, ColorId = 3, DailyPrice = 268.90M, Description = "Yarı Otomatik / Benzin" });
            //carManager.Add(new Car { Name = "BMW", ModelYear = "2020", BrandId = 4, ColorId = 4, DailyPrice = 500.94M, Description = "Benzin / Otomatik / Sedan" });
            //carManager.Add(new Car { Name = "Chevrolet", ModelYear = "2013", BrandId = 5, ColorId = 5, DailyPrice = 109.94M, Description = "Manuel / Benzin" });
            //carManager.Add(new Car { Name = "Citroen", ModelYear = "2017", BrandId = 6, ColorId = 6, DailyPrice = 139.94M, Description = "Dizel / Manuel" });
            //carManager.Add(new Car { Name = "Fiat", ModelYear = "2017", BrandId = 7, ColorId = 7, DailyPrice = 107.50M, Description = "Dizel / Manuel / Sedan" });

            //BrandManager brandManager = new BrandManager(new EfBrandDal());
            //brandManager.Add(new Brand { BrandName = "AMG GT", BrandModel = "3.0 S" });
            //brandManager.Add(new Brand { BrandName = "A Serisi", BrandModel = "A 180 CDI BlueEfficiency Style" });
            //brandManager.Add(new Brand { BrandName = "B Serisi", BrandModel = "B 180 BlueEfficiency Elite" });
            //brandManager.Add(new Brand { BrandName = "5 Serisi", BrandModel = "520i Special Edition M Sport" });
            //brandManager.Add(new Brand { BrandName = "Cruze Serisi", BrandModel = "1.6 LT" });
            //brandManager.Add(new Brand { BrandName = "C3 Serisi", BrandModel = "1.6 BlueHDi Live " });
            //brandManager.Add(new Brand { BrandName = "Egea Serisi", BrandModel = " 1.3 Multijet Easy " });

            //ColorManager colorManager = new ColorManager(new EfColorDal());
            //colorManager.Add(new Color { ColorName = "Beyaz" });
            //colorManager.Add(new Color { ColorName = "Mavi" });
            //colorManager.Add(new Color { ColorName = "Beyaz" });
            //colorManager.Add(new Color { ColorName = "Siyah" });
            //colorManager.Add(new Color { ColorName = "Kırmızı" });
            //colorManager.Add(new Color { ColorName = "Beyaz" });
            //colorManager.Add(new Color { ColorName = "Füme" });

            //BrandManager brandManager = new BrandManager(new EfBrandDal());
            //ColorManager colorManager = new ColorManager(new EfColorDal());
            //CarManager carManager = new CarManager(new EfCarDal());
            //Car car = carManager.GetCarById(3002);
            //car.BrandId = brandManager.GetAll().SingleOrDefault(b => b.BrandName == "AMG GT" && b.BrandModel == "3.0 S").BrandId;
            //car.ColorId = colorManager.GetAll().SingleOrDefault(c => c.ColorName == "Beyaz" && c.ColorId == 1002).ColorId;
            //carManager.Update(car);



            //BrandManager brandManager = new BrandManager(new EfBrandDal());
            //brandManager.Add(new Brand { BrandName = " Focus ", BrandModel = " 1.5 TDCi Trend X " });

            //ColorManager colorManager = new ColorManager(new EfColorDal());
            //colorManager.Add(new Color { ColorName = "Mavi" });

            //CarManager carManager = new CarManager(new EfCarDal());
            //carManager.Add(new Car { Name = "Ford", ModelYear = "2016", BrandId = 8, ColorId = 8, DailyPrice = 156.94M, Description = "Yarı Otomatik / Manuel / Benzin" });



            //BrandManager brandManager = new BrandManager(new EfBrandDal());
            //brandManager.Add(new Brand { BrandName = " Focus ", BrandModel = "  1.6 Titanium  " });

            //ColorManager colorManager = new ColorManager(new EfColorDal());
            //colorManager.Add(new Color { ColorName = "Lacivert" });

            //CarManager carManager = new CarManager(new EfCarDal());
            //carManager.Add(new Car { Name = "Ford", ModelYear = "2011", BrandId = 2010, ColorId = 1010, DailyPrice = 126.94M, Description = "Otomatik / Manuel / Benzin" });



            //Car car1 = carManager.GetCarById(2003);
            //Car car2 = carManager.GetCarById(2004);
            //car1.BrandId = brandManager.GetAll().SingleOrDefault(b => b.BrandName == "Renault" && b.BrandModel == "Clio 5").BrandId;
            //car2.BrandId = brandManager.GetAll().SingleOrDefault(b => b.BrandName == "Volvo" && b.BrandModel == "C 40").BrandId;
            //car1.ColorId = colorManager.GetAll().SingleOrDefault(c => c.ColorName == "Mavi").ColorId;
            //car2.ColorId = colorManager.GetAll().SingleOrDefault(c => c.ColorName == "Beyaz").ColorId;

            ////Car car = new Car
            ////{
            ////    BrandId = brandManager.GetAll().SingleOrDefault(b => b.BrandName == "Nissan" && b.BrandModel == "Juke").BrandId,
            ////    ColorId = colorManager.GetAll().SingleOrDefault(c => c.ColorName == "Siyah").ColorId
            ////};
            ////car1 = car;

            //carManager.Update(car1);
            //carManager.Update(car2);



            //CarManager carManager = new CarManager(new EfCarDal());

            //Console.WriteLine("------GÜNLÜK ARAÇ KİRA FİYATLARI------");
            //Console.WriteLine("---------------------------------------------");
            //Console.WriteLine("Marka Adı                      Marka Id             Renk Id                        Model Yılı                             Açıklama                                           Günlük ücret");
            //Console.WriteLine("--------                      -------               ----------                     --------                               ------------                                       --------------");
            //foreach (var car in carManager.GetAll())
            //{
            //    Console.WriteLine(car.Name + "   --   " + car.BrandId + "      --   " + car.ColorId + "   --    " + car.ModelYear + "          ---    " + car.Description + "                --       " + car.DailyPrice + " TL");
            //}



            //BrandManager brandManager = new BrandManager(new EfBrandDal());
            //Console.WriteLine("------ARAÇ MARKA ID VE MARKA ADI BİLGİSİ------");
            //Console.WriteLine("---------------------------------------------");
            //Console.WriteLine("Marka Id                               Marka Adı                          Marka Model");
            //Console.WriteLine("--------                               ---------                        ------------------");
            //foreach (var brand in brandManager.GetAll())
            //{
            //    Console.WriteLine(brand.BrandId + "             ---    " + brand.BrandName + "       ---  " + brand.BrandModel);
            //}


            //ColorManager colorManager = new ColorManager(new EfColorDal());
            //Console.WriteLine("------ARAÇ RENK ID VE MARKA ADI BİLGİSİ------");
            //Console.WriteLine("---------------------------------------------");
            //Console.WriteLine("Renk Id               Renk Adı");
            //Console.WriteLine("-------         --------");
            //foreach (var color in colorManager.GetAll())
            //{
            //    Console.WriteLine(color.ColorId + "       ---  " + color.ColorName);
            //}



            //CarManager carManager = new CarManager(new EfCarDal());
            //List<Car> cars = new List<Car>
            //{
            //    new Car {Name ="Mercedes", ModelYear ="2020", DailyPrice =250, BrandId = 2, ColorId = 6, Description ="Otomatik"},
            //    new Car {Name ="Volvo", ModelYear ="2018", DailyPrice =195, BrandId = 6, ColorId = 4, Description ="Manuel/Dizel"},
            //    new Car {Name ="Renault", ModelYear ="2017", DailyPrice =150, BrandId = 3, ColorId = 5, Description ="Manuel"}
            //};
            //foreach (var car in cars)
            //{
            //    carManager.Add(car);
            //}


            //BrandManager brandManager = new BrandManager(new EfBrandDal());
            //List<Brand> brands = new List<Brand>
            //{
            //    new Brand{ BrandName = "Mercedes", BrandModel ="AMG GT"},
            //    new Brand{ BrandName = "Volvo", BrandModel ="C 40"},
            //    new Brand{ BrandName = "Renault", BrandModel ="Clio 5"}
            //};
            //foreach (var brand in brands)
            //{
            //    brandManager.Add(brand);
            //}

            //ColorManager colorManager = new ColorManager(new EfColorDal());
            //List<Color> colors = new List<Color>
            //{
            //    new Color {ColorName ="Beyaz"},
            //    new Color {ColorName = "Mavi"},
            //    new Color {ColorName = "Siyah"}
            //};
            //foreach (var color in colors)
            //{
            //    colorManager.Add(color);
            //}



            //CarManager carManager = new CarManager(new EfCarDal());
            //foreach (var car in carManager.GetCarsByDailyPrice(185, 200))
            //{
            //    Console.WriteLine(car.Name +" / " + car.Description);
            //}

            //CarManager carManager = new CarManager(new EfCarDal());
            //carManager.Add(new Car {Name = "Ford", BrandId = 3, ColorId = 1, ModelYear ="2018", DailyPrice = 263, Description = "Dizel/Benzin, Otomatik"});


            //CarManager carManager = new CarManager(new EfCarDal());
            //carManager.Delete(new Car { Id = 1002, });

            //CarManager carManager = new CarManager(new EfCarDal());
            //carManager.Add(new Car { Name = "Nissan", BrandId = 7, ColorId = 6, ModelYear = "2016", DailyPrice = 270M, Description = "Dizel/Benzin, Otomatik, 1,250.00 Tl Depozito" });
            //BrandManager brandManager = new BrandManager(new EfBrandDal());
            //brandManager.Add(new Brand { BrandName = "Nissan", BrandModel = "Juke" });
            //ColorManager colorManager = new ColorManager(new EfColorDal());
            //colorManager.Add(new Color { ColorName = "Kırmızı" });



            //BrandManager brandManager = new BrandManager(new EfBrandDal());
            //brandManager.Add(new Brand {BrandName = "Passat"});
        }
Exemple #24
0
 private static void customerManagerTest(CustomerManager customerManager)
 {
     Console.WriteLine(customerManager.Add(new Customer {
         Id = 2, UserId = 2, CompanyName = "Ayancık Rentcar"
     }).Message);
 }
Exemple #25
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);
        }
Exemple #26
0
        //test
        static void Main(string[] args)
        {
            //CarTest();
            //BrandTest();


            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            var             addCustomerRes  = customerManager.Add(new Customer {
                UserId = 1, CompanyName = "Company 1"
            });

            System.Console.WriteLine(addCustomerRes.Message);


            UserManager userManager = new UserManager(new EfUserDal());
            var         addUserRes  = userManager.Delete(new User {
                FirstName = "Ayşe", LastName = "yar", Email = "*****@*****.**"
            });

            System.Console.WriteLine(addUserRes.Message);


            //CarManager carManager = new CarManager(new EfCarDal());

            //var result = carManager.GetCarDetails();
            //if (result.Success == true)
            //{

            //    foreach (var car in result.Data)
            //    {
            //        Console.WriteLine(car.CarId + "/" + " " + car.BrandName + " " + car.CarName + " Car color: " + car.ColorName);
            //    }
            //}
            //else
            //{
            //    Console.WriteLine(result.Message);
            //}



            //CarManager carManager = new CarManager(new EfCarDal());

            //var result = carManager.GetCarDetails();

            //if (result.Success == true)
            //{

            //    foreach (var car in result.Data)
            //    {
            //        Console.WriteLine(Car.CarName + "" + Car.BrandName);
            //    }
            //}
            //else
            //{
            //    Console.WriteLine(result.Message);
            //}



            //}

            //private static void BrandTest()
            //{
            //    BrandManager brandManager = new BrandManager(new EfBrandDal());
            //    foreach (var brand in brandManager.GetAll())
            //    {
            //        Console.WriteLine(brand.BrandName);
            //    }
            //}

            //private static void CarTest()
            //{
            //    CarManager carManager = new CarManager(new EfCarDal());
            //    foreach (var car in carManager.GetCarDetails())
            //    {
            //        Console.WriteLine(car.CarName + "/" + car.BrandName);
            //    }
            //}
        }
Exemple #27
0
        private static void CustomerTest()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            List <Customer> _customers = new List <Customer>
            {
                new Customer()
                {
                    UserId = 2, CompanyName = "Başarı İletişim"
                },
                new Customer()
                {
                    UserId = 3, CompanyName = "Samancı Gıda"
                },
                new Customer()
                {
                    UserId = 4, CompanyName = "Global Serviss"
                },
                new Customer()
                {
                    UserId = 5, CompanyName = "Turuncu Kuruyemiş"
                },
            };

            foreach (var customer in _customers)
            {
                var result = customerManager.Add(customer);
                if (result.Success == true)
                {
                    Console.WriteLine(Messages.CustomerAdded);
                }
                else
                {
                    Console.WriteLine(result.Message);
                }
            }

            // Global Servis yanlışlıkla Global Serviss yazılmış düzeltilecek.
            Customer customerToUpdate = new Customer();

            customerToUpdate.Id          = 3;
            customerToUpdate.UserId      = 4;
            customerToUpdate.CompanyName = "Global Servis";
            var result2 = customerManager.Update(customerToUpdate);

            if (result2.Success == true)
            {
                Console.WriteLine(Messages.CustomerUpdated);
            }
            else
            {
                Console.WriteLine(result2.Message);
            }

            // Turuncu Kuruyemiş silinecek
            Customer customerToDelete = new Customer();

            customerToDelete.Id = 4;


            var result3 = customerManager.Delete(customerToDelete);

            if (result3.Success == true)
            {
                Console.WriteLine(Messages.CustomerDeleted);
            }
            else
            {
                Console.WriteLine(result3.Message);
            }

            var result4 = customerManager.GetAll();

            if (result4.Success == true)
            {
                foreach (var customer in result4.Data)

                {
                    Console.WriteLine("{0}        {1}          {2}", customer.Id, customer.UserId, customer.CompanyName);
                }
                Console.WriteLine(Messages.CustomersListed);
            }
            else
            {
                Console.WriteLine(result4.Message);
            }
            // Id si 1 olan müşterinin bilgilerini getir
            var result5 = customerManager.Get(1);

            if (result5.Success == true)
            {
                Console.WriteLine("{0}        {1}          {2}", result5.Data.Id, result5.Data.UserId, result5.Data.CompanyName);


                Console.WriteLine(Messages.CustomerListed);
            }
            else
            {
                Console.WriteLine(result5.Message);
            }
        }
Exemple #28
0
        static void Main(string[] args)
        {
            #region Daha Sonra Düzenlenecek!
            //Console.WriteLine(" Araç Kiralama - Menü");
            //Console.WriteLine(" 1- Tüm araçları getir");
            //Console.WriteLine(" 2- Tüm renk seçeneklerini getir");
            //Console.WriteLine(" 3- Tüm markaları getir");
            //Console.WriteLine(" 4- Yeni Araç Ekle");
            //Console.WriteLine(" 5- Yeni Marka Ekle");
            //Console.WriteLine(" 6- Yeni Renk Ekle");
            //Console.WriteLine(" 7- Araç Detay Getir");
            #endregion


            // CarDetail();
            // GetUsers();

            //UserManager userManager = new UserManager(new EfUserDal());

            // Yeni User ekleme:
            //var result = userManager.Add(new User
            //{
            //    FirstName = "Berkay",
            //    LastName = "Başarın",
            //    Email = "*****@*****.**",
            //    Password = "******"
            //});

            //if (result.Success)
            //{
            //    Console.WriteLine(result.Message);
            //}
            //else
            //{
            //    Console.WriteLine(result.Message);
            //}

            //Console.WriteLine();


            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            customerManager.Add(new Customer
            {
                UserId      = 5,
                CompanyName = "ReCap Rent A Car"
            });

            var result = customerManager.GetAll();
            if (result.Success)
            {
                foreach (var customer in result.Data)
                {
                    Console.WriteLine(customer.UserId + " " + customer.CompanyName);
                }
            }



            // araç güncelleme
            //carManager.Update(new Car
            //{
            //    BrandId = 1,
            //    CarId = 6,
            //    ColorId = 4,
            //    ModelYear = "2013",
            //    DailyPrice = 65,
            //    Name = "Renault Symbol",
            //    Description = "Manuel vites. Dizel."
            //});

            //foreach (var car in carManager.GetAll())
            //{
            //    Console.WriteLine("{0}-{1}-{2}-{3}", car.Name, car.ModelYear, car.DailyPrice, car.Description);
            //}

            // araç ekleme
            //carManager.Add(new Car
            //{
            //    BrandId = 2,
            //    ColorId = 1,
            //    DailyPrice = 20,
            //    Description = "Silinecek araç",
            //    ModelYear = "2012",
            //    Name = "Suzuki"
            //});

            // araç silme
            //carManager.Delete(new Car
            //{
            //    CarId = 7,
            //    BrandId = 2,
            //    ColorId = 1,
            //    DailyPrice = 20,
            //    Description = "Silinecek araç",
            //    ModelYear = "2012",
            //    Name = "Suzuki"
            //});

            //carManager.Add(new Car
            //{
            //    BrandId = 1,
            //    ColorId = 4,
            //    DailyPrice = 60,
            //    ModelYear = "2011",
            //    Name = "Renault Symbol"
            //});


            //foreach (var car in carManager.GetCarsByColorId(4))
            //{
            //    Console.WriteLine(car.Name);
            //}



            //foreach (var car in carManager.GetCarsByBrandId(1))
            //{
            //    Console.WriteLine(car.ModelYear);
            //}

            //foreach (var car in carManager.GetAll())
            //{
            //    Console.WriteLine(car.Name);
            //}
        }
        static void Main(string[] args)
        {
            CarManager      carManager      = new CarManager(new EfCarDal());
            BrandManager    brandManager    = new BrandManager(new EfBrandDal());
            ColorManager    colorManager    = new ColorManager(new EfColorDal());
            UserManager     userManager     = new UserManager(new EfUserDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());

            GetCarDetails(carManager);
            GetAll(carManager);

            Console.WriteLine("\n====================================== Rent A Car ======================================");
            Console.WriteLine("1. Araba Ekle\n" + "2. Araba Sil\n" + "3. Araba Güncelle\n" + "4. Araba Listele\n\n" +
                              "5. Kullanıcı Ekle\n" + "6. Kullanıcı Sil\n" + "7. Kullanıcı Güncelle\n" + "8. Kullanıcı Listele\n\n" +
                              "9. Müşteri Ekle\n" + "10. Müşteri Sil\n" + "11. Müşteri Güncelle\n" + "12. Müşteri Listele\n\n" +
                              "13. Araba Kirala\n" + "14. Araba Teslim Al\n" + "15. Araba Kirası Güncelle\n" + "16. Kiralanmış Arabaları Listele\n\n" +
                              "99. Çıkış\n");


            bool exit = true;

            Console.WriteLine("\n------------------------------------------------------------------------");

            while (exit)
            {
                Console.Write("\nBir işlem seçin: ");
                int number = Convert.ToInt32(Console.ReadLine());

                switch (number)
                {
                case 1:
                    GetAll(brandManager);
                    GetAll(colorManager);

                    Console.Write("\nBrand Id: ");
                    int brandIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nColor Id: ");
                    int colorIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nDaily Price: ");
                    decimal dailyPriceForAdd = Convert.ToDecimal(Console.ReadLine());

                    Console.Write("\nDescription : ");
                    string descriptionForAdd = Console.ReadLine();

                    Console.Write("\nModel Year: ");
                    int modelYearForAdd = Convert.ToInt32(Console.ReadLine());

                    Car carForAdd = new Car {
                        BrandId = brandIdForAdd, ColorId = colorIdForAdd, DailyPrice = dailyPriceForAdd, Description = descriptionForAdd, ModelYear = modelYearForAdd
                    };
                    carManager.Add(carForAdd);
                    break;

                case 2:
                    GetAll(carManager);

                    Console.Write("Hangi Id'li arabayı silmek istiyorsunuz? ");
                    int carIdForDelete = Convert.ToInt32(Console.ReadLine());
                    carManager.Delete(carManager.GetById(carIdForDelete).Data);
                    break;

                case 3:
                    GetAll(carManager);

                    Console.Write("\nId: ");
                    int carIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nBrand Id: ");
                    int brandIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nColor Id: ");
                    int colorIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nDaily Price: ");
                    decimal dailyPriceForUpdate = Convert.ToDecimal(Console.ReadLine());

                    Console.Write("\nDescription : ");
                    string descriptionForUpdate = Console.ReadLine();

                    Console.Write("\nModel Year: ");
                    int modelYearForUpdate = Convert.ToInt32(Console.ReadLine());

                    Car carForUpdate = new Car {
                        Id = carIdForUpdate, BrandId = brandIdForUpdate, ColorId = colorIdForUpdate, DailyPrice = dailyPriceForUpdate, Description = descriptionForUpdate, ModelYear = modelYearForUpdate
                    };
                    carManager.Update(carForUpdate);
                    break;

                case 4:
                    GetAll(carManager);
                    break;

                case 5:
                    GetAll(userManager);

                    Console.Write("\nFirst Name: ");
                    string firstNameForAdd = Console.ReadLine();

                    Console.Write("\nLast Name: ");
                    string lastNameForAdd = Console.ReadLine();

                    Console.Write("\nEmail: ");
                    string emailForAdd = Console.ReadLine();

                    Console.Write("\nPassword: "******"Hangi Id'li kullanıcını silmek istiyorsunuz? ");
                    int userIdForDelete = Convert.ToInt32(Console.ReadLine());
                    userManager.Delete(userManager.GetById(userIdForDelete).Data);
                    break;

                case 7:
                    GetAll(userManager);

                    Console.Write("\nId: ");
                    int userIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nFirst Name: ");
                    string firstNameForUpdate = Console.ReadLine();

                    Console.Write("\nLast Name: ");
                    string lastNameForUpdate = Console.ReadLine();

                    Console.Write("\nEmail: ");
                    string emailForUpdate = Console.ReadLine();

                    Console.Write("\nPassword: "******"\nUser Id: ");
                    int userIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCustomer Name: ");
                    string customerNameForAdd = Console.ReadLine();

                    Customer customerForAdd = new Customer {
                        UserId = userIdForAdd, CompanyName = customerNameForAdd
                    };
                    customerManager.Add(customerForAdd);
                    break;

                case 10:
                    GetAll(customerManager);

                    Console.Write("Hangi Id'li müşterini silmek istiyorsunuz? ");
                    int customerIdForDelete = Convert.ToInt32(Console.ReadLine());
                    customerManager.Delete(customerManager.GetById(customerIdForDelete).Data);
                    break;

                case 11:
                    GetAll(customerManager);
                    GetAll(userManager);

                    Console.Write("\nId: ");
                    int customerIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nUser Id: ");
                    int customerUserIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCustomer Name: ");
                    string customerNameForUpdate = Console.ReadLine();

                    Customer customerForUpdate = new Customer {
                        Id = customerIdForUpdate, UserId = customerUserIdForUpdate, CompanyName = customerNameForUpdate
                    };
                    customerManager.Update(customerForUpdate);
                    break;

                case 12:
                    GetAll(customerManager);
                    break;

                case 13:
                    GetAll(carManager);
                    GetAll(customerManager);
                    GetAll(rentalManager);

                    Console.Write("\nCar Id: ");
                    int carIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCustomer Id: ");
                    int customerIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nRent Date: ");
                    DateTime rentDateForAdd = Convert.ToDateTime(Console.ReadLine());

                    Console.Write("\nReturn Date: ");
                    DateTime returnDateForAdd = Convert.ToDateTime(Console.ReadLine());

                    Rental rentalForAdd = new Rental {
                        CarId = carIdForAdd, CustomerId = customerIdForAdd, RentDate = rentDateForAdd, ReturnDate = returnDateForAdd
                    };
                    rentalManager.Add(rentalForAdd);
                    break;

                case 14:
                    GetAll(rentalManager);

                    Console.Write("Hangi Id'li kiralanmış arabanı teslim almak istiyorsunuz? ");
                    int rentalIdForDelete = Convert.ToInt32(Console.ReadLine());
                    rentalManager.Delete(rentalManager.GetById(rentalIdForDelete).Data);
                    break;

                case 15:
                    GetAll(carManager);
                    GetAll(customerManager);
                    GetAll(rentalManager);

                    Console.Write("\nId: ");
                    int rentalIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCar Id: ");
                    int rentalCarIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCustomer Id: ");
                    int rentalCustomerIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nRent Date: ");
                    DateTime rentDateForUpdate = Convert.ToDateTime(Console.ReadLine());

                    Console.Write("\nReturn Date: ");
                    DateTime returnDateForUpdate = Convert.ToDateTime(Console.ReadLine());

                    Rental rentalForUpdate = new Rental {
                        Id = rentalIdForUpdate, CarId = rentalCarIdForUpdate, CustomerId = rentalCustomerIdForUpdate, RentDate = rentDateForUpdate, ReturnDate = returnDateForUpdate
                    };
                    rentalManager.Update(rentalForUpdate);
                    break;

                case 16:
                    GetAll(rentalManager);
                    break;

                case 99:
                    exit = false;
                    break;
                }
            }
        }
Exemple #30
0
        static void Main(string[] args)
        {
            Console.WriteLine("----------USER----------");
            UserManager userManager = new UserManager(new EfUserDal());

            userManager.Add(new User
            {
                Id        = 2,
                FirstName = "Engincan",
                LastName  = "Coşkun",
                Email     = "*****@*****.**",
                Password  = "******"
            });

            foreach (var user in userManager.GetAll().Data)
            {
                Console.WriteLine("Id: {0} FirstName: {1} LastName: {2} Email: {3} Password: {4}", user.Id, user.FirstName, user.LastName, user.Email, user.Password);
            }


            Console.WriteLine("----------CUSTOMER----------");
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            customerManager.Add(new Customer
            {
                UserId      = 2,
                CustomerId  = 2,
                CompanyName = "Company1"
            });

            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine("UserId: {0} CustomerId: {1} CompanyName: {2}", customer.UserId, customer.CustomerId, customer.CompanyName);
            }


            Console.WriteLine("----------RENTAL----------");
            RentalManager rentalManager = new RentalManager(new EfRentalDal());

            rentalManager.Add(new Rental
            {
                RentalId   = 2,
                CarId      = 2,
                CustomerId = 2,
                RentDate   = new DateTime(2021, 3, 10),
                ReturnDate = new DateTime(2021, 3, 15)
            });

            foreach (var rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine("RentalId: {0} CarId: {1} CustomerId: {2} RentDate: {3} ReturnDate: {4}", rental.RentalId, rental.CarId, rental.CustomerId, rental.RentDate, rental.ReturnDate);
            }



            //Console.WriteLine("Marka Id'si 2 olan araç listesi");

            //CarManager carManager2 = new CarManager(new EfCarDal());
            //foreach (var car in carManager2.GetCarsByBrandId(2))
            //{
            //    Console.WriteLine("Modelyılı {0} Marka {1} Günlük Fiyatı {2} Tanımı {3}", car.ModelYear, car.BrandId, car.DailyPrice, car.Description);
            //}



            //Console.WriteLine("Renk Id'si 1 olan araç listesi");

            //CarManager carManager3 = new CarManager(new EfCarDal());
            //foreach (var car in carManager2.GetCarsByColorId(1))
            //{
            //    Console.WriteLine("Modelyılı {0} Marka {1} Günlük Fiyatı {2} Tanımı {3}", car.ModelYear, car.BrandId, car.DailyPrice, car.Description);
            //}



            //Console.WriteLine("Yeni araç ekleme ve araç listesi");

            //CarManager carManager1 = new CarManager(new EfCarDal());
            //carManager1.Add(new Entities.Concrete.Car { CarId = 7, BrandId = 5, ColorId = 2, ModelYear = 2020, DailyPrice = 1100, Description = "Lamborghini Gallardo " });

            //foreach (var car in carManager1.GetAll())
            //{
            //    Console.WriteLine("Modelyılı {0} Marka {1} Günlük Fiyatı {2} Tanımı {3}", car.ModelYear, car.BrandId, car.DailyPrice, car.Description);
            //}
        }