private static void BrandTest() { BrandManager brandManager = new BrandManager(new EfBrandDal()); Console.WriteLine(brandManager.Get(4).Data.Name); foreach (var brand in brandManager.GetAll().Data) { Console.WriteLine(brand.Name); } }
private static void BrandGet() { BrandManager brandManager = new BrandManager(new EfBrandDal()); /* BRAND GET */ try { Console.WriteLine(brandManager.Get(1).Data.Name); } catch (Exception) { Console.WriteLine("Marka getirilmeye çalışırken bir hata oluştu"); } }
private static void BrandTest(int brandId, string brandName) { BrandManager brandManager = new BrandManager(new EfBrandDal()); var result = brandManager.GetAll(); foreach (var brand in result.Data) { Console.WriteLine(brand.BrandName); Console.WriteLine("----------"); } Brand brand1 = new Brand { BrandName = brandName }; brandManager.Add(brand1); var getBrandId = brandManager.Get(brandId); Console.WriteLine("Brand is : " + getBrandId.Data.BrandName); }
private static void BrandCrudMethods() { BrandManager brandManager = new BrandManager(new EfBrandDal()); var result = brandManager.GetAll(); foreach (var brand in result.Data) { Console.WriteLine("{0} {1}", brand.Id, brand.BrandName); } Console.WriteLine("-------------------------------------------------------------------------"); var brandEntity = brandManager.Get(4); Console.WriteLine("{0} {1}", brandEntity.Data.Id, brandEntity.Data.BrandName); Console.WriteLine("-------------------------------------------------------------------------"); brandManager.Add(new Brand { BrandName = "Opel" }); foreach (var brand in result.Data) { Console.WriteLine("{0} {1}", brand.Id, brand.BrandName); } Console.WriteLine("-------------------------------------------------------------------------"); brandManager.Update(new Brand { Id = 4, BrandName = "Skoda" }); foreach (var brand in result.Data) { Console.WriteLine("{0} {1}", brand.Id, brand.BrandName); } Console.WriteLine("-------------------------------------------------------------------------"); brandManager.Delete(new Brand { Id = 4, BrandName = "Audi" }); foreach (var brand in result.Data) { Console.WriteLine("{0} {1}", brand.Id, brand.BrandName); } }
private static void InMemoryTest() { CarManager carManager = new CarManager(new InMemoryCarDal()); Console.WriteLine("********** GetAll Cars ****************************"); var result = carManager.GetAll(); if (result.Success == true) { Console.WriteLine(String.Format("{0,-3} {1,-7} {2,-7} {3,-15} {4,-10} {5,-10}", "Id", "BrandId", "ColorId", "Model Year", "DailyPrice", "Description")); foreach (var car in result.Data) { Console.WriteLine(String.Format("{0,4} {1,4} {2,4} {3,-10} {4,-10} {5,-10}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description)); } } else { Console.WriteLine(result.Message); } Console.WriteLine("**********GetAll Cars By Brand Id****************************"); result = carManager.GetCarsByBrandId(18); if (result.Success == true) { Console.WriteLine(String.Format("{0,-3} {1,-7} {2,-7} {3,-15} {4,-10} {5,-10}", "Id", "BrandId", "ColorId", "Model Year", "DailyPrice", "Description")); foreach (var car in result.Data) { Console.WriteLine(String.Format("{0,3} {1,7} {2,7} {3,-15} {4,-10} {5,-10}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description)); } } else { Console.WriteLine(result.Message); } Console.WriteLine("********GetAll Cars By Color Id******************************"); result = carManager.GetCarsByColorId(10); if (result.Success == true) { Console.WriteLine(String.Format("{0,-3} {1,-7} {2,-7} {3,-15} {4,-10} {5,-10}", "Id", "BrandId", "ColorId", "Model Year", "DailyPrice", "Description")); foreach (var car in result.Data) { Console.WriteLine(String.Format("{0,3} {1,7} {2,7} {3,-15} {4,-10} {5,-10}", car.Id, car.BrandId, car.ColorId, car.ModelYear, car.DailyPrice, car.Description)); } } else { Console.WriteLine(result.Message); } BrandManager brandManager = new BrandManager(new InMemoryBrandDal()); brandManager.GetAll(); Console.WriteLine("******** GetAll Brands ******************************"); var resultb = brandManager.GetAll(); if (resultb.Success == true) { Console.WriteLine(String.Format("{0,-3} {1,-15}", "Id", "Brand Name")); foreach (var brand in resultb.Data) { Console.WriteLine(String.Format("{0,3} {1,-15}", brand.Id, brand.Name)); } } else { Console.WriteLine(result.Message); } Console.WriteLine("******** Get a Brand ******************************"); var resultg = brandManager.Get(3); if (result.Success == true) { Console.WriteLine(String.Format("{0,-3} {1,-15}", "Id", "Brand Name")); Console.WriteLine(String.Format("{0,3} {1,-15}", resultg.Data.Id, resultg.Data.Name)); } else { Console.WriteLine(result.Message); } ColorManager colorManager = new ColorManager(new InMemoryColorDal()); Console.WriteLine("******** GetAll Colors ******************************"); var resultc = colorManager.GetAll(); if (resultc.Success == true) { Console.WriteLine(String.Format("{0,-3} {1,-15}", "Id", "Color Name")); foreach (var color in resultc.Data) { Console.WriteLine(String.Format("{0,3} {1,-15}", color.Id, color.Name)); } } else { Console.WriteLine(result.Message); } Console.WriteLine("******** Get a Color ******************************"); var colorg = colorManager.Get(5); if (colorg.Success == true) { Console.WriteLine(String.Format("{0,-3} {1,-15}", "Id", "Color Name")); Console.WriteLine(String.Format("{0,3} {1,-15}", colorg.Data.Id, colorg.Data.Name)); } else { Console.WriteLine(result.Message); } }
private static void BrandTest() { BrandManager brandManager = new BrandManager(new EfBrandDal()); List <Brand> _brands = new List <Brand> { new Brand { Name = "Audi" }, new Brand { Name = "Bmw" }, new Brand { Name = "Citroen" }, new Brand { Name = "Dacia" }, new Brand { Name = "Fiat" }, new Brand { Name = "Honda" }, new Brand { Name = "Hyundai" }, new Brand { Name = "Isuzu" }, new Brand { Name = "Mitsubishi" }, new Brand { Name = "Nisan" }, new Brand { Name = "Opel" }, new Brand { Name = "Porsche" }, new Brand { Name = "Renault" }, new Brand { Name = "RenaultSeat" }, new Brand { Name = "Skoda" }, new Brand { Name = "Suzuki" }, new Brand { Name = "Toyota" }, new Brand { Name = "Volkswagen" }, new Brand { Name = "Volvo" }, new Brand { Name = "Volvo" } }; // listedeki markaları boş vt ye atacaz foreach (var brand in _brands) { var resulti = brandManager.Add(brand); if (resulti.Success == true) { Console.WriteLine(Messages.CarAdded); } else { Console.WriteLine(resulti.Message); } } Brand brandToUpdate = new Brand(); brandToUpdate.Id = 10; brandToUpdate.Name = "Nissan"; // id si 10 olan ürünü bilerek Nissan yerine Nisan yapmıştım. onu düzeltecez var result = brandManager.Update(brandToUpdate); if (result.Success == true) { Console.WriteLine(Messages.CarUpdated); } else { Console.WriteLine(result.Message); } Brand brandToDelete = new Brand(); brandToDelete.Id = 20; // id si 19 ve 20 olan markayı bilerek iki defa yazdım. Fazlalık olan 20 noluyu silecez result = brandManager.Delete(brandToDelete); if (result.Success == true) { Console.WriteLine(Messages.CarDeleted); } else { Console.WriteLine(result.Message); } // Tüm markaları listeleme var result3 = brandManager.GetAll(); if (result3.Success == true) { Console.WriteLine(String.Format("{0,-3} {1,20}", "Id", "BrandName")); foreach (var brand in result3.Data) { Console.WriteLine(String.Format("{0,-3} {1,20}", brand.Id, brand.Name)); } } else { Console.WriteLine(result.Message); } // 11 nolu markayı listeleme var brandToGet = brandManager.Get(11); if (brandToGet.Success == true) { Console.WriteLine(String.Format("{0,-3} {1,20}", "Id", "BrandName")); Console.WriteLine(String.Format("{0,-3} {1,20}", brandToGet.Data.Id, brandToGet.Data.Name)); } else { Console.WriteLine(result.Message); } }
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 = 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 = 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 = 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, ColorHexCode = clr.HEXCode, DailyPrice = c.DailyPrice, Description = c.Description, ModelYear = c.ModelYear }; foreach (CarDTO carDTO in CarList) { Console.WriteLine($"Id: {carDTO.Id}, " + $"Marka Adı: {carDTO.BrandName}, " + $"Rengi: {carDTO.ColorName}, " + $"Renk Hex Kodu: {carDTO.ColorHexCode}, " + $"Günlük Fiyatı: {carDTO.DailyPrice}, " + $"Açıklama: {carDTO.Description}, " + $"Model Yılı: {carDTO.ModelYear}\n"); } }
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 = 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 = 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 = 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 = 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 = 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.ColorHexCode}, " + $"Günlük Fiyatı: {carDTO.DailyPrice}, " + $"Açıklama: {carDTO.Description}, " + $"Model Yılı: {carDTO.ModelYear}\n"); } }