Beispiel #1
0
        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");
            }
        }