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()); RentalManager rentalManager = new RentalManager(new EfRentalDal()); UserManager userManager = new UserManager(new EfUserDal()); //Car car = new Car() { CarId = 16, BrandId = 1, ColorId = 1, DailyPrice = 222222, ModelYear = 2000, Description = "araba", CarName = "Örnek araba ismi" }; //Get Car Details Test //GetCarDetailsTest(carManager); //Get Customer Details test //GetCustomerDetailsTest(customerManager); //Get Rental Details test //GetRentalDetailsTest(rentalManager); //Get All Tests //GetAllCarTest(carManager); //GetAllBrandTest(brandManager); //GetAllColorTest(colorManager); //GetAllCustomerTest(customerManager); //GetAllRentalTest(rentalManager); //GetAllUserTest(userManager); //AddCarTest(carManager); //UpdateCarTest(carManager); //DeleteCarTest(carManager); //Get By Id Tests //GetCarByIdTest(carManager, 2); //GetBrandByIdTest(brandManager, 6); //GetColorByIdTest(colorManager, 1); //Get Cars By Color Id And Brand Id Tests //GetCarsByBrandIdTest(carManager); //GetCarsByColorIdTest(carManager); //Add, Update, Delete for Brand Tests //AddBrandTest(brandManager); //UpdateBrandTest(brandManager); //DeleteBrandTest(brandManager); //Add, Update, Delete for Color Tests //AddColorTest(colorManager); //UpdateColorTest(colorManager); //DeleteColorTest(colorManager); //Add, Update, Delete for Customer Tests //AddCustomerTest(customerManager); //UpdateCustomerTest(customerManager); //DeleteCustomerTest(customerManager); //Add, Update, Delete for Rental Tests //AddRentalTest(rentalManager); //UpdateRentalTest(rentalManager); //DeleteRentalTest(rentalManager); //Add, Update, Delete for User Tests //AddUserTest(userManager); //UpdateUserTest(userManager); //DeleteUserTest(userManager); //denemeler Console.ReadLine(); }
private static void CarUpdateTest(CarManager carManager) { carManager.Update(new Car { Id = 3, CarName = "i8", BrandId = 2, ColorId = 1, DailyPrice = 380, ModelYear = "2017", Description = "ikinci el" }); }
private static void CarAddTest(CarManager carManager) { carManager.Add(new Car { CarName = "Insignie", BrandId = 3, ColorId = 2, ModelYear = "2016", DailyPrice = 200, Description = "ikinci el" }); }
private static void CarGetByIdTest() { CarManager carManager = new CarManager(new EfCarDal()); Console.WriteLine(carManager.GetById(4)); }
static void Main(string[] args) { //Car car1 = new Car { CarId = 6, BrandId = 1, ColorId = 2, ModelYear = "2021", DailyPrice = 450, Description = "not6" }; //CarManager carManager = new CarManager(new InMemoryCarDal()); //Console.WriteLine("---------Kayıt Eklendi-------------"); //carManager.Add(car1); //foreach (var car in carManager.GetAll()) //{ // Console.WriteLine(car.CarId + " " + car.BrandId + " " + car.ColorId + " " + " " + car.ModelYear + " " + car.DailyPrice + " " + car.Description); //} //Console.WriteLine("---------Silme-------------"); //carManager.Delete(car1); //foreach (var car in carManager.GetAll()) //{ // Console.WriteLine(car.CarId + " " + car.BrandId + " " + car.ColorId + " " + " " + car.ModelYear + " " + car.DailyPrice + " " + car.Description); //} //Console.WriteLine("---------Guncelleme-------------"); //Car car2 = new Car { CarId = 3, BrandId = 3, ColorId = 1, ModelYear = "2012", DailyPrice = 225, Description = "Guncelleme işlemi yapıldı" }; //carManager.Update(car2); //foreach (var car in carManager.GetAll()) //{ // Console.WriteLine(car.CarId + " " + car.BrandId + " " + car.ColorId + " " + " " + car.ModelYear + " " + car.DailyPrice + " " + car.Description); //} //Console.WriteLine("---------Id e göre bilgi getirme-------------"); //foreach (var car in carManager.GetById(5)) //{ // Console.WriteLine(car.CarId + " " + car.BrandId + " " + car.ColorId + " " + " " + car.ModelYear + " " + car.DailyPrice + " " + car.Description); //} //Console.WriteLine("---------Car------------"); //CarManager carManager = new CarManager(new EfCarDal()); //foreach (var car in carManager.GetAll()) //{ // Console.WriteLine(car.CarId+"-"+car.ColorId+"-"+car.BrandId+"-"+car.ModelYear+"-"+car.DailyPrice+"-"+car.Description); //} //Console.WriteLine("---------Color------------"); //ColorManager colorManager = new ColorManager(new EfColorDal()); //foreach (var color in colorManager.GetAll()) //{ // Console.WriteLine(color.ColorId+"-"+color.Name); //} //Console.WriteLine("---------Brand------------"); //BrandManager brandManager = new BrandManager(new EfBrandDal()); //foreach (var brand in brandManager.GetAll()) //{ // Console.WriteLine(brand.BrandId + "-" + brand.Name); //} //Console.WriteLine("---------car-colorName-BrandName------------"); //foreach (var car in carManager.GetCarDetailDtos()) //{ // Console.WriteLine(car.CarId+"-"+car.ColorName+"-"+car.BrandName+"-"+car.DailPrice+"-"+car.Description); //} CarManager carManager = new CarManager(new EfCarDal()); var result = carManager.GetCarDetailDtos(); if (result.Success == true) { foreach (var car in result.Data) { Console.WriteLine(car.BrandName + "--" + car.ColorName); } } else { Console.WriteLine(result.Message); } RentalManager rentalManager = new RentalManager(new EfRentalDal()); var result1 = rentalManager.GetAll(); if (result1.Success == true) { foreach (var rental in result1.Data) { Console.WriteLine(rental.Id + "---" + rental.CarId + "---" + rental.CustomerId + "---" + rental.RentDate + "---" + rental.ReturnDate); } } var result3 = rentalManager.GetRentalDetailDtos(); if (result3.Success == true) { foreach (var ren in result3.Data) { Console.WriteLine(ren.CarId + "-" + ren.BrandName + "-" + ren.CarId + "-" + ren.FirsName + "-" + ren.LastName + "-" + ren.CompanyName); } Console.WriteLine(result3.Message); } Console.WriteLine("------------------------"); var result4 = carManager.GetAll(1); if (result4.Success == true) { foreach (var car in result4.Data) { Console.WriteLine(car.CarId + "--" + car.ColorId + "--" + car.BrandId + "--" + car.DailyPrice); } } Console.ReadKey(); }
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()); //CarDetails listeleme foreach (var carDetail in carManager.GetCarDetails().Data) { Console.WriteLine(carDetail.BrandName + " " + carDetail.Description + " " + carDetail.ColorName + " ==> " + carDetail.DailyPrice); } Console.WriteLine("------------------"); //Tüm araçların listesini yazdırıyoruz foreach (var car in carManager.GetAll().Data) { Console.WriteLine(car.ModelYear + " Model " + car.Description + " : " + car.DailyPrice + "TL"); } Console.WriteLine("---------- " + carManager.GetAll().Message + " --------"); //BrandId ye göre araç listeleme var carsByBrandId = carManager.GetCarsByBrandId(1); if (carsByBrandId.Success == true) { foreach (var car in carManager.GetCarsByBrandId(1).Data) { Console.WriteLine(car.Description); } } else { Console.WriteLine(carsByBrandId.Message); } Console.WriteLine("------------------------"); //ColorId ye göre araç listeleme var carsByColorId = carManager.GetCarsByColorId(2); if (carsByColorId.Success == true) { foreach (var car in carManager.GetCarsByColorId(2).Data) { Console.WriteLine(car.Description); } } else { Console.WriteLine(carsByColorId.Message); } //Marka listeleme ekleme, güncelleme ve silme Console.WriteLine("------------------------"); foreach (var brand in brandManager.GetAll().Data) { Console.WriteLine(brand.BrandName); } brandManager.Update(new Brand { BrandId = 4, BrandName = "Renault" }); brandManager.Add(new Brand { BrandName = "BMW" }); brandManager.Delete(new Brand { BrandId = 4 }); foreach (var brand in brandManager.GetAll().Data) { Console.WriteLine(brand.BrandName); } //Renk listeleme, ekleme, güncelleme ve silme foreach (var color in colorManager.GetAll().Data) { Console.WriteLine(color.ColorName); } colorManager.Add(new Color { ColorName = "Sarı" }); colorManager.Update(new Color { ColorId = 1, ColorName = "Kırmızı" }); colorManager.Delete(new Color { ColorId = 1002 }); //araç ekleme carManager.Add(new Car { BrandId = 2, ColorId = 2, ModelYear = 2019, DailyPrice = 520, Description = "Golf Dizel Otomatik" }); //araç Güncelleme carManager.Update(new Car { Id = 1, BrandId = 1, ColorId = 1, ModelYear = 2010, DailyPrice = 200, Description = "Corsa Benzinli Otomatik" }); //araç silme carManager.Delete(new Car { Id = 1006 }); //CarDetails listeleme var carDetails = carManager.GetCarDetails(); if (carDetails.Success == true) { foreach (var carDetail in carManager.GetCarDetails().Data) { Console.WriteLine(carDetail.BrandName + " " + carDetail.Description + " " + carDetail.ColorName + " ==> " + carDetail.DailyPrice); } } else { Console.WriteLine(carDetails.Message); } userManager.Add(new User { FirstName = "Serdar", LastName = "Bey", Email = "*****@*****.**", Password = "******" }); userManager.Add(new User { FirstName = "Mustafa", LastName = "Bey", Email = "*****@*****.**", Password = "******" }); userManager.Add(new User { FirstName = "Merve", LastName = "Ceylan", Email = "*****@*****.**", Password = "******" }); foreach (var item in userManager.GetAll().Data) { Console.WriteLine(item.FirstName + " " + item.LastName); } userManager.Update(new User { UserId = 3, FirstName = "Merve", LastName = "Ceylan", Email = "*****@*****.**", Password = "******" }); customerManager.Add(new Customer { UserId = 2, CustomerName = "İpekyolu" }); rentalManager.Return(2); rentalManager.Add(new Rental { CarId = 3, CustomerId = 3, RentDate = DateTime.Now, }); rentalManager.Return(3); rentalManager.Return(4); }
private static void AddCarTestEntityFramework(Car car) { CarManager carManager = new CarManager(new EfCarDal()); carManager.Add(car); }
private void CarMenuScreen(CarManager carManager, BrandManager brandManager, ColorManager colorManager) { bool IsMenuOpen = true; while (IsMenuOpen) { Console.WriteLine("\n--------- ADMIN MENU ---------"); Console.WriteLine(" 1 - Add New Car"); Console.WriteLine(" 2 - Update a Car"); Console.WriteLine(" 3 - Delete a Car"); Console.WriteLine(" 4 - View Cars by Brand Id"); Console.WriteLine(" 5 - View Cars by Color Id"); Console.WriteLine(" 6 - View the List of Cars"); Console.WriteLine(" 7 - Go back to Main Menu"); Console.WriteLine("------------------------------"); string choice = Console.ReadLine(); if (choice == "") { Console.WriteLine("Wrong! Try again."); } else { switch (Int32.Parse(choice)) { case 1: CarMenu_Save(carManager); Console.WriteLine("Count of All Cars: " + carManager.GetCountOfAll()); break; case 2: CarMenu_Update(carManager); Console.WriteLine("Count of All Cars: " + carManager.GetCountOfAll()); break; case 3: CarMenu_Delete(carManager); Console.WriteLine("Count of All Cars: " + carManager.GetCountOfAll()); break; case 4: CarMenu_GetCarsByBrandId(carManager, brandManager); break; case 5: CarMenu_GetCarsByColorId(carManager, colorManager); break; case 6: if (carManager.GetCountOfAll() != 0) { Console.WriteLine("\nList of All Cars"); carManager.WriteAllCarDetails(carManager.GetAllCarDetails().Data); } Console.WriteLine("Count of All Cars: " + carManager.GetCountOfAll()); break; case 7: IsMenuOpen = false; break; default: Console.WriteLine("Wrong! Try again."); break; } } } }
private void RentalMenu_Save(RentalManager rentalManager, CustomerManager customerManager, CarManager carManager) { Console.WriteLine("Please enter the information of the new rental."); Console.WriteLine("\nList of All Cars"); carManager.WriteAll(carManager.GetAll().Data); Console.Write("Car ID: "); int CarId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\nList of All Customers"); customerManager.WriteAll(customerManager.GetAll().Data); Console.Write("Customer ID: "); int CustomerId = Convert.ToInt32(Console.ReadLine()); rentalManager.Add(new Rental { CarId = CarId, CustomerId = CustomerId, RentDate = DateTime.Now, ReturnDate = null }); }
public void MainScreen() { BrandManager brandManager = new BrandManager(new EFBrandDal()); ColorManager colorManager = new ColorManager(new EFColorDal()); CarManager carManager = new CarManager(new EFCarDal(), brandManager); CustomerManager customerManager = new CustomerManager(new EFCustomerDal()); UserManager userManager = new UserManager(new EFUserDal()); RentalManager rentalManager = new RentalManager(new EFRentalDal()); bool IsMainMenuOpen = true; while (IsMainMenuOpen) { Console.WriteLine("\n-------- MAIN MENU --------"); Console.WriteLine(" 1 - Car"); Console.WriteLine(" 2 - Brand"); Console.WriteLine(" 3 - Color"); Console.WriteLine(" 4 - Customer"); Console.WriteLine(" 5 - User"); Console.WriteLine(" 6 - Rental"); Console.WriteLine(" 7 - Exit"); Console.WriteLine("-----------------------------"); string choice = Console.ReadLine(); if (choice == "") { Console.WriteLine("Wrong! Try again."); } else { switch (Int32.Parse(choice)) { case 1: CarMenuScreen(carManager, brandManager, colorManager); IsMainMenuOpen = true; break; case 2: BrandMenuScreen(brandManager, carManager); IsMainMenuOpen = true; break; case 3: ColorMenuScreen(colorManager, carManager); IsMainMenuOpen = true; break; case 4: CustomerMenuScreen(customerManager, userManager); IsMainMenuOpen = true; break; case 5: UserMenuScreen(userManager, customerManager); IsMainMenuOpen = true; break; case 6: RentalMenuScreen(rentalManager, customerManager, carManager); IsMainMenuOpen = true; break; case 7: IsMainMenuOpen = false; break; default: break; } } } Console.WriteLine("\nGoodbye.."); }
private void RentalMenuScreen(RentalManager rentalManager, CustomerManager customerManager, CarManager carManager) { bool IsMenuOpen = true; while (IsMenuOpen) { Console.WriteLine("\n--------- ADMIN MENU ---------"); Console.WriteLine(" 1 - Add New Rental "); Console.WriteLine(" 2 - Update a Rental"); Console.WriteLine(" 3 - Delete a Rental"); Console.WriteLine(" 4 - View Rental List"); Console.WriteLine(" 5 - Go back to Main Menu"); Console.WriteLine("------------------------------"); string choice = Console.ReadLine(); if (choice == "") { Console.WriteLine("Wrong! Try again."); } else { switch (Int32.Parse(choice)) { case 1: RentalMenu_Save(rentalManager, customerManager, carManager); Console.WriteLine("Count of All Rentals: " + rentalManager.GetCountOfAll()); break; case 2: RentalMenu_Update(rentalManager, customerManager, carManager); Console.WriteLine("Count of All Rentals: " + rentalManager.GetCountOfAll()); break; case 3: RentalMenu_Delete(rentalManager); Console.WriteLine("Count of All Rentals: " + rentalManager.GetCountOfAll()); break; case 4: if (rentalManager.GetCountOfAll() != 0) { Console.WriteLine("\nList of All Rentals"); rentalManager.WriteAll(rentalManager.GetAll().Data); } Console.WriteLine("Count of All Rentals: " + rentalManager.GetCountOfAll()); break; case 5: IsMenuOpen = false; break; default: Console.WriteLine("Wrong! Try again."); break; } } } }
private static void TestCar() { CarManager carManager = new CarManager(new EfCarDal()); Car car1 = new Car { CarName = "Mercedes E200", BrandId = 1, ColorId = 1, ModelYear = 2015, DailyPrice = 350, Description = "Siyah Mercedes E200" }; Car car2 = new Car { CarName = "BMW M4", BrandId = 2, ColorId = 2, ModelYear = 2017, DailyPrice = 500, Description = "Kırmızı BMW M4" }; Car car3 = new Car { CarName = "BMW 520i", BrandId = 2, ColorId = 1, ModelYear = 2014, DailyPrice = 250, Description = "Siyah BMW 520i" }; Car car4 = new Car { CarName = "Audi A6", BrandId = 3, ColorId = 5, ModelYear = 2012, DailyPrice = 150, Description = "Gri Audi A6" }; Car car5 = new Car { CarName = "Volvo S60", BrandId = 4, ColorId = 3, ModelYear = 2015, DailyPrice = 700, Description = "Mavi Volvo S60" }; Console.WriteLine("----------GetAll----------"); foreach (var car in carManager.GetAll().Data) { Console.WriteLine(car.CarName); } Console.WriteLine("----------GetById----------"); var result = carManager.GetById(1); Console.WriteLine(result.Data.CarName); Console.WriteLine("----------Add----------"); carManager.Add(car5); foreach (var car in carManager.GetAll().Data) { Console.WriteLine(car.CarName); } Console.WriteLine("----------Update----------"); carManager.Update(new Car { Id = 1002, BrandId = 4, CarName = "Volvo 2", ColorId = 3, ModelYear = 2015, DailyPrice = 700, Description = "Güncellenmiş Volvo" }); foreach (var car in carManager.GetAll().Data) { Console.WriteLine(car.CarName); } Console.WriteLine("----------Delete----------"); Car car6 = new Car { Id = 7, CarName = "BMW 520i", BrandId = 2, ColorId = 1, ModelYear = 2014, DailyPrice = 250, Description = "Siyah BMW 520i" }; carManager.Delete(car6); foreach (var car in carManager.GetAll().Data) { Console.WriteLine(car.CarName); } foreach (var car in carManager.GetCarDetails().Data) { Console.WriteLine("{0} - {1} - {2} - {3}", car.CarName, car.BrandName, car.ColorName, car.DailyPrice); } }
static void Main(string[] args) { //CarManager carManager = new CarManager(new InMemoryCarDal()); //BrandManager brandManager = new BrandManager(new InMemoryBrandDal()); CarManager carManager = new CarManager(new EfCarDal()); BrandManager brandManager = new BrandManager(new EfBrandDal()); ColorManager colorManager = new ColorManager(new EfColorDal()); Console.Clear(); List <string> menuItems = new List <string>() { "Yeni Araç Kayıt", "Araç Silme İşlemi", "Tüm Araçları Listele", "Araç Bilgisi Güncelle", "Yeni Marka Girişi", "Marka Silme İşlemi", "Tüm Markaları Listele", "Model Yıllarına Göre Listele", "Fiyatına Göre Listele", "Çıkış" }; Console.CursorVisible = false; while (true) { string selectedMenuItem = drawMainMenu(menuItems); if (selectedMenuItem == "Yeni Araç Kayıt") { AddCar(carManager, brandManager, colorManager); } else if (selectedMenuItem == "Araç Silme İşlemi") { DeleteCar(carManager, brandManager); } else if (selectedMenuItem == "Tüm Araçları Listele") { ListCars(carManager); } else if (selectedMenuItem == "Araç Bilgisi Güncelle") { UpdateCar(carManager, brandManager); } else if (selectedMenuItem == "Yeni Marka Girişi") { AddBrand(brandManager); } else if (selectedMenuItem == "Marka Silme İşlemi") { DeleteBrand(brandManager); } else if (selectedMenuItem == "Tüm Markaları Listele") { ListBrands(brandManager); } else if (selectedMenuItem == "Model Yıllarına Göre Listele") { ListByModelYear(carManager, brandManager); } else if (selectedMenuItem == "Fiyatına Göre Listele") { ListByPrice(carManager, brandManager); } else if (selectedMenuItem == "Çıkış") { Environment.Exit(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()); bool islem = true; while (islem) { Console.WriteLine("----------Rent A Car----------" + "\n 1.Araba Ekleme\n" + "\n 2.Araba Güncelleme\n" + "\n 3.Araba Silme\n" + "\n 4.Arabaların Listelenmesi\n" + "\n 5.Detaylı Listelenme\n" + "\n 6.Arabaların Id'sine Göre Listelenmesi\n" + "\n 7.Marka Id'sine Göre Listenlenmesi\n" + "\n 8.Renk Id'sine Göre Listelenmesi\n" + "\n 9.Kullanıcı Ekle\n" + "\n 10.Kullanıcı Sil\n" + "\n 11.Kullanıcı Güncelle\n" + "\n 12.Kullanıcı Listesi\n" + "\n 13.Müşteri Ekle\n" + "\n 14.Müşteri Sil\n" + "\n 15.Müşteri Güncelle\n" + "\n 16.Müşteri Listesi\n" + "\n 17.Araç Kirala\n" + "\n 18.Kiralanmış Araç Bilgilerini Güncelle\n" + "\n 19.Kiralanmış Araç Listesi\n" + "\n 20.Islem\n\n" + "Yukarıdakilerden hangisi işlemi gerçekleştirmek istiyorusunuz?" ); int sayi = Convert.ToInt32(Console.ReadLine()); switch (sayi) { case 1: //Console.WriteLine("Color Listesi"); //GetAllColor(colorManager); //Console.WriteLine("Brand Listesi"); //GetAllBrand(brandManager); Console.WriteLine("Car Name:"); string carNameAdd = Console.ReadLine(); Console.WriteLine("Brand Id:"); int brandIdAdd = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Color Id:"); int colorIdAdd = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Model Year:"); string modelYearAdd = Console.ReadLine(); Console.WriteLine("Daily Price:"); int dailyPriceAdd = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Description:"); string descriptionAdd = Console.ReadLine(); Car carAdd = new Car { CarName = carNameAdd, BrandId = brandIdAdd, ColorId = colorIdAdd, ModelYear = modelYearAdd, DailyPrice = dailyPriceAdd, Description = descriptionAdd }; var result = carManager.Add(carAdd); if (result.Success == true) { carManager.Add(carAdd); } else { Console.WriteLine(result.Message); } islem = false; break; case 2: GetAllCarDetails(carManager); Console.WriteLine("Car Id:"); int carIdUpdate = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Car Name:"); string carNameUpdate = Console.ReadLine(); Console.WriteLine("Color Id:"); int colorIdUpdate = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Brand Id:"); int brandIdUpdate = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Model Year:"); string modelYearUpdate = Console.ReadLine(); Console.WriteLine("Daily Price:"); int dailyPriceUpdate = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Description:"); string descriptionUpdate = Console.ReadLine(); Car carUpdate = new Car { Id = carIdUpdate, CarName = carNameUpdate, ColorId = colorIdUpdate, BrandId = brandIdUpdate, ModelYear = modelYearUpdate, DailyPrice = dailyPriceUpdate, Description = descriptionUpdate }; carManager.Update(carUpdate); break; case 3: GetAllCarDetails(carManager); Console.WriteLine("Hangi Id'ye sahip arabayı silmek istersin"); int carIdDelete = Convert.ToInt32(Console.ReadLine()); carManager.Delete(carManager.GetById(carIdDelete).Data); break; case 4: Console.WriteLine("Arabaların Listelenmesi: \nId\tColor Name\tBrand Name\tModel Year\tDaily Price\t Description"); GetAllCarDetails(carManager); break; case 5: Console.WriteLine("Arabaların Listelenmesi: \nId\tColor Name\tBrand Name\tModel Year\tDaily Price\t Description"); GetAllCarDetails(carManager); islem = false; break; case 6: GetAllCarDetails(carManager); Console.WriteLine("Görmek istediğiniz Id numarasını giriniz? "); int carId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine($"\n Id'si {carId} olan araba: \nId\tColor Name\tBrand Name\tModel Year \tDaily Price\tDescription"); Car carById = carManager.GetById(carId).Data; Console.WriteLine($"{carById.Id}\t{colorManager.GetById(carById.ColorId).ColorName}\t\t{brandManager.GetById(carById.BrandId).BrandName}\t\t{carById.ModelYear}\t\t{carById.DailyPrice}\t\t{carById.Description}"); break; case 7: GetAllBrand(brandManager); Console.WriteLine("Hangi markaya sahip arabayı görmek istiyorsunuz? Lütfen bir Id numarası yazınız."); int brandIdForCarList = Convert.ToInt32(Console.ReadLine()); Console.WriteLine($"\n\nBrand Id'si {brandIdForCarList} olan arabalar: \nId\tColor Name\tBrand Name\tModel Year\tDaily Price\tDescriptions"); foreach (var car in carManager.GetCarsByBrandId(brandIdForCarList).Data) { Console.WriteLine($"{car.Id}\t{car.CarName}\t{colorManager.GetById(car.ColorId).ColorName}\t\t{brandManager.GetById(car.BrandId).BrandName}\t\t{car.ModelYear}\t\t{car.DailyPrice}\t\t{car.Description}"); } break; case 8: GetAllColor(colorManager); Console.WriteLine("Hangi renge sahip arabayı görmek istiyorsunuz? Lütfen bir Id numarası yazınız."); int colorIdForCarList = Convert.ToInt32(Console.ReadLine()); Console.WriteLine($"\n\nColor Id'si {colorIdForCarList} olan arabalar: \nId\tColor Name\tBrand Name\tModel Year\tDaily Price\tDescriptions"); foreach (var car in carManager.GetCarsByColorId(colorIdForCarList).Data) { Console.WriteLine($"{car.Id}\t{car.CarName}\t{colorManager.GetById(car.ColorId).ColorName}\t\t{brandManager.GetById(car.BrandId).BrandName}\t\t{car.ModelYear}\t\t{car.DailyPrice}\t\t{car.Description}"); } break; case 9: string ad, soyad, email, password; Console.WriteLine("Kullanıcı adı giriniz."); ad = Console.ReadLine(); Console.WriteLine("Kullanıcı soyadı giriniz."); soyad = Console.ReadLine(); Console.WriteLine("Email giriniz."); email = Console.ReadLine(); Console.WriteLine("Şifre giriniz."); password = Console.ReadLine(); User user = new User { FirstName = ad, LastName = soyad, Email = email, Password = password }; userManager.Add(user); Console.WriteLine("Kullanıcı başarıyla eklendi."); break; case 10: int id = 0; Console.WriteLine("Silmek istediğiniz kullanıcının Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); User user2 = new User { Id = id }; userManager.Delete(user2); Console.WriteLine("Kullanıcı başarıyla silindi."); break; case 11: int id2 = 0; string ad2, soyad2, email2, password2; Console.WriteLine("Güncellemek istediğiniz kullanıcının Id değerini giriniz."); id2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Kullanıcı adı giriniz."); ad2 = Console.ReadLine(); Console.WriteLine("Kullanıcı soyadı giriniz."); soyad2 = Console.ReadLine(); Console.WriteLine("Email giriniz."); email2 = Console.ReadLine(); Console.WriteLine("Şifre giriniz."); password2 = Console.ReadLine(); User user3 = new User { FirstName = ad2, LastName = soyad2, Email = email2, Password = password2 }; userManager.Update(user3); Console.WriteLine("Kullanıcı bilgileri başarıyla güncellenmiştir."); break; case 12: foreach (var user4 in userManager.GetAll().Data) { Console.WriteLine("Id:" + user4.Id + "/" + user4.FirstName + "/" + user4.LastName + "/" + user4.Email + "/" + user4.Password); Console.WriteLine("---------------------------------------------"); } break; case 13: int userId; string companyName; Console.WriteLine("Eklemek istediğiniz müşterinin kullanıcı Id değerini giriniz."); userId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Şirket adını giriniz."); companyName = Console.ReadLine(); Customer customer = new Customer { UserId = userId, CompanyName = companyName }; customerManager.Add(customer); Console.WriteLine("Müşteri başarıyla eklendi."); break; case 14: int id3 = 0; Console.WriteLine("Silmek istediğiniz müşterinin Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); Customer customer2 = new Customer { Id = id3 }; customerManager.Delete(customer2); Console.WriteLine("Müşteri başarıyla silindi."); break; case 15: int userId2, id4; string companyName2; Console.WriteLine("Güncellemek istediğiniz müşterinin Id değerini giriniz."); id4 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Güncellemek istediğiniz müşterinin kullanıcı Id değerini giriniz."); userId2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Şirket adını giriniz."); companyName2 = Console.ReadLine(); Customer customer3 = new Customer { Id = id4, UserId = userId2, CompanyName = companyName2 }; customerManager.Update(customer3); Console.WriteLine("Müşteri bilgileri başarıyla güncellendi."); break; case 16: foreach (var customer4 in customerManager.GetCustomerDetails().Data) { Console.WriteLine("Id:" + customer4.Id + "/" + customer4.FirstName + "/" + customer4.LastName + "/" + customer4.Email + "/" + customer4.Password + "/" + customer4.CompanyName); Console.WriteLine("---------------------------------------------"); } break; case 17: DateTime rentDate, returnDate; int carId2 = 0, customerId = 0; Console.WriteLine("Kiralamak istediğiniz aracın Id değerini giriniz."); carId2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Kiralamak istediğiniz müşterinin Id değerini giriniz."); customerId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Başlangıç tarihini giriniz."); rentDate = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Bitiş tarihini giriniz."); returnDate = DateTime.Parse(Console.ReadLine()); Rental rental = new Rental { CarId = carId2, CustomerId = customerId, RentDate = rentDate, ReturnDate = returnDate }; var result2 = rentalManager.Add(rental); if (result2.Success) { rentalManager.Add(rental); } break; case 18: DateTime rentDate2, returnDate2; int carId3 = 0, customerId2 = 0; Console.WriteLine("Güncellemek istediğiniz aracın Id değerini giriniz."); carId3 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Güncelemek istediğiniz müşterinin Id değerini giriniz."); customerId2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Başlangıç tarihini giriniz."); rentDate2 = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Bitiş tarihini giriniz."); returnDate2 = DateTime.Parse(Console.ReadLine()); Rental rental2 = new Rental { CarId = carId3, CustomerId = customerId2, RentDate = rentDate2, ReturnDate = returnDate2 }; var result3 = rentalManager.Update(rental2); if (result3.Success) { rentalManager.Update(rental2); } break; case 19: Console.WriteLine("**************Kiralanmış Araç Listesi**************"); foreach (var rentalDto in rentalManager.GetRentalDetails().Data) { Console.WriteLine("Id:" + rentalDto.Id + "/" + rentalDto.FirstName + "/" + rentalDto.LastName + "/" + rentalDto.RentDate + "/" + rentalDto.RentDate + "/" + rentalDto.BrandName + "/" + rentalDto.ColorName + "/" + rentalDto.ModelYear + "/" + rentalDto.DailyPrice + "/" + rentalDto.Description + "/" + rentalDto.CompanyName); Console.WriteLine("---------------------------------------------"); } break; case 20: islem = false; Console.WriteLine("Çıkış işlemi gerçekleşti."); break; } } }
private static void Test(ColorManager colorManager, BrandManager brandManager, CarManager carManager) { Brand brand = new Brand { Id = 0, BrandName = "marka1", }; brandManager.AddOrEdit(brand); brand.Id = 0; brand.BrandName = "marka1"; brandManager.AddOrEdit(brand); brand.Id = 0; brand.BrandName = "marka2"; brandManager.AddOrEdit(brand); Car car = new Car { Id = 0, BrandId = brandManager.Get(b => b.BrandName == "Marka1").Data.Id, ColorId = colorManager.Get(c => c.ColorName == "Siyah").Data.Id, ModelYear = Convert.ToDateTime("03.02.1999"), DailyPrice = 3700, Description = "Araç birin açıklaması" }; carManager.AddOrEdit(car); car.Id = 0; car.BrandId = brandManager.Get(b => b.BrandName == "Marka2").Data.Id; car.ColorId = colorManager.Get(c => c.ColorName == "Kirmizi").Data.Id; car.ModelYear = Convert.ToDateTime("03.02.2000"); car.DailyPrice = 4900; car.Description = "Araç ikinin açıklaması"; carManager.AddOrEdit(car); car.Id = 0; car.BrandId = brandManager.Get(b => b.BrandName == "Marka3").Data.Id; car.ColorId = colorManager.Get(c => c.ColorName == "Sari").Data.Id; car.ModelYear = Convert.ToDateTime("03.02.1988"); car.DailyPrice = 8000; car.Description = "Araç üçün açıklaması"; carManager.AddOrEdit(car); var CarList = from c in carManager.GetAll().Data join b in brandManager.GetAll().Data on c.BrandId equals b.Id join clr in colorManager.GetAll().Data on c.ColorId equals clr.Id select new CarDTO { Id = c.Id, BrandName = b.BrandName, ColorName = clr.ColorName, ColorsHexCode = clr.HexCode, DailyPrice = c.DailyPrice, Description = c.Description, ModelYear = c.ModelYear.Year }; foreach (CarDTO carDTO in CarList) { Console.WriteLine($"Id: {carDTO.Id}, " + $"Marka Adı: {carDTO.BrandName}, " + $"Rengi: {carDTO.ColorName}, " + $"Renk Hex Kodu: {carDTO.ColorsHexCode}, " + $"Günlük Fiyatı: {carDTO.DailyPrice}, " + $"Açıklama: {carDTO.Description}, " + $"Model Yılı: {carDTO.ModelYear}\n"); } }
private void RentalMenu_Update(RentalManager rentalManager, CustomerManager customerManager, CarManager carManager) { Console.WriteLine("\nList of All Rentals"); rentalManager.WriteAll(rentalManager.GetAll().Data); bool IsExist = false; int searchID = 0; while (!IsExist) { Console.Write("-> Enter the ID of the rental you want to update: "); searchID = Convert.ToInt32(Console.ReadLine()); IsExist = rentalManager.IsExistById(searchID).Success; if (!IsExist) { Console.Write(Messages.ColorNotExist + " Try again. Rental ID: "); searchID = Convert.ToInt32(Console.ReadLine()); IsExist = rentalManager.IsExistById(searchID).Success; } } if (!rentalManager.IsReturn(searchID).Success) { Console.WriteLine(Messages.CarNotReturn); bool isUpdated = false; int choice = 0; while (!isUpdated) { Console.Write("Is it delivered right now? (1) Yes, (2) No : "); choice = Convert.ToInt32(Console.ReadLine()); if (choice == 1) { var rental = rentalManager.GetById(searchID).Data; rentalManager.Update(new Rental { Id = searchID, CarId = rental.CarId, CustomerId = rental.CustomerId, RentDate = rental.RentDate, ReturnDate = DateTime.Now }); isUpdated = true; } else if (choice == 2) { Console.WriteLine("No update."); isUpdated = true; } else { Console.WriteLine("Wrong! Try again."); } } } else { Console.WriteLine("Update is not available. The rental process is already completed."); } }
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()); bool cikis = true; while (cikis) { Console.WriteLine( "Rent A Car \n---------------------------------------------------------------" + "\n\n1.Araba Ekleme\n" + "2.Araba Silme\n" + "3.Araba Güncelleme\n" + "4.Arabaların Listelenmesi\n" + "5.Arabaların detaylı bir şekilde Listelenmesi\n" + "6.Arabaların Marka Id'sine göre Listelenmesi\n" + "7.Arabaların Renk Id'sine göre Listelenmesi\n" + "8.Araba Id'sine göre Listeleme\n" + "9.Arabaların fiyat aralığına göre Listelenmesi\n" + "10.Arabaların model yılına göre Listelenmesi\n" + "11.Müşteri Ekleme\n" + "12.Müşterilerin Listelenmesi\n" + "13.Kullanıcı Ekleme\n" + "14.Kullanıcıların Listelenmesi\n" + "15.Araba Kiralama\n" + "16.Araba Teslim Etme\n" + "17.Araba Kiralama Listesi\n" + "18.Çıkış\n" + "Yukarıdakilerden hangi işlemi gerçekleştirmek istiyorsunuz ?" ); int number = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\n---------------------------------------------------------------\n"); switch (number) { case 1: CarAddition(carManager, brandManager, colorManager); break; case 2: GetAllCarDetails(carManager); CarDeletion(carManager); break; case 3: GetAllCarDetails(carManager); CarUpdate(carManager); break; case 4: GetAllCar(carManager); break; case 5: GetAllCarDetails(carManager); break; case 6: GetAllBrand(brandManager); CarListByBrand(carManager); break; case 7: GetAllColor(colorManager); CarListByColor(carManager); break; case 8: GetAllCarDetails(carManager); CarById(carManager, brandManager, colorManager); break; case 9: CarByDailyPrice(carManager, brandManager, colorManager); break; case 10: GetAllCarDetails(carManager); CarByModelYear(carManager, brandManager, colorManager); break; case 11: GetAllUserList(userManager); CustomerAddition(customerManager); break; case 12: GetAllCustomerList(customerManager); break; case 13: UserAddition(userManager); break; case 14: GetAllUserList(userManager); break; case 15: GetAllCarDetails(carManager); GetAllCustomerList(customerManager); RentalAddition(rentalManager); break; case 16: ReturnRental(rentalManager); break; case 17: GetAllRentalDetailList(rentalManager); break; case 18: cikis = false; Console.WriteLine("Çıkış işlemi gerçekleşti."); break; } } }
static void Main(string[] args) { CarManager carManager = new CarManager(new EfCarDal()); BrandManager brandManager = new BrandManager(new EfBrandDal()); CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); Customer customer1 = new Customer { CompanyName = "RentCarX", UserId = 1 }; Customer customer2 = new Customer { CompanyName = "RentCarY", UserId = 2 }; Brand newBrand = new Brand() { BrandName = "Doblo", BrandId = 6 }; //brandManager.AddNewBrandToDb(newBrand); //brandManager.DeleteBrandToDb(newBrand); Car newcar = new Car() { CarId = 6, CarName = "Doblo A", BrandId = 6, ColorId = 2, DailyPrice = 162, Description = "Tosbağa", ModelYear = 2000 }; //carManager.Add(newcar); var result = carManager.GetCarDetails(); if (result.Success == true) { foreach (var car in result.Data) { Console.WriteLine("Car Name: {0}\nBrand Name: {1}\n,Color Name: Black,Daily Price: {3}\n*****************", car.CarName, car.BrandName, car.DailyPrice); Console.WriteLine(result.Message + "FGSAHYFLGDAUG"); } } else { Console.WriteLine(result.Message); } //carManager.Add(new Car { CarName = "Renault", BrandId = 2, ColorId = 3, ModelYear = 1992, DailyPrice = 110, Description = "oldbutgold",Id = 4 }); //DailyPrice(carManager); }
static void Main(string[] args) { Car car1 = new Car() { CarId = 5, BrandId = 4, ColorId = 3, DailyPrice = 300, ModelYear = 2020, Description = "BMW 3.2" }; Car car2 = new Car() { CarId = 5, BrandId = 4, ColorId = 3, DailyPrice = 100, ModelYear = 2020, Description = "B" }; CarManager carManager = new CarManager(new EfCarDal()); Rental rental = new Rental { Id = 5, CarId = 1, CustomerId = 2, }; RentalTest(rental); CarTest(); Console.WriteLine("----------------------"); GetCarDetailTest(); Console.WriteLine("----------------------"); BrandTest(1); Console.WriteLine("----------------------"); ColorTest(); //AddCarTestEntityFramework(car1); //car1.Description = "Yeni Model İsmi: BMW 3.2"; //UpdateCarTestEntityFramework(car1); //AddTestInMemory(); //var MarkayaGöreSorgu = carManager.GetCarsByBrandId(2); //foreach (var car in MarkayaGöreSorgu) //{ // Console.WriteLine(car.Description); //} //Console.WriteLine("----------------------"); //var RengeGöreSorgu = carManager.GetCarsByColorId(1); //foreach (var car in RengeGöreSorgu) //{ // Console.WriteLine(car.Description); //} //Console.WriteLine("----------------------"); //carManager.Delete(car1); //Console.WriteLine("----------------------"); //carManager.Add(car2); }
static void Main(string[] args) { Console.WriteLine("RENT A CAR PROJECT"); Console.WriteLine(""); 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()); Brand bmwBrand = new Brand() { Id = 1, Name = "BMW" }; //brandManager.Add(bmwBrand); Brand mercedesBrand = new Brand() { Id = 2, Name = "Mercedes-Benz" }; //brandManager.Add(mercedesBrand); Brand audiBrand = new Brand() { Id = 3, Name = "Audi" }; //brandManager.Add(audiBrand); Brand volkswagenBrand = new Brand() { Id = 4, Name = "Volkswagen" }; //brandManager.Add(volkswagenBrand); Brand seatBrand = new Brand() { Id = 5, Name = "Seat" }; //brandManager.Add(seatBrand); Brand renaultBrand = new Brand() { Id = 6, Name = "Renault" }; //brandManager.Add(renaultBrand); Brand hyundaiBrand = new Brand() { Id = 7, Name = "Hyundai" }; //brandManager.Add(hyundaiBrand); //*************************************************************************************************************************************** Color beyazColor = new Color() { Id = 1, Name = "Beyaz" }; //colorManager.Add(beyazColor); Color siyahColor = new Color() { Id = 2, Name = "Siyah" }; //colorManager.Add(siyahColor); Color griColor = new Color() { Id = 3, Name = "Gri" }; //colorManager.Add(griColor); Color maviColor = new Color() { Id = 4, Name = "Mavi" }; //colorManager.Add(maviColor); Color kırmızıColor = new Color() { Id = 5, Name = "Kırmızı" }; //colorManager.Add(kırmızıColor); Color sarıColor = new Color() { Id = 6, Name = "Sarı" }; //colorManager.Add(sarıColor); Car car1 = new Car() { Id = 1, BrandId = 1, ColorId = 2, DailyPrice = 1499, Description = "E60 M5 / Otomatik Vites", ModelYear = 2008 }; //carManager.Update(car1); //UpdateTest(car1, carManager); Car car2 = new Car() { Id = 2, BrandId = 4, ColorId = 1, DailyPrice = 299, Description = "Passat / Otomatik Vites", ModelYear = 2015 }; //carManager.Update(car2); Car car3 = new Car() { Id = 3, BrandId = 5, ColorId = 5, DailyPrice = 249, Description = "Leon / Otomatik Vites", ModelYear = 2008 }; //carManager.Update(car3); Car car4 = new Car() { Id = 4, BrandId = 3, ColorId = 2, DailyPrice = 699, Description = "A6 / Otomatik Vites", ModelYear = 2019 }; //carManager.Update(car4); Car car5 = new Car() { Id = 5, BrandId = 3, ColorId = 3, DailyPrice = 449, Description = "A5 / Otomatik Vites", ModelYear = 2018 }; //carManager.Update(car5); customerManager.Add(new Customer { UserId = 1, CompanyName = "ABCD COMPANY" }); //**************************************************************************************************************** //GetAllTest(carManager); //GetCarDetailsTest(carManager); Console.ReadLine(); }
private static void UpdateCarTestEntityFramework(Car car1) { CarManager carManager = new CarManager(new EfCarDal()); carManager.Update(car1); }
private static void UpdateTest(Car car1, CarManager carManager) { car1.Description = "BMW E60 M5 / Otomatik"; carManager.Update(car1); }
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"); }
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()); Tekrar: Console.WriteLine("********Rent A Car Sistemine Hoşgeldiniz********"); Console.WriteLine("1-)Kiralık Araç Listesi"); Console.WriteLine("2-)Marka Listesi"); Console.WriteLine("3-)Renk Listesi"); Console.WriteLine("4-)Kiralık Araç Ekle"); Console.WriteLine("5-)Marka Ekle"); Console.WriteLine("6-)Renk Ekle"); Console.WriteLine("7-)Araç Sil"); Console.WriteLine("8-)Araç Bilgisi Güncelleştir"); Console.WriteLine("9-)Fiyat Aralığındaki Araç Listesi"); Console.WriteLine("10-)Fiyata Göre Artan Araç Listesi"); Console.WriteLine("11-)Fiyata Göre Azalan Araç Listesi"); Console.WriteLine("12-)Marka Güncelle"); Console.WriteLine("13-)Renk Güncelle"); Console.WriteLine("14-)Kullanıcı Ekle"); Console.WriteLine("15-)Kullanıcı Sil"); Console.WriteLine("16-)Kullanıcı Güncelle"); Console.WriteLine("17-)Kullanıcı Listesi"); Console.WriteLine("18-)Müşteri Ekle"); Console.WriteLine("19-)Müşteri Sil"); Console.WriteLine("20-)Müşteri Güncelle"); Console.WriteLine("21-)Müşteri Listesi"); Console.WriteLine("22-)Araç Kirala"); Console.WriteLine("23-)Kiralanmış Araç Bilgilerini Güncelle"); Console.WriteLine("24-)Kiralanmış Araç Listesi"); Console.WriteLine("25-)Araç Teslim Et"); Console.WriteLine("26-)Programı Sonlandır"); string anaMenu; int secim = 0; try { secim = Convert.ToInt32(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Yanlış karakter girdiniz !"); } switch (secim) { case 1: { var result = carManager.GetCarDetails(); if (result.Success) { Console.WriteLine("**************Araç Listesi**************"); foreach (var carDto in carManager.GetCarDetails().Data) { Console.WriteLine("Id:" + carDto.Id + "/" + carDto.BrandName + "/" + carDto.ColorName + "/" + carDto.ModelYear + "/" + carDto.DailyPrice + "/" + carDto.Description); Console.WriteLine("---------------------------------------------"); } } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 2: { var result = brandManager.GetAll(); if (result.Success) { Console.WriteLine("******************Marka Listesi******************"); foreach (var brand in brandManager.GetAll().Data) { Console.WriteLine("Id:" + brand.Id + "/" + brand.BrandName); Console.WriteLine("---------------------------------------------"); } } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 3: { Console.WriteLine("******************Renk Listesi******************"); var result = colorManager.GetAll(); if (result.Success) { foreach (var color in colorManager.GetAll().Data) { Console.WriteLine("Id:" + color.Id + "/" + color.ColorName); Console.WriteLine("---------------------------------------------"); } } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 4: { string modelYear, description; int brand = 0, color = 0, dailyPrice = 0; Console.WriteLine("Eklemek istediğiniz aracın bilgilerini giriniz"); Console.WriteLine("Markanın BrandId değerini giriniz."); brand = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Rengin ColorId değerini giriniz"); color = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Model yılınız giriniz"); modelYear = Console.ReadLine(); Console.WriteLine("Kiralama ücretini giriniz"); dailyPrice = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Açıklama giriniz"); description = Console.ReadLine(); Car car1 = new Car { BrandId = brand, ColorId = color, ModelYear = modelYear, DailyPrice = dailyPrice, Description = description }; carManager.Add(car1); Console.WriteLine("Araç başarılı bir şekilde sistem tarafından eklendi."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 5: { string marka; Console.WriteLine("Eklemek istediğiniz markayı yazınız"); marka = Console.ReadLine(); Brand brand1 = new Brand { BrandName = marka }; brandManager.Add(brand1); Console.WriteLine("Marka ekleme işlemi başarılı şekilde yapıldı."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 6: { string renk; Console.WriteLine("Eklemek istediğiniz rengi yazınız"); renk = Console.ReadLine(); Color color1 = new Color { ColorName = renk }; colorManager.Add(color1); Console.WriteLine("Renk ekleme işlemi başarılı şekilde yapıldı."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 7: { int id = 0; Console.WriteLine("Silmek istediğiniz aracın Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); Car car2 = new Car { Id = id }; carManager.Delete(car2); Console.WriteLine("Silme işlemi başarıyla tamamlandı."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 8: { string modelYear, description; int brand = 0, color = 0, dailyPrice = 0, id = 0; Console.WriteLine("Güncellemek istediğiniz aracın bilgilerini giriniz"); Console.WriteLine("Güncellemek istediğiniz aracın Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Markanın BrandId değerini giriniz."); brand = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Rengin ColorId değerini giriniz"); color = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Model yılınız giriniz"); modelYear = Console.ReadLine(); Console.WriteLine("Kiralama ücretini giriniz"); dailyPrice = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Açıklama giriniz"); description = Console.ReadLine(); Car car1 = new Car { Id = id, BrandId = brand, ColorId = color, ModelYear = modelYear, DailyPrice = dailyPrice, Description = description }; Console.WriteLine("Güncelleştirme işlemi başarıyla tamamlandı"); carManager.Update(car1); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 9: { int minMoney = 0, maxMoney = 0; Console.WriteLine("Kiralamak istediğiniz değer aralığını giriniz."); Console.WriteLine("Minumum ücreti giriniz."); minMoney = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Maxiumum ücreti giriniz."); 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.Id + "/" + brandManager.GetById(i.BrandId).Data.BrandName + "/" + colorManager.GetById(i.ColorId).Data.ColorName + "/" + i.ModelYear + "/" + i.DailyPrice + "/" + i.Description); } } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 10: { var result = carManager.GetCarAsc(); if (result.Success) { foreach (var asc in carManager.GetCarAsc().Data) { Console.WriteLine("Id:" + asc.Id + "/" + asc.BrandName + "/" + asc.ColorName + "/" + asc.ModelYear + "/" + asc.DailyPrice + "/" + asc.Description); } } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 11: { var result = carManager.GetCarDesc(); if (result.Success) { foreach (var desc in carManager.GetCarDesc().Data) { Console.WriteLine("Id:" + desc.Id + "/" + desc.BrandName + "/" + desc.ColorName + "/" + desc.ModelYear + "/" + desc.DailyPrice + "/" + desc.Description); } } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 12: { string marka; int id = 0; Console.WriteLine("Id"); id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Yeni markayı yazınız"); marka = Console.ReadLine(); Brand brand1 = new Brand { Id = id, BrandName = marka }; brandManager.Update(brand1); Console.WriteLine("Marka güncelleme işlemi başarılı şekilde yapıldı."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 13: { string renk; int id = 0; Console.WriteLine("Güncellemek istediğiniz rengin Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Yeni rengi yazınız"); renk = Console.ReadLine(); Color color1 = new Color { Id = id, ColorName = renk }; colorManager.Update(color1); Console.WriteLine("Renk güncelleme işlemi başarılı şekilde yapıldı."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 14: { string ad, soyad, email; byte[] password; Console.WriteLine("Kullanıcı adı giriniz."); ad = Console.ReadLine(); Console.WriteLine("Kullanıcı soyadı giriniz."); soyad = Console.ReadLine(); Console.WriteLine("Email giriniz."); email = Console.ReadLine(); Console.WriteLine("Şifre giriniz."); password = Convert.FromBase64String(Console.ReadLine()); User user = new User { FirstName = ad, LastName = soyad, Email = email, PasswordHash = password }; userManager.Add(user); Console.WriteLine("Kullanıcı başarıyla eklendi."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 15: { int id = 0; Console.WriteLine("Silmek istediğiniz kullanıcının Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); User user = new User { Id = id }; userManager.Delete(user); Console.WriteLine("Kullanıcı başarıyla silindi."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 16: { int id = 0; string ad, soyad, email; byte[] password; Console.WriteLine("Güncellemek istediğiniz kullanıcının Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Kullanıcı adı giriniz."); ad = Console.ReadLine(); Console.WriteLine("Kullanıcı soyadı giriniz."); soyad = Console.ReadLine(); Console.WriteLine("Email giriniz."); email = Console.ReadLine(); Console.WriteLine("Şifre giriniz."); password = Convert.FromBase64String(Console.ReadLine()); User user = new User { FirstName = ad, LastName = soyad, Email = email, PasswordHash = password }; userManager.Update(user); Console.WriteLine("Kullanıcı bilgileri başarıyla güncellenmiştir."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 17: { foreach (var user in userManager.GetAll().Data) { Console.WriteLine("Id:" + user.Id + "/" + user.FirstName + "/" + user.LastName + "/" + user.Email + "/" + user.PasswordHash); Console.WriteLine("---------------------------------------------"); } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 18: { int userId; string companyName; Console.WriteLine("Eklemek istediğiniz müşterinin kullanıcı Id değerini giriniz."); userId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Şirket adını giriniz."); companyName = Console.ReadLine(); Customer customer = new Customer { UserId = userId, CompanyName = companyName }; customerManager.Add(customer); Console.WriteLine("Müşteri başarıyla eklendi."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 19: { int id = 0; Console.WriteLine("Silmek istediğiniz müşterinin Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); Customer customer = new Customer { Id = id }; customerManager.Delete(customer); Console.WriteLine("Müşteri başarıyla silindi."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 20: { int userId, id; string companyName; Console.WriteLine("Güncellemek istediğiniz müşterinin Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Güncellemek istediğiniz müşterinin kullanıcı Id değerini giriniz."); userId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Şirket adını giriniz."); companyName = Console.ReadLine(); Customer customer = new Customer { Id = id, UserId = userId, CompanyName = companyName }; customerManager.Update(customer); Console.WriteLine("Müşteri bilgileri başarıyla güncellendi."); Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 21: { foreach (var customer in customerManager.GetCustomerDetails().Data) { Console.WriteLine("Id:" + customer.Id + "/" + customer.FirstName + "/" + customer.LastName + "/" + customer.Email + "/" + customer.Password + "/" + customer.CompanyName); Console.WriteLine("---------------------------------------------"); } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 22: { DateTime rentDate, returnDate; int carId = 0, customerId = 0; Console.WriteLine("Kiralamak istediğiniz aracın Id değerini giriniz."); carId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Kiralamak istediğiniz müşterinin Id değerini giriniz."); customerId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Başlangıç tarihini giriniz."); rentDate = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Bitiş tarihini giriniz."); returnDate = DateTime.Parse(Console.ReadLine()); Rental rental = new Rental { CarId = carId, CustomerId = customerId, RentDate = rentDate, ReturnDate = returnDate }; var result2 = rentalManager.GetById(carId); if (result2.Success) { Console.WriteLine("Bu araç zaten kiralandı."); } else { rentalManager.Add(rental); } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 23: { DateTime rentDate, returnDate; int carId = 0, customerId = 0; Console.WriteLine("Güncellemek istediğiniz aracın Id değerini giriniz."); carId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Güncelemek istediğiniz müşterinin Id değerini giriniz."); customerId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Başlangıç tarihini giriniz."); rentDate = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Bitiş tarihini giriniz."); 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("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 24: { Console.WriteLine("**************Kiralanmış Araç Listesi**************"); foreach (var rentalDto in rentalManager.GetRentalDetails().Data) { Console.WriteLine("Id:" + rentalDto.Id + "/" + rentalDto.FirstName + "/" + rentalDto.LastName + "/" + rentalDto.RentDate + "/" + rentalDto.RentDate + "/" + rentalDto.BrandName + "/" + rentalDto.ColorName + "/" + rentalDto.ModelYear + "/" + rentalDto.DailyPrice + "/" + rentalDto.Description + "/" + rentalDto.CompanyName); Console.WriteLine("---------------------------------------------"); } break; } case 25: { int carId, id; Console.WriteLine("Teslim etmek istediğiniz kiralık araç Id değerini giriniz."); id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Teslim etmek istediğiniz aracın Id değerini giriniz."); carId = Convert.ToInt32(Console.ReadLine()); Rental rental = new Rental { Id = id, CarId = carId }; var result = rentalManager.GetById(carId); if (result.Success) { rentalManager.Delete(rental); } else { Console.WriteLine("Böyle bir araç kaydı bulunmamaktadır."); } Console.WriteLine("Ana menüye dönmek ister misiniz? Evet==e||Hayır==h"); anaMenu = Console.ReadLine(); if (anaMenu == "e") { goto Tekrar; } break; } case 26: { Console.WriteLine("Bir tuşa basın..."); Environment.Exit(0); break; } default: { Console.WriteLine("Yanlış seçim lütfen tekrar deneyiniz !"); goto Tekrar; } } }
private static void CarUpdateTest(CarManager carManager) { carManager.Update(new Car { CarId = 2, CarName = "Civicc", BrandId = 4, ColorId = 9, DailyPrice = 300, Description = "CİVİC 1.6 ELEGANCE,Benzinli,Otomatik Vites", ModelYear = 2016 }); }
private static void CarManager() { CarManager carManager = new CarManager(new EfCarDal()); Console.WriteLine("---------- ARABA LİSTESİ ----------------"); foreach (var car in carManager.GetAll().Data) { Console.WriteLine("{0} : {1} : {2} : {3} : {4} : {5}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description); } Car car1 = new Car { BrandId = 1, ColorId = 2, DailyPrice = 800, ModelYear = "2020", Description = "A8 kaskolu" }; carManager.Add(car1); Console.WriteLine(car1.Description + " Eklendi"); Console.WriteLine("---------- ARABA LİSTESİ ----------------"); foreach (var car in carManager.GetAll().Data) { Console.WriteLine("{0} : {1} : {2} : {3} : {4} : {5}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description); } carManager.Delete(car1); Console.WriteLine(car1.Description + " Silindi"); Console.WriteLine("---------- ARABA LİSTESİ ----------------"); foreach (var car in carManager.GetAll().Data) { Console.WriteLine("{0} : {1} : {2} : {3} : {4} : {5}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description); } Car car2 = new Car { Id = 1, BrandId = 1, ColorId = 2, DailyPrice = 700, ModelYear = "2018", Description = "A8 kaskosuz" }; carManager.Update(car2); Console.WriteLine(car1.Description + " Güncellendi."); Console.WriteLine("---------- ARABA LİSTESİ ----------------"); foreach (var car in carManager.GetAll().Data) { Console.WriteLine("{0} : {1} : {2} : {3} : {4} : {5}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description); } Console.WriteLine("---------- ARABA DETAYLARI (JOIN) -----------------"); foreach (var car in carManager.GetCarDetails().Data) { Console.WriteLine("{0} : {1} : {2} : {3}", car.Description, car.BrandName, car.ColorName, car.DailyPrice); } }
private static void CarDeleteTest(CarManager carManager) { carManager.Delete(new Car { Id = 2 }); }
private static void CarDtoTest(BrandManager brandManager, ColorManager colorManager, CarManager carManager) { Car car = new Car { Id = 0, BrandId = brandManager.Get(b => b.BrandName == "Marka1").Data.Id, ColorId = colorManager.Get(c => c.ColorName == "Siyah").Data.Id, ModelYear = Convert.ToDateTime("03.02.1999"), DailyPrice = 3700, Description = "Araç birin açıklaması" }; carManager.AddOrEdit(car); car.Id = 0; car.BrandId = brandManager.Get(b => b.BrandName == "Marka2").Data.Id; car.ColorId = colorManager.Get(c => c.ColorName == "Kirmizi").Data.Id; car.ModelYear = Convert.ToDateTime("03.02.2000"); car.DailyPrice = 4900; car.Description = "Araç ikinin açıklaması"; carManager.AddOrEdit(car); car.Id = 0; car.BrandId = brandManager.Get(b => b.BrandName == "Marka3").Data.Id; car.ColorId = colorManager.Get(c => c.ColorName == "Sari").Data.Id; car.ModelYear = Convert.ToDateTime("03.02.1988"); car.DailyPrice = 8000; car.Description = "Araç üçün açıklaması"; carManager.AddOrEdit(car); car.Id = 0; car.BrandId = brandManager.Get(b => b.BrandName == "Marka4").Data.Id; car.ColorId = colorManager.Get(c => c.ColorName == "Beyaz").Data.Id; car.ModelYear = Convert.ToDateTime("03.02.1988"); car.DailyPrice = 8000; car.Description = ""; carManager.AddOrEdit(car); car.Id = 0; car.BrandId = brandManager.Get(b => b.BrandName == "Marka5").Data.Id; car.ColorId = colorManager.Get(c => c.ColorName == "Siyah").Data.Id; car.ModelYear = Convert.ToDateTime("03.02.1988"); car.DailyPrice = 0; car.Description = "Araç beşin açıklaması"; carManager.AddOrEdit(car); foreach (CarDTO carDTO in carManager.GetCarDetails().Data) { Console.WriteLine($"Id: {carDTO.Id}, " + $"Marka Adı: {carDTO.BrandName}, " + $"Rengi: {carDTO.ColorName}, " + $"Renk Hex Kodu: {carDTO.ColorsHexCode}, " + $"Günlük Fiyatı: {carDTO.DailyPrice}, " + $"Açıklama: {carDTO.Description}, " + $"Model Yılı: {carDTO.ModelYear}\n"); } }
static void Main(string[] args) { CarManager carManager = new CarManager(new EfCarDal()); ColorManager colorManager = new ColorManager(new EfColorDal()); BrandManager brandManager = new BrandManager(new EfBrandDal()); Car car1 = new Car() { Id = 1, BrandId = 2, ColorId = 5, ModelYear = 2015, DailyPrice = 265, Description = "Reno Clio Campus 2007" }; Car car2 = new Car() { Id = 2, BrandId = 1, ColorId = 1, ModelYear = 2017, DailyPrice = 350, Description = "Temiz Ford Connect 2017" }; Car car3 = new Car() { Id = 3, BrandId = 2, ColorId = 3, ModelYear = 2005, DailyPrice = 150, Description = "Az km'li BMW x5 2005" }; Car car4 = new Car() { Id = 4, BrandId = 3, ColorId = 2, ModelYear = 2021, DailyPrice = 650, Description = "Sıfır Fiat Egea Sedan" }; Car car5 = new Car() { Id = 5, BrandId = 4, ColorId = 6, ModelYear = 2013, DailyPrice = 250, Description = "Sahibinden Ford focus 2013" }; Car car6 = new Car() { Id = 6, BrandId = 5, ColorId = 4, ModelYear = 2009, DailyPrice = 180, Description = "İkinci el wolkswagen Golf" }; Color c1 = new Color() { ColorId = 1, ColorName = "Beyaz" }; Color c2 = new Color() { ColorId = 2, ColorName = "Siyah" }; Color c3 = new Color() { ColorId = 3, ColorName = "Platinum" }; Color c4 = new Color() { ColorId = 4, ColorName = "Gri" }; Color c5 = new Color() { ColorId = 5, ColorName = "Lacivert" }; Color c6 = new Color() { ColorId = 6, ColorName = "Kırmızı" }; Brand b1 = new Brand() { BrandId = 1, BrandName = "Ford" }; Brand b2 = new Brand() { BrandId = 2, BrandName = "BMW" }; Brand b3 = new Brand() { BrandId = 3, BrandName = "Fiat" }; Brand b4 = new Brand() { BrandId = 4, BrandName = "Wolkswagen" }; Brand b5 = new Brand() { BrandId = 5, BrandName = "Renault" }; colorManager.Add(c1); colorManager.Add(c2); colorManager.Add(c3); colorManager.Add(c4); colorManager.Add(c5); colorManager.Add(c6); brandManager.Add(b1); brandManager.Add(b2); brandManager.Add(b3); brandManager.Add(b4); brandManager.Add(b5); carManager.Add(car1); carManager.Add(car2); carManager.Add(car3); carManager.Add(car4); carManager.Add(car5); foreach (Car car in carManager.GetAll().Data) { Console.WriteLine("Id:{0} - Description:{1} - Daily Price:{2}", car.Id, car.Description, car.DailyPrice); } Console.WriteLine("------------------------"); carManager.Add(car6); Console.WriteLine("After Adding car has Id 6"); foreach (Car car in carManager.GetAll().Data) { Console.WriteLine("Id:{0} - Description:{1} - Daily Price:{2}", car.Id, car.Description, car.DailyPrice); } Console.WriteLine("------------------------"); carManager.Delete(car1); Console.WriteLine("After Deleting Car has Id 1"); foreach (Car car in carManager.GetAll().Data) { Console.WriteLine("Id:{0} - Description:{1} - Daily Price:{2}", car.Id, car.Description, car.DailyPrice); } Console.WriteLine("------------------------"); car3.DailyPrice = 90; carManager.Update(car3); Console.WriteLine("After Updating car has id 3 with making DailyPrice 90"); foreach (Car car in carManager.GetAll().Data) { Console.WriteLine("Id:{0} - Description:{1} - Daily Price:{2}", car.Id, car.Description, car.DailyPrice); } Console.WriteLine("------------------------"); Console.WriteLine("GetCarDetails:"); foreach (var c in carManager.GetCarDetails().Data) { Console.WriteLine(" Car Name:{0} \n Brand Name:{1} \n Color Name {2} \n Daily Price:{3}\n\n", c.CarName, c.BrandName, c.ColorName, c.DailyPrice); } Console.WriteLine("------------------------"); Console.ReadLine(); colorManager.Delete(c1); colorManager.Delete(c2); colorManager.Delete(c3); colorManager.Delete(c4); colorManager.Delete(c5); colorManager.Delete(c6); carManager.Delete(car2); carManager.Delete(car3); carManager.Delete(car4); carManager.Delete(car5); carManager.Delete(car6); brandManager.Delete(b1); brandManager.Delete(b2); brandManager.Delete(b3); brandManager.Delete(b4); brandManager.Delete(b5); Console.ReadLine(); }
static void Main(string[] args) { //CarManager carManager = InMemoryTest(); CarManager carManager = new CarManager(new EfCarDal()); //CarTest(carManager); Console.WriteLine("***EF Database'de olan arabalar CarDetailsDto'ya göre gösterildi***"); //CarGetAll(carManager); Console.WriteLine(carManager.GetAll().Message); Console.WriteLine("\n***BrandId'a göre ve ColorId'ye göre getirme****"); Console.WriteLine("*color'a göre"); //CarGetByColorId(carManager); Console.WriteLine(carManager.GetCarsByColorId(1).Message); Console.WriteLine("*brand'a göre"); //CarGetByBrandId(carManager); Console.WriteLine(carManager.GetCarsByBrandId(1).Message); BrandManager brandManager = new BrandManager(new EfBrandDal()); //BrandAddTest(brandManager); Console.WriteLine("\n***Marka Listesi***"); //GetBrands(brandManager); Console.WriteLine(brandManager.GetAll().Message); ColorManager colorManager = new ColorManager(new EfColorDal()); //ColorAddTest(colorManager); Console.WriteLine("\n***Renk Listesi***"); //GetColors(colorManager); Console.WriteLine(colorManager.GetAll().Message); Console.WriteLine("\n***Kullanıcılar Oluşturuldu***"); UserManager userManager = new UserManager(new EfUserDal()); //UsersTest(userManager); Console.WriteLine(userManager.GetAll().Message); Console.WriteLine("\n***Müşteriler Oluşturuldu***"); CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); //CustomersTest(customerManager); Console.WriteLine(customerManager.GetAll().Message); // CarTest(carManager); Console.WriteLine("\n***Kiralama Oluşturuldu***"); RentalManager rentalManager = new RentalManager(new EfRentalDal()); RentalsTest(rentalManager); var datasonuc = rentalManager.GetRentDetails().Data; foreach (var rental in datasonuc) { //Console.WriteLine("rental id: " + rental.RentalId + " - car description:" + rental.CarDescription + " - company name:" + rental.CampanyName + " - rentdate:" + rental.RentDate + " - returndate:" + rental.ReturnDate); Console.WriteLine($"rental id: {rental.RentalId} - car description: {rental.CarDescription} - company name:{rental.CampanyName}- rentdate: { rental.RentDate} - returndate: { rental.ReturnDate}"); } }