private static void Bolum2() { CarManager carManager = new CarManager(new EFCarDal()); BrandManager brandManager = new BrandManager(new EFBrandDal()); ColorManager colorManager = new ColorManager(new EFColorDal()); #region BrandCRUDOperation //Sakın ID yazma.Çünkü primary key ve kendisi otomatik yapıyor! Brand addBrand = new Brand() { BrandName = "Nissan" }; brandManager.Add(addBrand); Brand updateBrand = new Brand() { Id = 1005, BrandName = "Nissanssss" }; brandManager.Update(updateBrand); Brand deleteBrand = new Brand() { Id = 1005, BrandName = "Nissanssss" }; brandManager.Delete(deleteBrand); foreach (var brands in brandManager.GetAll().Data) { Console.WriteLine(brands.BrandName); } #endregion #region ColorCRUDOperation Color addColor = new Color() { ColorName = "Vişne Çürüğü" }; colorManager.Add(addColor); Color updateColor = new Color() { Id = 1002, ColorName = "Elma Kırmızısı" }; colorManager.Update(updateColor); Color deleteColor = new Color() { Id = 1002, ColorName = "Elma Kırmızısı" }; colorManager.Delete(deleteColor); foreach (var color in colorManager.GetAll().Data) { Console.WriteLine(color.ColorName); } #endregion #region CarCRUDOperation Car car1 = new Car() { BrandId = 2, ColorId = 3, DailyPrice = 100, ModelYear = "2006", Descriptions = "Tofaş - Dizel" }; carManager.Add(car1); Car car2 = new Car() { Id = 8, BrandId = 2, ColorId = 3, DailyPrice = 85, ModelYear = "2007", Descriptions = "Renault/Kangoo - Manuel Benzin" }; carManager.Update(car2); Car deleteCar = new Car() { Id = 1002, BrandId = 2, ColorId = 3, DailyPrice = 100, ModelYear = "2006", Descriptions = "Tofaş - Dizel" }; carManager.Delete(deleteCar); var result = carManager.GetAll(); if (result.Success != true) { foreach (var car in result.Data) { Console.WriteLine(car.Descriptions); } } else { Console.WriteLine(result.Message); } #endregion #region DTOUsing DtoUsing(carManager); #endregion }
private static void BrandDeleteTest(BrandManager brandManager) { brandManager.Delete(new Brand { BrandId = 6 }); }
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 { Id = 4, BrandName = "Renault" }); brandManager.Add(new Brand { BrandName = "BMW" }); brandManager.Delete(new Brand { Id = 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 { Id = 1, ColorName = "Kırmızı" }); colorManager.Delete(new Color { Id = 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 { Id = 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); }
static void Main(string[] args) { CarManager carManager = new CarManager(new EfCarDal()); ColorManager colorManager = new ColorManager(new EfColorDal()); BrandManager brandManager = new BrandManager(new EfBrandDal()); UserManager userManager = new UserManager(new EfUserDal()); CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); RentalManager rentalManager = new RentalManager(new EfRentalDal()); Console.WriteLine("1- Araba ekle"); Console.WriteLine("2- Araba güncelle"); Console.WriteLine("3- Araba sil"); Console.WriteLine("4- Marka Ekle"); Console.WriteLine("5- Marka Güncelle"); Console.WriteLine("6- Marka Sil"); Console.WriteLine("7- Renk Ekle"); Console.WriteLine("8- Renk Güncelle"); Console.WriteLine("9- Renk Sil"); Console.WriteLine("10- Arabaları Listele"); Console.WriteLine("11- Markaları Listele"); Console.WriteLine("12- Renkleri Listele"); Console.WriteLine("13- Kullanıcı Ekle"); Console.WriteLine("14- Müşteri Ekle"); Console.WriteLine("15- Araba Kirala"); Console.Write("Yapmak istediğiniz işlemi seçin:"); var selectedOperation = Convert.ToInt32(Console.ReadLine()); switch (selectedOperation) { case 1: var carToAdd = new Car(); Console.Write("Marka Id: "); carToAdd.BrandId = Convert.ToInt32(Console.ReadLine()); Console.Write("Renk Id: "); carToAdd.ColorId = Convert.ToInt32(Console.ReadLine()); Console.Write("Model yılı: "); carToAdd.ModelYear = Convert.ToInt16(Console.ReadLine()); Console.Write("Günlük fiyat: "); carToAdd.DailyPrice = Convert.ToDecimal(Console.ReadLine()); Console.Write("Araba ismi: "); carToAdd.Description = Console.ReadLine(); var result = carManager.Add(carToAdd); Console.WriteLine(result.Message); break; case 2: ListAllCars(carManager); Console.Write("Güncellemek istediğiniz arabayı seçiniz: "); var selectedId = Convert.ToInt32(Console.ReadLine()); var carToUpdate = carManager.GetCarById(selectedId); Console.Write("Marka Id: "); carToUpdate.Data.BrandId = Convert.ToInt32(Console.ReadLine()); Console.Write("Renk Id: "); carToUpdate.Data.ColorId = Convert.ToInt32(Console.ReadLine()); Console.Write("Model yılı: "); carToUpdate.Data.ModelYear = Convert.ToInt16(Console.ReadLine()); Console.Write("Günlük fiyat: "); carToUpdate.Data.DailyPrice = Convert.ToDecimal(Console.ReadLine()); Console.Write("Araba ismi: "); carToUpdate.Data.Description = Console.ReadLine(); result = carManager.Update(carToUpdate.Data); Console.WriteLine(result.Message); break; case 3: ListAllCars(carManager); Console.Write("Silmek istediğiniz arabayı seçiniz:"); selectedId = Convert.ToInt32(Console.ReadLine()); var carToDelete = carManager.GetCarById(selectedId); result = carManager.Delete(carToDelete.Data); Console.WriteLine(result.Message); break; case 4: Console.Write("Marka adı:"); var brand = new Brand(); brand.Name = Console.ReadLine(); result = brandManager.Add(brand); Console.WriteLine(result.Message); break; case 5: ListAllBrands(brandManager); Console.Write("Güncellemek istediğiniz markayı seçiniz: "); selectedId = Convert.ToInt32(Console.ReadLine()); var brandToUpdate = brandManager.GetBrandById(selectedId); Console.Write("Marka Adı: "); brandToUpdate.Data.Name = Console.ReadLine(); result = brandManager.Update(brandToUpdate.Data); Console.WriteLine(result.Message); break; case 6: ListAllBrands(brandManager); Console.Write("Silmek istediğiniz markayı seçiniz: "); selectedId = Convert.ToInt32(Console.ReadLine()); var brandToDelete = brandManager.GetBrandById(selectedId); result = brandManager.Delete(brandToDelete.Data); Console.WriteLine(result.Message); break; case 7: Console.Write("Renk adı:"); var color = new Color(); color.Name = Console.ReadLine(); result = colorManager.Add(color); Console.WriteLine(result.Message); break; case 8: ListAllColors(colorManager); Console.Write("Güncellemek istediğiniz rengi seçiniz: "); selectedId = Convert.ToInt32(Console.ReadLine()); var colorToUpdate = colorManager.GetColorById(selectedId); Console.Write("Renk Adı: "); colorToUpdate.Data.Name = Console.ReadLine(); result = colorManager.Update(colorToUpdate.Data); Console.WriteLine(result.Message); break; case 9: ListAllColors(colorManager); Console.Write("Silmek istediğiniz rengi seçiniz: "); selectedId = Convert.ToInt32(Console.ReadLine()); var colorToDelete = colorManager.GetColorById(selectedId); result = colorManager.Delete(colorToDelete.Data); Console.WriteLine(result.Message); break; case 10: ListAllCars(carManager); break; case 11: ListAllBrands(brandManager); break; case 12: ListAllColors(colorManager); break; case 13: var userToAdd = new User(); Console.Write("Kullanıcı adı: "); userToAdd.FirstName = Console.ReadLine(); Console.Write("Kullanıcı soyadı: "); userToAdd.LastName = Console.ReadLine(); Console.Write("E-posta adresi: "); userToAdd.Email = Console.ReadLine(); Console.Write("Şifre: "); userToAdd.Password = Console.ReadLine(); result = userManager.Add(userToAdd); Console.WriteLine(result.Message); break; case 14: ListAllUsers(userManager); Console.Write("Müşteri olacak kullanıcıyı seçiniz: "); selectedId = Convert.ToInt32(Console.ReadLine()); var selectedUser = userManager.GetUserById(selectedId).Data; var customerToAdd = new Customer(); customerToAdd.UserId = selectedUser.Id; Console.Write("Şirket adı: "); customerToAdd.CompanyName = Console.ReadLine(); result = customerManager.Add(customerToAdd); Console.WriteLine(result.Message); break; case 15: ListAllCars(carManager); Console.Write("Kiralanacak arabayı seçiniz: "); var selectedCar = Convert.ToInt32(Console.ReadLine()); result = rentalManager.CheckCarRentalStatus(selectedCar); if (result.Success) { Console.WriteLine(result.Message); } else { Console.WriteLine(result.Message); break; } ListAllCustomers(customerManager); Console.Write("Kiralayacak müşteriyi seçiniz: "); var selectedCustomer = Convert.ToInt32(Console.ReadLine()); var rentalToAdd = new Rental(); rentalToAdd.CarId = selectedCar; rentalToAdd.CustomerId = selectedCustomer; rentalToAdd.RentDate = DateTime.Now; var rentalResult = rentalManager.Add(rentalToAdd); Console.WriteLine(rentalResult.Message); break; } }
private static void CarColorBrandExamples() { CarManager carManager1 = new CarManager(new EfCarDal()); ColorManager colorManager1 = new ColorManager(new EfColorDal()); BrandManager brandManager1 = new BrandManager(new EfBrandDal()); Console.WriteLine("---Color GetAll"); foreach (var color in colorManager1.GetAll().Data) { Console.WriteLine("ColorId:{0}, ColorName:{1}", color.ColorId, color.ColorName); } Console.WriteLine("\n---Brand GetAll"); foreach (var brand in brandManager1.GetAll().Data) { Console.WriteLine("BrandId:{0}, BrandName:{1}", brand.BrandId, brand.BrandName); } Console.WriteLine("\n---Car GetAll"); foreach (var car in carManager1.GetAll().Data) { Console.WriteLine("CarId:{0}, BrandId:{1}, ColorId:{2}, ModelName:{3}, ModelYear:{4}, DailyPrice:{5}, Description:{6}", car.CarId, car.BrandId, car.ColorId, car.ModelName, car.ModelYear, car.DailyPrice, car.Description); } Console.WriteLine("\n---GetCarDetails"); foreach (var car in carManager1.GetCarDetails().Data) { Console.WriteLine("CarId:{0}, BrandName:{1}, ColorName:{2}, ModelName:{3}, ModelYear:{4}, DailyPrice:{5}, Description:{6}", car.CarId, car.BrandName, car.ColorName, car.ModelName, car.ModelYear, car.DailyPrice, car.Description); } Console.WriteLine("\n---GetById(6)"); var resultCarGetById = carManager1.GetById(6).Data; Console.WriteLine("CarId:{0}, BrandId:{1}, ColorId:{2}, ModelName:{3}, ModelYear:{4}, DailyPrice:{5}, Description:{6}", resultCarGetById.CarId, resultCarGetById.BrandId, resultCarGetById.ColorId, resultCarGetById.ModelName, resultCarGetById.ModelYear, resultCarGetById.DailyPrice, resultCarGetById.Description); Console.WriteLine("\n---GetCarsByBrandId(2)"); var resultGetCarsByBrandId = carManager1.GetCarsByBrandId(2).Data; foreach (var car in resultGetCarsByBrandId) { Console.WriteLine("CarId:{0}, BrandId:{1}, ColorId:{2}, ModelName:{3}, ModelYear:{4}, DailyPrice:{5}, Description:{6}", car.CarId, car.BrandName, car.ColorName, car.ModelName, car.ModelYear, car.DailyPrice, car.Description); } Console.WriteLine("\n---GetCarsByColorId(3)"); var resultGetCarsByColorId = carManager1.GetCarsByColorId(3).Data; foreach (var car in resultGetCarsByColorId) { Console.WriteLine("CarId:{0}, BrandId:{1}, ColorId:{2}, ModelName:{3}, ModelYear:{4}, DailyPrice:{5}, Description:{6}", car.CarId, car.BrandName, car.ColorName, car.ModelName, car.ModelYear, car.DailyPrice, car.Description); } Car car1 = new Car() { BrandId = 2, ColorId = 3, ModelName = "Test Model", ModelYear = 2021, DailyPrice = 1850, Description = "Test Description" }; string isCarAdded = carManager1.Add(car1).Message; Console.WriteLine("\nisCarAdded:" + isCarAdded); Console.WriteLine("\n---Car GetById(7)"); var resultGetCarById = carManager1.GetById(7).Data; Console.WriteLine("CarId:{0}, BrandId:{1}, ColorId:{2}, ModelName:{3}, ModelYear:{4}, DailyPrice:{5}, Description:{6}", resultGetCarById.CarId, resultGetCarById.BrandId, resultGetCarById.ColorId, resultGetCarById.ModelName, resultGetCarById.ModelYear, resultGetCarById.DailyPrice, resultGetCarById.Description); Color color1 = new Color() { ColorName = "Blue" }; string isColorAdded = colorManager1.Add(color1).Message; Console.WriteLine("\nisColorAdded:" + isColorAdded); Console.WriteLine("\n---Color GetById(4)"); var resultGetColorById = colorManager1.GetById(4).Data; Console.WriteLine("ColorId:{0}, ColorName:{1}", resultGetColorById.ColorId, resultGetColorById.ColorName); Brand brand1 = new Brand() { BrandName = "Audi" }; string isBrandAdded = brandManager1.Add(brand1).Message; Console.WriteLine("\nisBrandAdded:" + isBrandAdded); Console.WriteLine("\n---Brand GetById(4)"); var resultGetBrandById = brandManager1.GetById(4).Data; Console.WriteLine("BrandId:{0}, BrandName:{1}", resultGetBrandById.BrandId, resultGetBrandById.BrandName); car1.BrandId = 4; car1.ColorId = 4; car1.ModelName = "Test Model Update"; car1.Description = "Test Description Update"; string isCarUpdated = carManager1.Update(car1).Message; Console.WriteLine("\nisCarUpdated:" + isCarUpdated); Console.WriteLine("\n---Color GetById(7)"); var resultGetCarById2 = carManager1.GetById(7).Data; Console.WriteLine("CarId:{0}, BrandId:{1}, ColorId:{2}, ModelName:{3}, ModelYear:{4}, DailyPrice:{5}, Description:{6}", resultGetCarById2.CarId, resultGetCarById2.BrandId, resultGetCarById2.ColorId, resultGetCarById2.ModelName, resultGetCarById2.ModelYear, resultGetCarById2.DailyPrice, resultGetCarById2.Description); color1.ColorName = "Gray"; string isColorUpdated = colorManager1.Update(color1).Message; Console.WriteLine("\nisColorUpdated:" + isColorUpdated); Console.WriteLine("\n---Color GetById(4)"); var resultGetColorById2 = colorManager1.GetById(4).Data; Console.WriteLine("ColorId:{0}, ColorName:{1}", resultGetColorById2.ColorId, resultGetColorById2.ColorName); brand1.BrandName = "Toyota"; string isBrandUpdated = brandManager1.Update(brand1).Message; Console.WriteLine("\nisBrandUpdated:" + isBrandUpdated); Console.WriteLine("\n---Brand GetById(4)"); var resultGetbBrandById2 = brandManager1.GetById(4).Data; Console.WriteLine("BrandId:{0}, BrandName:{1}", resultGetbBrandById2.BrandId, resultGetbBrandById2.BrandName); string isCarDeleted = carManager1.Delete(car1).Message; Console.WriteLine("\nisCarDeleted:" + isCarDeleted); string isColorDeleted = colorManager1.Delete(color1).Message; Console.WriteLine("\nisColorDeleted:" + isColorDeleted); string isBrandDeleted = brandManager1.Delete(brand1).Message; Console.WriteLine("\nisBrandDeleted:" + isBrandDeleted); Console.WriteLine("\n---Car Not Valid Adding Error Message"); Console.WriteLine(carManager1.Add(new Car() { CarId = 8, BrandId = 1, ColorId = 3, ModelName = "Test Model 2", ModelYear = 2018, DailyPrice = 800, Description = "T" }).Message); }
private static void BrandtDeleteTest(ref BrandManager brandManager) { var entity = brandManager.GetAllByName("Reno")?.Data.SingleOrDefault(); brandManager.Delete(entity); }
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(); }
private static void TestingBrand() { BrandManager brandManager = new BrandManager(new EfBrandDal()); Console.WriteLine("----------"); Console.WriteLine("Brands : "); var result = brandManager.GetAll(); if (result.Success == true) { foreach (var brand in result.Data) { Console.WriteLine(brand.Id + " " + brand.Name); } } else { Console.WriteLine(result.Message); } Brand brand1 = new Brand() { Id = 4, Name = "Chevrolet" }; List <Brand> list = result.Data; for (int i = 0; i < list.Count; i++) { Brand brand = list[i]; if (brand1.Id == brand.Id) { Console.WriteLine("----------"); brandManager.Delete(brand1); Console.WriteLine("Brands After Deleting : "); foreach (var brand2 in result.Data) { Console.WriteLine(brand2.Id + " " + brand2.Name); } } } for (int i = 0; i < list.Count; i++) { Brand brand = list[i]; if (brand1.Id != brand.Id) { Console.WriteLine("----------"); brandManager.Add(brand1); Console.WriteLine("Brands After Adding : "); foreach (var brand3 in result.Data) { Console.WriteLine(brand3.Id + " " + brand3.Name); } break; } } foreach (var brand in result.Data) { if (brand.Name == "Chevrolet") { Brand brand4 = new Brand() { Id = 4, Name = "Cadillac" }; Console.WriteLine("----------"); brandManager.Update(brand4); Console.WriteLine("Brands After Updating : "); foreach (var brand5 in result.Data) { Console.WriteLine(brand5.Id + " " + brand5.Name); } } else if (brand.Name == "Cadillac") { Brand brand5 = new Brand() { Id = 4, Name = "Chevrolet" }; Console.WriteLine("----------"); brandManager.Update(brand5); Console.WriteLine("Brands After Updating : "); foreach (var brand6 in result.Data) { Console.WriteLine(brand6.Id + " " + brand6.Name); } } } }
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"); }
private static void brandDelete(BrandManager brandManager) { brandManager.Delete(new Brand { BrandId = 1002, BrandName = "Fiat12" }); }