Пример #1
0
        private static void InMemory()
        {
            InMemoryCarDal inMemoryCarDal = new InMemoryCarDal();

            inMemoryCarDal.Add(new Car
            {
                CarId       = 6,
                BrandId     = 2,
                ColorId     = 1,
                DailyPrice  = 30000,
                Description = "Hybrid",
                ModelYear   = "2021"
            });

            CarManager carManager = new CarManager(inMemoryCarDal);

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

            List <Brand> brands = new List <Brand>
            {
                new Brand {
                    BrandId = 1, BrandName = "Mercedes"
                },
                new Brand {
                    BrandId = 2, BrandName = "Bmw"
                },
                new Brand {
                    BrandId = 3, BrandName = "Audi"
                }
            };

            List <Color> colors = new List <Color>
            {
                new Color {
                    ColorId = 1, ColorName = "Beyaz"
                },
                new Color {
                    ColorId = 2, ColorName = "Siyah"
                },
                new Color {
                    ColorId = 3, ColorName = "Mor"
                },
                new Color {
                    ColorId = 4, ColorName = "Kırmızı"
                }
            };
        }
Пример #2
0
        static void Main(string[] args)
        {
            Car car = new Car();

            car.Id          = 5;
            car.BrandId     = 6;
            car.ColorId     = 10;
            car.DailyPrice  = 350;
            car.Description = "Peugoet 301";
            car.ModelYear   = 2016;


            ICarDal cars = new InMemoryCarDal();

            cars.Add(car);
            cars.Delete(3);
            cars.GetAll();
            cars.GetById(4);
            cars.Update(2, car);
        }
Пример #3
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new InMemoryCarDal());

            foreach (var car in carManager.GetAll())
            {
                Console.WriteLine(car.Id + " " + car.ModelYear + " " + car.DailyPrice + " " + car.Description);
            }
            Console.WriteLine("-----------");
            foreach (var car in carManager.GetById(3))
            {
                Console.WriteLine(car.Id + " " + car.ModelYear + " " + car.DailyPrice + " " + car.Description);
            }
            Console.WriteLine("-----------");

            InMemoryCarDal inMemoryCarDal = new InMemoryCarDal();

            inMemoryCarDal.Add(new Car
            {
                Id          = 6,
                BrandId     = 4,
                ColorId     = 3,
                DailyPrice  = 94500,
                ModelYear   = "2009",
                Description = "Nissan"
            });


            inMemoryCarDal.Update(new Car
            {
                Id          = 5,
                BrandId     = 4,
                ColorId     = 3,
                DailyPrice  = 94500,
                ModelYear   = "2009",
                Description = "Nissan"
            });
        }
Пример #4
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new InMemoryCarDal());

            foreach (var car in carManager.GetAll())
            {
                Console.WriteLine(car.Description);
            }

            InMemoryCarDal inMemoryCarDal = new InMemoryCarDal();

            inMemoryCarDal.Add(new Car {
                Id = 6, BrandId = 2, ColorId = 2, DailyPrice = 20000, ModelYear = 1985, Description = "Pembe Araba"
            });
            inMemoryCarDal.Update(new Car {
                Id = 6, BrandId = 2, ColorId = 2, DailyPrice = 60000, ModelYear = 1975, Description = "Lacivert Araba"
            });
            inMemoryCarDal.Delete(new Car {
                Id = 6
            });

            Console.ReadLine();
        }