Exemplo n.º 1
0
            static void updateCustomer(CustomerManager customerManager)
            {
                //carManager.Add(new Car
                //{
                //    CarId = 6,
                //    BrandId = 2,
                //    ColorId = 1,
                //    DailyPrice = 100,
                //    Description = "Audi",
                //    ModelYear = 2001
                //});
                getAllCustomer(customerManager);
                Customer customer = new Customer();

                Console.WriteLine("Please Select Customer ID to Update :");
                customer.Id = UInt16.Parse(Console.ReadLine());
                customerManager.GetById(customer.Id);
                Console.WriteLine("Enter Customer Name:");
                customer.CustomerName = Console.ReadLine();
                Console.WriteLine("Enter Customer's Payment:");
                customer.Payment = UInt16.Parse(Console.ReadLine());
                Console.WriteLine("Enter Payment Type:");
                customer.PaymetType = Console.ReadLine();
                Console.WriteLine("Enter Payment Date:");
                customer.PaymentDate = DateTime.Parse(Console.ReadLine());

                customerManager.Update(customer);
            }
Exemplo n.º 2
0
        private void UserMenu_Delete(UserManager userManager, CustomerManager customerManager)
        {
            Console.WriteLine("\nList of All Users");
            userManager.WriteAll(userManager.GetAll().Data);

            bool IsExist  = false;
            int  searchID = 0;

            while (!IsExist)
            {
                Console.Write("-> Enter the ID of the user you want to delete: ");
                searchID = Convert.ToInt32(Console.ReadLine());
                IsExist  = userManager.IsExistById(searchID).Success;
                if (!IsExist)
                {
                    Console.Write(Messages.ColorNotExist + " Try again. User ID: ");
                    searchID = Convert.ToInt32(Console.ReadLine());
                    IsExist  = userManager.IsExistById(searchID).Success;
                }
            }

            var user = userManager.Delete(userManager.GetById(searchID).Data).Data;

            customerManager.Delete(customerManager.GetById(user.Id).Data);
        }
Exemplo n.º 3
0
        private static void RentalCarTest()
        {
            CarManager      carManager      = new CarManager(new EfCarDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());
            Car             _car            = new Car();
            var             selectCustomer  = customerManager.GetById(1);

            if (selectCustomer != null)
            {
                Rental rental = new Rental
                {
                    CarId      = _car.CarId,
                    RentDate   = DateTime.Now,
                    ReturnDate = null,
                    CustomerId = selectCustomer.Data.CustomerId
                };
                var result = rentalManager.Add(rental);
                if (result.Success)
                {
                    Console.WriteLine(result.Message);
                }
                else
                {
                    Console.WriteLine(result.Message);
                }
            }
        }
Exemplo n.º 4
0
        private protected static void AddRentalTest()
        {
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());
            CarManager      carManager      = new CarManager(new EfCarDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            var car      = carManager.GetById(3);
            var customer = customerManager.GetById(1);

            if (car.Data == null)
            {
                Console.WriteLine("Araç sistemde bulunamadı.");
            }
            else if (customer.Data == null)
            {
                Console.WriteLine("Müşteri sistemde bulunamadı.");
            }
            else
            {
                var result = rentalManager.Add(new Rental
                {
                    CarId      = car.Data.Id,
                    CustomerId = customer.Data.Id,
                    RentDate   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))
                });
                if (result.Success)
                {
                    Console.WriteLine(result.Message);
                }
                else
                {
                    Console.WriteLine(result.Message);
                }
            }
        }
Exemplo n.º 5
0
        private static void CustomerTest()
        {
            Console.WriteLine("--------- CUSTOMER TEST ---------");
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            Console.WriteLine("--------- GetAll ---------");
            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.CustomerId + " " + customer.CompanyName);
            }

            Console.WriteLine("--------- GetById ---------");
            Console.WriteLine(customerManager.GetById(1).Data.CustomerId + " " + customerManager.GetById(1).Data.CompanyName);

            Console.WriteLine("--------- Add ---------");
            var resultAdd = customerManager.Add(new Customer {
                CustomerId = 6, UserId = 1, CompanyName = "F"
            });

            Console.WriteLine(resultAdd.Message);
            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.CustomerId + " " + customer.CompanyName);
            }

            Console.WriteLine("--------- Update ---------");
            var resultUpdate = customerManager.Update(new Customer {
                CustomerId = 6, UserId = 1, CompanyName = "FFF"
            });

            Console.WriteLine(resultUpdate.Message);
            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.CustomerId + " " + customer.CompanyName);
            }

            Console.WriteLine("--------- Delete ---------");
            var resultDelete = customerManager.Delete(new Customer {
                CustomerId = 6
            });

            Console.WriteLine(resultDelete.Message);
            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.CustomerId + " " + customer.CompanyName);
            }
        }
Exemplo n.º 6
0
        private static void DeleteCustomerTest(int id)
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            var result = customerManager.Delete(customerManager.GetById(id).Data);

            Console.WriteLine(result.Message);
        }
Exemplo n.º 7
0
        static void CustomerGetById(CustomerManager customerManager)
        {
            Console.Write("Id giriniz : ");
            int      id       = int.Parse(Console.ReadLine());
            Customer customer = customerManager.GetById(id).Data;

            Console.WriteLine(customer.Id + "\t" + customer.UserId + "\t" + customer.CompanyName);
        }
Exemplo n.º 8
0
        private static void CustomerById()
        {
            ICustomerService customerManager = new CustomerManager(new EfCustomerDal());
            var result1 = customerManager.GetById(7);

            if (result1.Success == true)
            {
                Console.WriteLine(result1.Data.CompanyName);
            }
        }
Exemplo n.º 9
0
        private static void CustomerDeleteTest()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            CustomerTest();
            Console.Write("Silmek için Customer ID'si giriniz:");
            int chooseId = int.Parse(Console.ReadLine());
            var result   = customerManager.GetById(chooseId).Data;

            customerManager.Delete(result);
        }
Exemplo n.º 10
0
            static void deleteCustomer(CustomerManager customerManager)
            {
                Customer customer1 = new Customer();

                getAllCustomer(customerManager);
                Console.WriteLine("Enter Customer ID to DELETE:");
                customer1.Id = UInt16.Parse(Console.ReadLine());
                //customer1 = customerManager.GetById(customer1.CustomerId);
                customer1 = customerManager.GetById(customer1.Id).Data;
                customerManager.Delete(customer1);
            }
Exemplo n.º 11
0
        static void YeniBirKiralamaYap()
        {
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());
            CarManager      carManager      = new CarManager(new EfCarDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            Customer customer = customerManager.GetById(1).Data;
            Car      car      = carManager.GetById(1).Data;

            IResult result = rentalManager.RentACar(car, customer);

            Console.WriteLine(result.Message);
        }
Exemplo n.º 12
0
        private static void CustomerUpdateTest()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            CustomerTest();
            Console.Write("Güncellemek için Customer ID'si giriniz:");
            int chooseId = int.Parse(Console.ReadLine());
            var result   = customerManager.GetById(chooseId).Data;

            Console.Write("User Id giriniz:");
            result.CustomerId = int.Parse(Console.ReadLine());
            Console.Write("Company Name giriniz:");
            result.CompanyName = Console.ReadLine();
            customerManager.Update(result);
        }
Exemplo n.º 13
0
        private static void CustomerTests()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            Console.WriteLine(customerManager.Update(new Customer {
                UserId = 2, CompanyName = "GHI COMPANY"
            }).Message);

            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine(customer.CompanyName);
            }
            Console.WriteLine(customerManager.GetAll().Message);

            Console.WriteLine(customerManager.GetById(2).Data.CompanyName);
        }
Exemplo n.º 14
0
        /**   public  void ProductTest()
         * {
         *     ProductManager productManager = new ProductManager(new EfProductDal());
         *     //var result = productManager.GetProductDetailDtos();
         *     //if (result.Success == true)
         *     //{
         *     //    foreach (var product in result.Data)
         *     //    {
         *     //        Console.WriteLine("ProductId" + product.ProductId);
         *     //        Console.WriteLine("ProductName" + product.ProductName);
         *     //        Console.WriteLine("CategoryName" + product.CategoryName);
         *     //        Console.WriteLine("UnitsInStock" + product.UnitsInStock);
         *     //    }
         *     //}
         *     //else
         *     //{
         *     //    Console.WriteLine(result.Message);
         *     //}
         *
         *
         *     var result2 = productManager.GetAll();
         *     if (result2.Success == true)
         *     {
         *         foreach (var product in result2.Data)
         *         {
         *             Console.WriteLine("ProductID : " + product.ProductID);
         *             Console.WriteLine("ProductName : " + product.CategoryID);
         *             Console.WriteLine("ProductName : " + product.ProductName);
         *             Console.WriteLine("UnitPrice : " + product.UnitPrice);
         *             Console.WriteLine("ProductName : " + product.UnitsInStock);
         *             Console.WriteLine("=========================" );
         *
         *         }
         *     }
         *     else
         *     {
         *         Console.WriteLine(result2.Message);
         *     }
         *
         *     //foreach (var product in productManager.GetAll().Data)
         *     //{
         *     //    Console.WriteLine("ProductID : " + product.ProductID);
         *     //    Console.WriteLine("ProductName : " + product.CategoryID);
         *     //    Console.WriteLine("ProductName : " + product.ProductName);
         *     //    Console.WriteLine("UnitPrice : " + product.UnitPrice);
         *     //    Console.WriteLine("ProductName : " + product.UnitsInStock);
         *     //}
         *
         *     //productManager.Add(new Product
         *     //{
         *     //    ProductID = 78,
         *     //    ProductName = "Test",
         *     //    SupplierID = 10,
         *     //    CategoryID = 220,
         *     //    QuantityPerUnit = "0 boxes x 8 pieces",
         *     //    UnitPrice = 500,
         *     //    UnitsInStock = 7,
         *     //    UnitsOnOrder = 70,
         *     //    ReorderLevel = 20,
         *     //    Discontinued = false
         *
         *     //});
         *     //productManager.GetById(2021);
         *     //productManager.GetAllByCategoryId(2020);
         *
         *     //foreach (var product in productManager.GetProductDetailDtos().Data)
         *     //{
         *     //    Console.WriteLine("ProductId" + product.ProductId);
         *     //    Console.WriteLine("ProductName" + product.ProductName);
         *     //    Console.WriteLine("CategoryName" + product.CategoryName);
         *     //    Console.WriteLine("UnitsInStock" + product.UnitsInStock);
         *     //}
         *
         *     //productManager.GetByUnitPrice(500, 1500);
         *
         *     //productManager.Update(new Product
         *     //{
         *     //    ProductID = 2025,
         *     //    CategoryID = 2025,
         *     //    ProductName = "TestTest",
         *     //    UnitPrice = 50,
         *     //    UnitsInStock = 70
         *     //});
         *     //productManager.Delete(new Product
         *     //{
         *     //    ProductID = 50,
         *     //    ProductName = "Valkoinen suklaa",
         *     //    SupplierID = 23,
         *     //    CategoryID =3,
         *     //    QuantityPerUnit = "12 - 100 g bars",
         *     //    UnitPrice = 162500,
         *     //    UnitsInStock = 65,
         *     //    UnitsOnOrder = 0,
         *     //    ReorderLevel = 30,
         *     //    Discontinued = false
         *     //});
         *
         * }*/
        //customer
        //********************** SonarQube ********************
        public void CustomerTest()
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            foreach (var customer in customerManager.GetAll().Data)
            {
                Console.WriteLine("CustomerID : " + customer.CustomerID);
                Console.WriteLine("CompanyName : " + customer.CompanyName);
                Console.WriteLine("ContactName : " + customer.ContactName);
                Console.WriteLine("City : " + customer.City);
            }
            Customer customer1 = customerManager.GetById("TRAIH").Data;

            Console.WriteLine(customer1.CompanyName);
            Console.WriteLine(customer1.ContactName);
            Console.WriteLine(customer1.City);
        }
Exemplo n.º 15
0
        private static void RentalTest()
        {
            CarManager      carManager      = new CarManager(new EfCarDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());
            var             result          = rentalManager.Add(new Rental {
                CarId = carManager.GetById(10).Data.Id, CustomerId = customerManager.GetById(4).Data.CustomerId, RentDate = new DateTime(2021, 03, 20), ReturnDate = new DateTime(2021, 03, 23)
            });

            if (result.Success == true)
            {
                Console.WriteLine(result.Message);
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Exemplo n.º 16
0
        private static void GetCustomerById(CustomerManager customerManager)
        {
            Console.WriteLine("---------- Müşteri Bilgileri Detay Ekranı ----------");
            Console.WriteLine("Müşteri Id'si giriniz: ");
            int id = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(" ");

            var result = customerManager.GetById(id);

            if (result.Data != null)
            {
                Console.WriteLine("Customer Id\tUser Id\t\tCompany Name");
                Console.WriteLine($"{result.Data.CustomerId}\t\t{result.Data.UserId}\t\t{result.Data.CompanyName}");
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Exemplo n.º 17
0
        static void CustomerUpdate(CustomerManager customerManager)
        {
            Console.Write("Güncellemek istediğiniz müşterinin idsini giriniz : ");
            int      customerIdUpdate = int.Parse(Console.ReadLine());
            Customer updatedCustomer  = customerManager.GetById(customerIdUpdate).Data;

            Console.Write("UserId : ");
            updatedCustomer.UserId = int.Parse(Console.ReadLine());
            Console.Write("CompanyName : ");
            updatedCustomer.CompanyName = Console.ReadLine();
            var result = customerManager.Update(updatedCustomer);

            if (result.Success)
            {
                Console.WriteLine(result.Message);
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
        private static void GetCustomerByIdTest(int id)
        {
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            var      result       = customerManager.GetById(id);
            Customer customerById = result.Data;

            if (result.Success == true)
            {
                string str = new string('_', 50);
                Console.WriteLine(str + "\n\n\tID\t\tUserID\t\tCompany Name\t");

                Console.WriteLine("\t{0}\t\t{1}\t\t{2}\t",
                                  customerById.Id, customerById.UserId, customerById.CompanyName);

                Console.WriteLine(str + "\n");
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Exemplo n.º 20
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);
            }
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            InputManager    inputManager    = new InputManager();
            BrandManager    brandManager    = new BrandManager(new EfBrandDal());
            CarManager      carManager      = new CarManager(new EfCarDal());
            ColorManager    colorManager    = new ColorManager(new EfColorDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());
            UserManager     userManager     = new UserManager(new EfUserDal());

            do
            {
                Console.Clear();
                int operation1 = inputManager.InputTitle();
                int operation2 = inputManager.Inputoperation(operation1);

                switch (operation1)
                {
                case 1:
                    switch (operation2)
                    {
                    case 1:
                        var result1 = brandManager.GetById();

                        Console.WriteLine(Lists.BrandList);
                        Console.WriteLine(result1.Data.Id + "\t\t\t" + result1.Data.BrandName);
                        Console.WriteLine(result1.Message);
                        break;

                    case 2:
                        var result2 = brandManager.GetAll();

                        Console.WriteLine(Lists.BrandList);
                        foreach (var brand in result2.Data)
                        {
                            Console.WriteLine(brand.Id + "\t\t\t" + brand.BrandName);
                        }
                        Console.WriteLine(result2.Message);
                        break;

                    case 3:
                        var result3 = brandManager.Add();
                        Console.WriteLine(result3.Message);
                        break;

                    case 4:
                        var result4 = brandManager.Update();
                        Console.WriteLine(result4.Message);
                        break;

                    case 5:
                        var result5 = brandManager.Delete();
                        Console.WriteLine(result5.Message);
                        break;
                    }
                    break;

                case 2:
                    switch (operation2)
                    {
                    case 1:
                        var result1 = carManager.GetById();

                        Console.WriteLine(Lists.CarList);
                        Console.WriteLine(
                            result1.Data.Id + "\t\t" +
                            result1.Data.BrandId + "\t\t" +
                            result1.Data.ColorId + "\t\t" +
                            result1.Data.ModelYear + "\t\t" +
                            result1.Data.DailyPrice + "\t\t" +
                            result1.Data.Description
                            );
                        Console.WriteLine(result1.Message);
                        break;

                    case 2:
                        var result2 = carManager.GetAll();

                        Console.WriteLine(Lists.CarList);
                        foreach (var car in result2.Data)
                        {
                            Console.WriteLine(
                                car.Id + "\t\t" +
                                car.BrandId + "\t\t" +
                                car.ColorId + "\t\t" +
                                car.ModelYear + "\t\t" +
                                car.DailyPrice + "\t\t" +
                                car.Description
                                );
                        }
                        Console.WriteLine(result2.Message);
                        break;

                    case 3:
                        var result3 = carManager.Add();
                        Console.WriteLine(result3.Message);
                        break;

                    case 4:
                        var result4 = carManager.Update();
                        Console.WriteLine(result4.Message);
                        break;

                    case 5:
                        var result5 = carManager.Delete();
                        Console.WriteLine(result5.Message);
                        break;

                    case 6:
                        var result6 = carManager.GetCarsByBrandId();

                        Console.WriteLine(Lists.CarList);
                        foreach (var car in result6.Data)
                        {
                            Console.WriteLine(
                                car.Id + "\t\t" +
                                car.BrandId + "\t\t" +
                                car.ColorId + "\t\t" +
                                car.ModelYear + "\t\t" +
                                car.DailyPrice + "\t\t" +
                                car.Description
                                );
                        }
                        Console.WriteLine(result6.Message);
                        break;

                    case 7:
                        var result7 = carManager.GetCarsByColorId();

                        Console.WriteLine(Lists.CarList);
                        foreach (var car in result7.Data)
                        {
                            Console.WriteLine(
                                car.Id + "\t\t" +
                                car.BrandId + "\t\t" +
                                car.ColorId + "\t\t" +
                                car.ModelYear + "\t\t" +
                                car.DailyPrice + "\t\t" +
                                car.Description
                                );
                        }
                        Console.WriteLine(result7.Message);
                        break;

                    case 8:
                        var result8 = carManager.GetCarDetailDtos();

                        Console.WriteLine(Lists.CarList);
                        foreach (var car in result8.Data)
                        {
                            Console.WriteLine(
                                car.CarName +
                                "\t\t" + car.BrandName +
                                "\t\t\t" + car.ColorName +
                                "\t\t\t" + car.DailyPrice);
                        }
                        Console.WriteLine(result8.Message);
                        break;
                    }
                    break;

                case 3:
                    switch (operation2)
                    {
                    case 1:
                        var result1 = colorManager.GetById();

                        Console.WriteLine(Lists.ColorList);
                        Console.WriteLine(result1.Data.Id + "\t\t\t" + result1.Data.ColorName);
                        Console.WriteLine(result1.Message);
                        break;

                    case 2:
                        var result2 = colorManager.GetAll();

                        Console.WriteLine(Lists.ColorList);
                        foreach (var color in result2.Data)
                        {
                            Console.WriteLine(color.Id + "\t\t" + color.ColorName);
                        }
                        Console.WriteLine(result2.Message);
                        break;

                    case 3:
                        var result3 = colorManager.Add();
                        Console.WriteLine(result3.Message);
                        break;

                    case 4:
                        var result4 = colorManager.Update();
                        Console.WriteLine(result4.Message);
                        break;

                    case 5:
                        var result5 = colorManager.Delete();
                        Console.WriteLine(result5.Message);
                        break;
                    }
                    break;

                case 4:
                    switch (operation2)
                    {
                    case 1:
                        var result1 = customerManager.GetById();

                        Console.WriteLine(Lists.CustomerList);
                        Console.WriteLine(result1.Data.Id + "\t\t\t"
                                          + result1.Data.UserId + "\t\t\t"
                                          + result1.Data.CompanyName);
                        Console.WriteLine(result1.Message);
                        break;

                    case 2:
                        var result2 = customerManager.GetAll();

                        Console.WriteLine(Lists.CustomerList);
                        foreach (var customer in result2.Data)
                        {
                            Console.WriteLine(customer.Id + "\t\t\t"
                                              + customer.UserId + "\t\t\t"
                                              + customer.CompanyName);
                        }
                        Console.WriteLine(result2.Message);
                        break;

                    case 3:
                        var result3 = customerManager.Add();
                        Console.WriteLine(result3.Message);
                        break;

                    case 4:
                        var result4 = customerManager.Update();
                        Console.WriteLine(result4.Message);
                        break;

                    case 5:
                        var result5 = customerManager.Delete();
                        Console.WriteLine(result5.Message);
                        break;
                    }
                    break;

                case 5:
                    switch (operation2)
                    {
                    case 1:
                        var result1 = rentalManager.GetById();

                        Console.WriteLine(Lists.RentalList);
                        Console.WriteLine(
                            result1.Data.Id + "\t\t\t" +
                            result1.Data.CarId + "\t\t\t" +
                            result1.Data.CustomerId + "\t\t\t" +
                            result1.Data.RentDate + "\t\t" +
                            result1.Data.ReturnDate);
                        Console.WriteLine(result1.Message);
                        break;

                    case 2:
                        var result2 = rentalManager.GetAll();

                        Console.WriteLine(Lists.RentalList);
                        foreach (var rental in result2.Data)
                        {
                            Console.WriteLine(
                                rental.Id + "\t\t\t" +
                                rental.CarId + "\t\t\t" +
                                rental.CustomerId + "\t\t\t" +
                                rental.RentDate + "\t\t" +
                                rental.ReturnDate);
                        }
                        Console.WriteLine(result2.Message);
                        break;

                    case 3:
                        var result3 = rentalManager.Add();
                        Console.WriteLine(result3.Message);
                        break;

                    case 4:
                        var result4 = rentalManager.Update();
                        Console.WriteLine(result4.Message);
                        break;

                    case 5:
                        var result5 = rentalManager.Delete();
                        Console.WriteLine(result5.Message);
                        break;
                    }
                    break;

                case 6:
                    switch (operation2)
                    {
                    case 1:
                        var result1 = userManager.GetById();

                        Console.WriteLine(Lists.UserList);
                        Console.WriteLine(
                            result1.Data.Id + "\t\t\t" +
                            result1.Data.FirstName + "\t\t" +
                            result1.Data.LastName + "\t\t" +
                            result1.Data.Email + "\t\t" +
                            result1.Data.Password);
                        Console.WriteLine(result1.Message);
                        break;

                    case 2:
                        var result2 = userManager.GetAll();

                        Console.WriteLine(Lists.UserList);
                        foreach (var user in result2.Data)
                        {
                            Console.WriteLine(
                                user.Id + "\t\t\t" +
                                user.FirstName + "\t\t" +
                                user.LastName + "\t\t" +
                                user.Email + "\t\t" +
                                user.Password);
                        }
                        Console.WriteLine(result2.Message);
                        break;

                    case 3:
                        var result3 = userManager.Add();
                        Console.WriteLine(result3.Message);
                        break;

                    case 4:
                        var result4 = userManager.Update();
                        Console.WriteLine(result4.Message);
                        break;

                    case 5:
                        var result5 = userManager.Delete();
                        Console.WriteLine(result5.Message);
                        break;
                    }
                    break;
                }

                Console.Write("Devam Etmek İster Misiniz? (e/h)");
            } while(Console.ReadLine() == "e");
        }
Exemplo n.º 22
0
        private static Rental AddRental(RentalManager rentalManager, CarManager carManager, CustomerManager customerManager)
        {
            Console.WriteLine("Varolan Kiralama Işlemleri Llisteleniyor..");
            foreach (var item in rentalManager.GetAll().Data)
            {
                Console.WriteLine($"\nKiralanan Araba :{carManager.GetById(item.CarId).Data.Name}\nŞirket Adı : {customerManager.GetById(item.CustomerId).Data.CompanyName}\nKiralama Başlangıç Tarihi : {item.RentDate}\n Kiralama Bitiş Tarihi : {item.ReturnDate}");
            }
            Console.WriteLine("\nSırasıyla Bilgileri Giriniz:\nCarID giriniz : ");
            int carId = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Müşteri ID Giriniz : ");
            int customerId = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Kiralama Tarihini giriniz : ");
            DateTime rentDate = Convert.ToDateTime(Console.ReadLine());

            Console.WriteLine("Geri Getireceğiniz Tarihi Giriniz : ");
            DateTime returnTime = Convert.ToDateTime(Console.ReadLine());

            return(new Rental {
                CarId = carId, CustomerId = customerId, RentDate = rentDate, ReturnDate = returnTime
            });
        }
Exemplo n.º 23
0
        //private static void UserMenu()
        //{
        //    int userMenu = 1;
        //    while (userMenu != 0)
        //    {
        //        Console.WriteLine("Kullanıcı eklemek için 1'e basınız\nKullanıcı güncellemek için 2'ye basınız\nKullanıcı silmek için 3'e basınız\nKullanıcıları listelemek için 4'e basınız\nBir üst menüye geçiş yapmak için 0'a basınız");
        //        userMenu = int.Parse(Console.ReadLine());
        //        switch (userMenu)
        //        {
        //            case 1:
        //                Console.WriteLine("Kullanıcı adını giriniz");
        //                User user = new User();
        //                user.UserName = Console.ReadLine();
        //                Console.WriteLine("Şifrenizi giriniz");
        //                user.Password = Console.ReadLine();
        //                Console.WriteLine("Adınızı giriniz");
        //                user.FirstName = Console.ReadLine();
        //                Console.WriteLine("Soyadınızı giriniz");
        //                user.LastName = Console.ReadLine();
        //                Console.WriteLine("E-mail adresinizi giriniz");
        //                user.Email = Console.ReadLine();
        //                Console.WriteLine(userManager.Add(user).Message);
        //                break;
        //            case 2:
        //                Console.WriteLine("Güncellemek istediğiniz kullanıcının Idsini giriniz");
        //                UserWriteList();
        //                User updateToUser = userManager.GetById(Convert.ToInt32(Console.ReadLine())).Data;
        //                if (updateToUser==null)
        //                {
        //                    Console.WriteLine("Gerçersiz Id");
        //                    break;
        //                }
        //                Console.WriteLine("Şifrenizi giriniz");
        //                updateToUser.Password = Console.ReadLine();
        //                Console.WriteLine("Adınızı giriniz");
        //                updateToUser.FirstName = Console.ReadLine();
        //                Console.WriteLine("Soyadınızı giriniz");
        //                updateToUser.LastName = Console.ReadLine();
        //                Console.WriteLine("E-mail adresinizi giriniz");
        //                updateToUser.Email = Console.ReadLine();
        //                Console.WriteLine(userManager.Update(updateToUser).Message);
        //                break;
        //            case 3:
        //                Console.WriteLine("Silmek istediğiniz kullanıcının Idsini giriniz");
        //                UserWriteList();
        //                User deleteToUser = userManager.GetById(Convert.ToInt32(Console.ReadLine())).Data;
        //                Console.WriteLine(userManager.Delete(deleteToUser).Message);
        //                break;
        //            case 4:
        //                Console.WriteLine("\nKullanıcılar");
        //                UserWriteList();
        //                break;
        //            case 0:
        //                break;
        //            default:
        //                Console.WriteLine("Hatalı bir seçim yaptınız");
        //                break;
        //        }
        //    }
        //}
        private static void CustomerMenu()
        {
            int customerMenu = 1;

            while (customerMenu != 0)
            {
                Console.WriteLine("Şirket eklemek için 1'e basınız\nŞirket güncellemek için 2'ye basınız\nŞirket silmek için 3'e basınız\nŞirketleri listelemek için 4'e basınız\nBir üst menüye geçiş yapmak için 0'a basınız");
                customerMenu = int.Parse(Console.ReadLine());
                switch (customerMenu)
                {
                case 1:
                    UserWriteList();
                    Console.WriteLine("Şirketini yazacağınız kullanıcının Idsini yazınız");
                    Customer customer = new Customer();
                    int      userId   = Convert.ToInt32(Console.ReadLine());
                    if (userManager.GetById(userId).Data == null)
                    {
                        Console.WriteLine("Geçersiz kullanıcı idsi");
                        break;
                    }
                    customer.UserId = userManager.GetById(userId).Data.Id;
                    Console.WriteLine("Şirket adını giriniz");
                    customer.CompanyName = Console.ReadLine();
                    Console.WriteLine(customerManager.Add(customer).Message);
                    break;

                case 2:
                    Console.WriteLine("Güncellemek istediğiniz şirketin Idsini giriniz");
                    CustomerWriteList();
                    Customer updateToCustomer = customerManager.GetById(Convert.ToInt32(Console.ReadLine())).Data;
                    if (updateToCustomer == null)
                    {
                        Console.WriteLine("Geçersiz Id");
                        break;
                    }
                    Console.WriteLine("Yeni şirket adını giriniz");
                    updateToCustomer.CompanyName = Console.ReadLine();
                    Console.WriteLine(customerManager.Update(updateToCustomer).Message);
                    break;

                case 3:
                    Console.WriteLine("Silmek istediğiniz şirketin Idsini giriniz");
                    CustomerWriteList();
                    Customer deleteToCustomer = customerManager.GetById(Convert.ToInt32(Console.ReadLine())).Data;
                    Console.WriteLine(customerManager.Delete(deleteToCustomer).Message);
                    break;

                case 4:
                    Console.WriteLine("\nŞirketler");
                    CustomerWriteList();
                    break;

                case 0:
                    break;

                default:
                    Console.WriteLine("Hatalı bir seçim yaptınız");
                    break;
                }
            }
        }
Exemplo n.º 24
0
        private static void CustomerGetByIdTest()
        {
            CustomerManager customerGetById = new CustomerManager(new EfCustomerDal());

            Console.WriteLine(customerGetById.GetById(2).Data.CompanyName);
        }
Exemplo n.º 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());
            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;
                }
            }
        }