private static void CarAddInMemoryDal() { Car car = new Car() { Id = 10, BrandId = 5, CarName = "Brava", ColorId = 3, DailyPrice = 400, Description = "Hatchback, Otomatik", ModelYear = 2019 }; Car car1 = new Car() { Id = 11, BrandId = 4, CarName = "CLK 200", ColorId = 1, DailyPrice = 800, Description = "Hatchback, Otomatik", ModelYear = 2020 }; InMemoryCarDal inMemoryCarDal = new InMemoryCarDal();/*new EfEntityRepositoryBase(car, new RentaCarContext());*/ CarManager carManager = new CarManager(inMemoryCarDal); inMemoryCarDal.Add(car); inMemoryCarDal.Add(car1); int i = 0; foreach (var item in carManager.GetRentableCarsDto().Data) { i++; Console.WriteLine("{5} - {0}{1}{2}{3}{4}", item.BrandName.PadRight(10), item.CarName.PadRight(10), item.ColorName.PadRight(10), item.DailyPrice.ToString().PadRight(10), item.Description.PadRight(20), i); } }
private static void GetAllTest(InMemoryCarDal inMemoryCarDal) { foreach (var car in inMemoryCarDal.GetAll()) { Console.WriteLine( "* Aciklama: {0} | Ücret: {1} | Yıl: {2} | Marka: {3} | Renk: {4} ", car.Description, car.DailyPrice, car.ModelYear, car.BrandId, car.ColorId); } ;; }
static void Main(string[] args) { ICarDal carDal = new InMemoryCarDal(); CarManager carManager = new CarManager(carDal); foreach (var car in carManager.GetAll()) { Console.WriteLine(car.ModelYear); } ; }
private static void AddTestInMemory(InMemoryCarDal inMemoryCarDal) { inMemoryCarDal.Add(new Car { Id = 8, BrandId = 8, ColorId = 8, DailyPrice = 800000, ModelYear = "1972", Description = "Yeni Retro" }); foreach (var car in inMemoryCarDal.GetAll()) { Console.WriteLine( "* Aciklama: {0} | Ücret: {1} | Yıl: {2} | Marka: {3} | Renk: {4} ", car.Description, car.DailyPrice, car.ModelYear, car.BrandId, car.ColorId); } ; }
private static void InMemoryTest() { CarManager carManager = new CarManager(new InMemoryCarDal()); InMemoryCarDal inMemoryCarDal = new InMemoryCarDal(); GetAllTest(inMemoryCarDal); Console.WriteLine("------"); AddTestInMemory(inMemoryCarDal); Console.WriteLine("------"); GetByIdTest(inMemoryCarDal); Console.WriteLine("------"); inMemoryCarDal.Update(new Car { Id = 2, BrandId = 2, ColorId = 2, DailyPrice = 800000, ModelYear = "1964", Description = "Retro Update" }); Console.WriteLine("in memory"); foreach (var car in carManager.GetByUnitPrice(40, 100).Data) { Console.WriteLine(car.Description); } }
public CarManager(InMemoryCarDal carDal) { _carDal = carDal; }
public CarManager(InMemoryCarDal memoryCarDal) { _ınMemoryCarDal = memoryCarDal; }
private static void GetByIdTest(InMemoryCarDal inMemoryCarDal) { Console.WriteLine(inMemoryCarDal.GetById(5).Description); }