Example #1
0
        private static void CarByBrandId()
        {
            CarManager carManager = new CarManager(new EfCarDal());

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

            Console.WriteLine("");
            Console.WriteLine(carManager.Get(id).Data.Id + " " + carManager.Get(id).Data.ModelYear + " " + carManager.Get(id).Data.Description + " " + carManager.Get(id).Data.DailyPrice + "TL Günlük");
        }
Example #2
0
        private static void CarGetIdTest()
        {
            CarManager carManager = new CarManager(new EfCarDal());
            Car        car        = carManager.Get(4).Data;

            Console.WriteLine(car.Name);
        }
Example #3
0
        private static void CarTest()
        {
            ICarService carService = new CarManager(new EfCarDal());

            //Console.WriteLine("Yeni araç ekle : ");
            //carService.Add(new Car { BrandId = 3, ColorId = 3, ModelYear = "1999", DailyPrice = 80, Description = "F30 Kasa" });

            //Console.WriteLine("Araç güncelle ;");
            //carService.Update(new Car { Id = 1002, BrandId = 1, ColorId = 2, ModelYear = "2009", DailyPrice = 180, Description = "Toros" });

            //Console.WriteLine("Araç Sil ;");
            //carService.Delete(new Car { Id = 2002, BrandId = 3, ColorId = 3, ModelYear = "1999", DailyPrice = 80, Description = "F30 Kasa" });

            Console.WriteLine("Araçları Listele :");
            foreach (var car in carService.GetAll().Data)
            {
                Console.WriteLine("Marka : {0}, Açıklama : {1}, Model : {2}, Günlük Fiyat : {3} TL", car.BrandId, car.Description, car.ModelYear, car.DailyPrice);
            }

            Console.WriteLine("Id si 2 olan araç : ");
            var carId1 = carService.Get(3).Data;

            Console.WriteLine("3 Id li Araç ; Marka : {0}, Açıklama : {1}, Model : {2}, Günlük Fiyat : {3} TL", carId1.BrandId, carId1.Description, carId1.ModelYear, carId1.DailyPrice);

            Console.WriteLine("Araç detaylı sıralama : ");
            foreach (var car in carService.GetCarDetails().Data)
            {
                Console.WriteLine("Marka : {0}, Renk : {1}, Açıklama : {2}, Günlük Fiyat : {3} TL", car.BrandName, car.ColorName, car.Description, car.DailyPrice);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            CarManager carManager = new CarManager(new InMemoryCarDal());

            foreach (var car in carManager.GetAll())
            {
                Console.WriteLine($"{car.BrandId} {car.ColorId} {car.Description} {car.DailyPrice} ");
            }


            Console.WriteLine("-----------------------------");
            foreach (var car in carManager.GetAllByColor(2))
            {
                Console.WriteLine($"{car.BrandId} {car.ColorId} {car.Description} {car.DailyPrice} ");
            }


            carManager.Add(new Entities.Concrete.Car {
                CarId = 9, BrandId = 2, ColorId = 1, Description = "yeni Kayıt", DailyPrice = 134000, year = "2020"
            });

            Console.WriteLine((carManager.Get(9)).Description);
            Console.WriteLine("-----------------------------");
            foreach (var car in carManager.GetAll())
            {
                Console.WriteLine($"{car.BrandId} {car.ColorId} {car.Description} {car.DailyPrice} ");
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new EfCarDal());
            List <Car> cars       = carManager.GetAll();

            cars.ForEach(x => Console.WriteLine(x.CarName));
            // Car car = new Car()
            // {
            //     BrandId = 2,
            //     ColorId = 1,
            //     CarName = "BMW 320i Sedan M Sport",
            //     DailyPrice = 14255,
            //     ModelYear = 2020,
            //     Description = null,
            // };
            // var result = carManager.Insert(car);
            // if (!result)
            //     Console.WriteLine("Ekleme işlemi iptal edildi. Araba ismi veya Günlük Ücret hatalı.");
            // else
            //     Console.WriteLine("\n-----------Ekleme işlemi başarılı.\n");
            // cars = carManager.GetAll();
            // cars.ForEach(x => Console.WriteLine(x.CarName));
            // Car car = carManager.Get(17);
            // car.DailyPrice = 13798;
            // carManager.Update(car);
            // Console.WriteLine("\n-----------Ekleme işlemi başarılı.\n");
            // carManager.GetAll().ForEach(x => Console.WriteLine(x.DailyPrice));


            Console.WriteLine("\n-----------Ekleme işlemi başarılı.\n");
            Car car = carManager.Get(19);

            carManager.Delete(car);
            carManager.GetAll().ForEach(x => Console.WriteLine(x.CarName));
        }
Example #6
0
        private static void CarById()
        {
            CarManager carManager = new CarManager(new EfCarDal());

            Console.WriteLine("Id: ");
            Console.WriteLine(carManager.Get(int.Parse(Console.ReadLine())).Data.Description);
        }
Example #7
0
        private static void CarUpdate()
        {
            CarManager carManager = new CarManager(new EfCarDal());

            CarList();
            Console.WriteLine("Güncellemek istediğiniz arabanın Id'si: ");
            int id        = int.Parse(Console.ReadLine());
            var carEntity = carManager.Get(id).Data;

            Console.WriteLine(carEntity.Id + " " + carEntity.BrandId + " " + carEntity.ColorId + " " + carEntity.ModelYear + " " + carEntity.DailyPrice + "TL Günlük " + carEntity.Description);
            Console.WriteLine("");
            BrandList();
            Console.Write("Brand Id Giriniz: ");
            carEntity.BrandId = int.Parse(Console.ReadLine());
            ColorList();
            Console.Write("\nColor Id Giriniz: ");
            carEntity.ColorId = int.Parse(Console.ReadLine());
            Console.Write("\nModel Yılını Giriniz: ");
            carEntity.ModelYear = int.Parse(Console.ReadLine());
            Console.Write("\nGünlük Ücret Giriniz: ");
            carEntity.DailyPrice = decimal.Parse(Console.ReadLine());
            Console.Write("\nAçıklama ekleyiniz: ");
            carEntity.Description = Console.ReadLine();
            carManager.Update(carEntity);
        }
Example #8
0
        private static void CarRental()
        {
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());
            CarManager      carManager      = new CarManager(new EfCarDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());

            var car      = carManager.Get(3);
            var customer = customerManager.Get(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.CarId,
                    CustomerId = customer.Data.CustomerId,
                    RentDate   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))
                });
                if (result.Success)
                {
                    Console.WriteLine(result.Message);
                }
                else
                {
                    Console.WriteLine(result.Message);
                }
            }
        }
Example #9
0
        private static void carUpdated(CarManager carManager)
        {
            var updatedCar = carManager.Get(1004);

            updatedCar.Data.Description = "BMW";
            updatedCar.Data.BrandId     = 1;
            updatedCar.Data.ColorId     = 1;
            updatedCar.Data.ModelYear   = 2021;
            updatedCar.Data.DailyPrice  = 2000;
            carManager.Update(updatedCar.Data);
            Console.WriteLine("Güncelleme işlemi tamamlandı.");
        }
Example #10
0
        private static void RentalTesst(RentalManager rentalManager, CarManager carManager)
        {
            var result = rentalManager.Add(new Rental()
            {
                CarId    = 2, ReturnDate = Convert.ToDateTime("01.01.1900"), CustomerId = 1,
                RentDate = Convert.ToDateTime("11.02.2021")
            });

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

            var result1 = carManager.Get(2);

            Console.WriteLine(result1.Data.Available);
            var result2 = rentalManager.FinishRental(rentalManager.Get(12).Data);

            if (result2.Success)
            {
                Console.WriteLine(result2.Message);
            }

            var result3 = rentalManager.GetRentalDetails();

            if (result3.Success)
            {
                foreach (var VARIABLE in result3.Data)
                {
                    Console.WriteLine(
                        "Rental Id:{0} Customer Id:{1} Company Name={2} Car Id:{3} Car Name:{4} Rent Date:{5} Return Date:{6}",
                        VARIABLE.RentalId, VARIABLE.CustomerId, VARIABLE.CompanyName, VARIABLE.CarId, VARIABLE.CarName,
                        VARIABLE.RentDate, VARIABLE.ReturnDate);
                }
            }
        }
Example #11
0
        private static void CarCrudMethods()
        {
            CarManager carManager = new CarManager(new EfCarDal());
            var        result     = carManager.GetAll();

            foreach (var car in result.Data)
            {
                Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", car.Id, car.BrandId, car.ColorId, car.CarName, car.ModelYear, car.DailyPrice, car.Descriptions);
            }
            Console.WriteLine("-------------------------------------------------------------------------");
            var carEntity = carManager.Get(3);

            Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", carEntity.Data.Id, carEntity.Data.BrandId, carEntity.Data.ColorId, carEntity.Data.CarName, carEntity.Data.ModelYear, carEntity.Data.DailyPrice, carEntity.Data.Descriptions);
            Console.WriteLine("-------------------------------------------------------------------------");
            carManager.Add(new Car {
                BrandId = 1, ColorId = 2, CarName = "Duster", DailyPrice = 238, ModelYear = "2018", Descriptions = "Benzinli"
            });
            foreach (var car in result.Data)
            {
                Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", car.Id, car.BrandId, car.ColorId, car.CarName, car.ModelYear, car.DailyPrice, car.Descriptions);
            }
            Console.WriteLine("-------------------------------------------------------------------------");
            carManager.Update(new Car {
                Id = 5, BrandId = 3, ColorId = 3, CarName = "Mazda6", DailyPrice = 578, ModelYear = "2009", Descriptions = "Dizel"
            });
            foreach (var car in result.Data)
            {
                Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", car.Id, car.BrandId, car.ColorId, car.CarName, car.ModelYear, car.DailyPrice, car.Descriptions);
            }
            Console.WriteLine("-------------------------------------------------------------------------");
            carManager.Delete(new Car {
                Id = 6, BrandId = 1, ColorId = 2, CarName = "Mazda6", DailyPrice = 238, ModelYear = "2018", Descriptions = "Benzinli"
            });
            foreach (var car in result.Data)
            {
                Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", car.Id, car.BrandId, car.ColorId, car.CarName, car.ModelYear, car.DailyPrice, car.Descriptions);
            }
        }
Example #12
0
        private static void CarTest()
        {
            List <Car> _cars = new List <Car>
            {
                new Car {
                    BrandId = 1, ColorId = 2, ModelYear = "2010", DailyPrice = 1500, Description = "Tüplu"
                },
                new Car {
                    BrandId = 1, ColorId = 3, ModelYear = "2012", DailyPrice = 170, Description = "Dizel"
                },
                new Car {
                    BrandId = 1, ColorId = 8, ModelYear = "2005", DailyPrice = 180, Description = "Tüplü"
                },
                new Car {
                    BrandId = 5, ColorId = 10, ModelYear = "2009", DailyPrice = 195, Description = "Arazi aracı"
                },
                new Car {
                    BrandId = 5, ColorId = 6, ModelYear = "2008", DailyPrice = 185, Description = "Tüplü"
                },
                new Car {
                    BrandId = 15, ColorId = 1, ModelYear = "2006", DailyPrice = 190, Description = "Arazi Aracı"
                },
                new Car {
                    BrandId = 10, ColorId = 10, ModelYear = "2010", DailyPrice = 210, Description = "Dizel"
                },
                new Car {
                    BrandId = 18, ColorId = 2, ModelYear = "2015", DailyPrice = 180, Description = "Benzinli"
                },
                new Car {
                    BrandId = 18, ColorId = 4, ModelYear = "2016", DailyPrice = 175, Description = "Arazi aracı"
                },
                new Car {
                    BrandId = 18, ColorId = 8, ModelYear = "2014", DailyPrice = 140, Description = "Tüplü"
                },
                new Car {
                    BrandId = 18, ColorId = 8, ModelYear = "2014", DailyPrice = 140, Description = "Arazi Aracı"
                },
                new Car {
                    BrandId = 18, ColorId = 8, ModelYear = "2014", DailyPrice = 140, Description = "Arazi Aracı"
                }
            };

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

            // ekleme bölümü
            foreach (var car in _cars)
            {
                carManager.Add(car);
            }

            // 4 nolu kaydın DailyPrice değeri 205 yerine 195 yazılmış düzeltilecek

            Car carToUpdate = new Car();

            carToUpdate.Id          = 4;
            carToUpdate.BrandId     = 5;
            carToUpdate.ColorId     = 10;
            carToUpdate.ModelYear   = "2009";
            carToUpdate.DailyPrice  = 205;
            carToUpdate.Description = "Arazi Aracı";

            carManager.Update(carToUpdate);

            // 11 ve 12 nolu kayıt örnek için mükerrer girildiğinden 12 nolu kayıt silinecek

            Car carToDelete = new Car();

            carToDelete.Id = 12;

            carManager.Delete(carToDelete);


            // Tüm araçları listeleme

            var result = carManager.GetAll();

            if (result.Success == true)
            {
                Console.WriteLine(String.Format("{0,-3} {1,-7}  {2,-7} {3,-15} {4,-10} {5,-10}", "Id", "BrandId", "ColorId", "Model Year", "DailyPrice", "Description"));
                foreach (var car in result.Data)
                {
                    Console.WriteLine(String.Format("{0,4} {1,4}  {2,4} {3,-10} {4,-10} {5,-10}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description));
                }
            }
            else
            {
                Console.WriteLine(result.Message);
            }


            result = carManager.GetCarsByBrandId(18);
            if (result.Success == true)
            {
                // BrandId si 18 olan tüm araçları listeleme
                Console.WriteLine(String.Format("{0,-3} {1,-7}  {2,-7} {3,-15} {4,-10} {5,-10}", "Id", "BrandId", "ColorId", "Model Year", "DailyPrice", "Description"));
                foreach (var car in result.Data)
                {
                    Console.WriteLine(String.Format("{0,4} {1,4}  {2,4} {3,-10} {4,-10} {5,-10}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description));
                }
            }
            else
            {
                Console.WriteLine(result.Message);
            }



            // ColorId  si 8 olan tüm araçları listeleme
            result = carManager.GetCarsByColorId(8);
            if (result.Success == true)
            {
                Console.WriteLine(String.Format("{0,-3} {1,-7}  {2,-7} {3,-15} {4,-10} {5,-10}", "Id", "BrandId", "ColorId", "Model Year", "DailyPrice", "Description"));
                foreach (var car in result.Data)
                {
                    Console.WriteLine(String.Format("{0,4} {1,4}  {2,4} {3,-10} {4,-10} {5,-10}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description));
                }
            }
            else
            {
                Console.WriteLine(result.Message);
            }

            // Id si 10 olan aracın bilgilerini getirme


            Console.WriteLine(String.Format("{0,-3} {1,-7}  {2,-7} {3,-15} {4,-10} {5,-10}", "Id", "BrandId", "ColorId", "Model Year", "DailyPrice", "Description"));


            var carToGet = carManager.Get(10);

            if (carToGet.Success == true)
            {
                {
                    Console.WriteLine(String.Format("{0,4} {1,4}  {2,4} {3,-10} {4,-10} {5,-10}", carToGet.Data.Id, carToGet.Data.BrandId, carToGet.Data.ColorId, carToGet.Data.ModelYear, carToGet.Data.DailyPrice, carToGet.Data.Description));
                }
            }
            else
            {
                Console.WriteLine(result.Message);
            }



            var crd = carManager.GetCarDetails();

            // Araç ile birlikte ve marka ve rengini getirme Dto örneği

            if (crd.Success == true)
            {
                Console.WriteLine(String.Format("{0,-4} {1,20}  {2,20} {3,-10} {4,-10} {5,-10}", "Id", "BrandName", "ColorName", "Model Year", "DailyPrice", "Description"));
                foreach (var car in crd.Data)
                {
                    Console.WriteLine(String.Format("{0,4} {1,20}  {2,20} {3,-10} {4,-10} {5,-10}", car.CarId, car.BrandName, car.ColorName, car.ModelYear, car.DailyPrice, car.Description));
                }
            }
            else
            {
                Console.WriteLine(result.Message);
            }

            // DailyPrice değeri 170 - 205 aralığında olan araçları getirme
            result = carManager.GetByDailyPrice(170, 205);
            if (result.Success == true)
            {
                Console.WriteLine(String.Format("{0,-4} {1,-4}  {2,-4} {3,-10} {4,-10} {5,-10}", "Id", "BrandId", "ColorId", "Model Year", "DailyPrice", "Description"));
                foreach (var car in result.Data)
                {
                    Console.WriteLine(String.Format("{0,4} {1,4}  {2,4} {3,-10} {4,-10} {5,-10}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description));
                }
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }