Example #1
0
        /// <summary>
        /// Add car with CarManager
        /// </summary>
        private static void AddCar()
        {
            WriteToCenter("Car Name : ");
            string carName = Console.ReadLine();

            WriteToCenter("Model Year : ");
            int ModelYear = Convert.ToInt32(Console.ReadLine());

            WriteToCenter("Daily Price : ");
            int dailyPrice = Convert.ToInt32(Console.ReadLine());

            WriteToCenter("Brand Id: ");
            int brandId = Convert.ToInt32(Console.ReadLine());

            WriteToCenter("Color Id : ");
            int colorId = Convert.ToInt32(Console.ReadLine());
            var result  = carManager.Add(new Car
            {
                Description = carName,
                DailyPrice  = dailyPrice,
                ModelYear   = ModelYear,
                BrandId     = brandId,
                ColorId     = colorId,
            });

            if (result.IsSuccess)
            {
                WriteToCenter(result.Message);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new InMemoryCarDal());

            Console.WriteLine("*******************GETALL**************");
            GetAll(carManager.GetAll());
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("*******************ADD**************");
            carManager.Add(new Car {
                Id = 5, BrandId = 1, ColorId = 1, DailyPrice = 150000, Description = "Seat Ibıza", ModelYear = "2017"
            });
            GetAll(carManager.GetAll());
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("*******************UPDATE**************");
            Console.WriteLine("*******************SEAT IBIZA FİYATI GÜNCELLEDİ**************");
            carManager.Update(new Car {
                Id = 5, BrandId = 1, ColorId = 1, DailyPrice = 160000, Description = "Seat Ibıza", ModelYear = "2017"
            });
            GetAll(carManager.GetAll());
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("*******************DELETE**************");
            Console.WriteLine("*******************IBIZA YOK ARTIK**************");
            carManager.Delete(new Car {
                Id = 5
            });
            GetAll(carManager.GetAll());
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("*******************GET ALL BY ID**************");
            Console.WriteLine("*******************LEON**************");
            GetAll(carManager.GetAllById(1));
        }
Example #3
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new InMemoryCarDal());

            GetItem(carManager.GetByCarId(1));

            GetList(carManager.GetAll());


            carManager.Delete(new Car {
                CarId = 1, ColorId = 1, BrandId = 1, ModelYear = new DateTime(1987, 01, 01), DailyPrice = 70, Description = "Renault 1987"
            });

            GetList(carManager.GetAll());

            carManager.Update(new Car {
                CarId = 2, ColorId = 2, BrandId = 2, ModelYear = new DateTime(2013, 02, 24), DailyPrice = 100, Description = "Ford Focus"
            });

            GetList(carManager.GetAll());


            carManager.Add(new Car {
                CarId = 5, ColorId = 4, BrandId = 3, ModelYear = new DateTime(2016, 06, 27), DailyPrice = 180, Description = "Audi A3"
            });

            GetList(carManager.GetAll());

            GetList(carManager.GetByColorId(2));

            GetList(carManager.GetByBrandId(3));
        }
Example #4
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new InMemoryCarDal());

            carManager.Add(new Car {
                Id = 6, BrandId = 4, ColorId = 3, DailyPrice = 25, ModelYear = "2011", Description = "Mazda 6 "
            });

            carManager.Update(new Car {
                Id = 6, BrandId = 4, ColorId = 1, DailyPrice = 30, ModelYear = "2011", Description = "Mazda 6 Skyactive"
            });

            carManager.Delete(new Car {
                Id = 6
            });


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

            Console.WriteLine("-----------------------------");

            Console.WriteLine(carManager.GetById(1).Data.Description);

            Console.WriteLine("-----------------------------");
        }
        static void Main(string[] args)
        {
            CarManager   carManager   = new CarManager(new EfCarDal());
            BrandManager brandManager = new BrandManager(new EfBrandDal());
            ColorManager colorManager = new ColorManager(new EfColorDal());

            Car car = new Car {
                BrandId = 1, ColorId = 1, DailyPrice = 100, ModelYear = 2018
            };

            carManager.Add(car);
            foreach (var car in carManager.Add())
            {
                Console.WriteLine(car.BrandId);
            }
        }
Example #6
0
        private static void CarTest()
        {
            CarManager carManager = new CarManager(new EfCarDal());

            carManager.Add(new Car {
                BrandId = 2, ColorId = 4, DailyPrice = 450, Description = "Sıfıra yakın!", ModelYear = "2021"
            });
            carManager.Update(new Car {
                CarId = 1009, BrandId = 2, ColorId = 4, DailyPrice = 460, Description = "Sıfıra yakın!", ModelYear = "2021"
            });
            carManager.Delete(new Car {
                CarId = 1012
            });

            var result = carManager.GetAll();

            if (result.Success == true)
            {
                foreach (var car in result.Data)
                {
                    Console.WriteLine(car.ModelYear + " model aracınız günlük " + car.DailyPrice + " TL'dir. " + car.Description);
                }
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Example #7
0
        private static void CarOperations(CarManager carManager)
        {
            Console.WriteLine("--------Araba ile İlgili İşlemler------ \n");

            Console.WriteLine("Bir işlem türü giriniz");

            Console.WriteLine("1-Araba Ekleme İşlemi");
            Console.WriteLine("2-Araba Silme İşlemi");
            Console.WriteLine("3-Araba Güncelleme İşlemi");
            int islem = Convert.ToInt16(Console.ReadLine());

            switch (islem)
            {
            case 1:
                Console.WriteLine("Sırası ile ColorId,BrandId,ModelYear,DailyPrice,Description şeklinde giriniz");
                carManager.Add(new Car
                {
                    ColorId     = Convert.ToInt32(Console.ReadLine()),
                    BrandId     = Convert.ToInt32(Console.ReadLine()),
                    ModelYear   = Convert.ToInt32(Console.ReadLine()),
                    DailyPrice  = Convert.ToInt32(Console.ReadLine()),
                    Description = Console.ReadLine()
                }
                               ); break;
            }
        }
        private static void CarCRUDTest()
        {
            CarManager carManager      = new CarManager(new EfCarDal());
            Car        carAddandDelete = new Car();

            carAddandDelete.Description = "it will be added and deleted";
            Console.WriteLine("Eklemeden Once \n");
            CarTest();
            Console.WriteLine("\n");

            carManager.Add(carAddandDelete);
            Console.WriteLine("Ekledikten Sonra \n");
            CarTest();
            Console.WriteLine("\n");

            //carManager.Delete(carAddandDelete);
            // Console.WriteLine("Silindikten sonra");
            //CarTest();
            Car carToUpdate = new Car()
            {
                Id = 2, Description = "Updated:Skoda", BrandId = 2, ColorId = 1
            };

            carManager.Update(carToUpdate);
            Console.WriteLine("Guncellendikten sonra");
            CarTest();
        }
Example #9
0
        private static void CarAdd()
        {
            CarManager carManager = new CarManager(new EfCarDal());

            carManager.Add(new Car {
                BrandId = 1, ColorId = 2, CarName = "MERCEDES", ModelYear = 2020, DailyPrice = 300, Description = "Alieye uygun"
            });
        }
Example #10
0
        public void Menu()
        {
            MenuShow();
            string     input      = Console.ReadLine();
            CarManager carManager = new CarManager(new InMemoryCarDal());


            switch (input)
            {
            case "1":

                foreach (var category in carManager.GetAllCategories())
                {
                    Console.WriteLine(category.CategoryId + " " + category.CategoryName);
                }

                break;

            case "2":
                foreach (var cars in carManager.GetAll())
                {
                    Console.WriteLine(cars.Id + " " + cars.BrandId + " " + cars.ColorId + " " + cars.Modelyear +
                                      " " + cars.DailyPrice + " " + cars.Description);
                }

                break;

            case "3":
                foreach (var rented in carManager.RentCarsList())
                {
                    Console.WriteLine(rented.CarName + " " + "Is the vehicle electric ?" + " " +
                                      rented.VehicleElectric);
                }

                break;

            case "4":
                var carId = CarAddList(out var carBrandId, out var carColorId, out var carModelYear,
                                       out var carDailyPrice, out var carDescription);

                carManager.Add(new Car
                {
                    Id         = carId, BrandId = carBrandId, ColorId = carColorId, Modelyear = carModelYear,
                    DailyPrice = carDailyPrice, Description = carDescription
                });


                foreach (var cars in carManager.GetAll())
                {
                    Console.WriteLine(cars.Id + " " + cars.BrandId + " " + cars.ColorId + " " + cars.Modelyear +
                                      " " + cars.DailyPrice + " " + cars.Description);
                }

                Console.WriteLine("The vehicle has been added and the list has been updated !");

                break;
            }
        }
Example #11
0
        private static void CarAddTest()
        {
            CarManager carManager = new CarManager(new EfCarDal());
            var        result     = carManager.Add(new Car {
                ColorId = 255, ModelYear = 2020, BrandId = 9, DailyPrice = 400, Description = "Buketin Arabası"
            });

            Console.WriteLine(result.Message);
        }
Example #12
0
        private static void EntityFrameworkAddTest()
        {
            CarManager carManager = new CarManager(new EfCarDal());
            Car        carToAdd   = new Car {
                Id = 7, BrandId = 3, ColorId = 2, ModelYear = 2020, DailyPrice = 300, Description = "Peugeot 308"
            };

            carManager.Add(carToAdd);
        }
Example #13
0
        private static void AddTest()
        {
            CarManager carManager = new CarManager(new EfCarDal());
            Car        car        = new Car()
            {
                Name = "X", DailyPrice = 0, BrandId = 2, ColorId = 1, Description = "NEW CAR", ModelYear = 2021
            };

            carManager.Add(car);
        }
Example #14
0
        private static void AddCar()
        {
            CarManager carManager = new CarManager(new EfCarDal());

            carManager.Add(new Car
            {
                CarId       = 1, CarName = "Civic", ColorId = 3, BrandId = 6, ModelYear = 2019, DailyPrice = 150,
                Description = "Konfora düşkün insanlar için."
            });
        }
Example #15
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new EfCarDal());
            Car        car1       = new Car()
            {
                BrandId = 1, ColorId = 2, DailyPrice = 900, Description = "Ford", ModelYear = 2009
            };

            carManager.Add(car1);
        }
Example #16
0
 private static void CarTest()
 {
     CarManager carManager = new CarManager(new EfCarDal());
     carManager.Add(new Car { BrandId = 3, ColorId = 2, DailyPrice = 1, Description = "  mercedes", ModelYear = 2019 });
     //  carManager.Delete(new Car { Id=2012, BrandId=1,ColorId=2 });
     //foreach (var car in carManager.GetCarDetails().Data)
     //{
     //    Console.WriteLine(car.Id + " - " + car.BrandName + " - "
     //        + car.ColorName + " - " + car.DailyPrice);
     //}
 }
Example #17
0
        static void Main(string[] args)
        {
            //CustomerTest();
            //RentalTest();
            CarManager carManager = new CarManager(new EfCarDal());

            Console.WriteLine(carManager.Add(new Car {
                BrandId = 5, ColorId = 3, Description = "Lada Jeep", DailyPrice = 1500, ModelYear = new DateTime(2021, 01, 01)
            }).Message);

            // UserTest();
        }
Example #18
0
        private static void AddingCars()
        {
            var carManager = new CarManager(new EfCarDal());

            carManager.Add(new Car()
            {
                BrandId     = 1, ColorId = 2, DailyPrice = 20000, ModelYear = 2016, Name = "Toyota Camry",
                Description =
                    "Is an automobile sold internationally by the Japanese manufacturer Toyota since 1982, spanning multiple generations"
            });
            carManager.Add(new Car()
            {
                BrandId     = 3, Name = "Honda Accord", DailyPrice = 30000, ModelYear = 2019, ColorId = 1,
                Description = "Use the U.S. News Best Price Program to find the best local prices on the Accord."
            });
            carManager.Add(new Car()
            {
                BrandId     = 5, ColorId = 3, DailyPrice = 15000, Name = "Hyundai Sonata", ModelYear = 2013,
                Description = "Is a mid-size car produced by the South Korean manufacturer Hyundai since 1985"
            });
        }
Example #19
0
 private static void AddMetodu2(CarManager carManager)
 {
     carManager.Add(new Car
     {
         Id          = 8,
         BrandId     = 3,
         ColorId     = 10,
         DailyPrice  = 200,
         ModelYear   = 2006,
         Description = "Tır"
     });
 }
Example #20
0
        static void Main(string[] args)
        {
            CarManager   carManager   = new CarManager(new EfCarDal());
            BrandManager brandManager = new BrandManager(new EfBrandDal());
            ColorManager colorManager = new ColorManager(new EfColorDal());

            Car car = new Car {
                Id = 1, BrandId = 1, ColorId = 1, DailyPrice = 100, ModelYear = 2018, Description = "2018 Model Araba"
            };
            Car car2 = new Car {
                Id = 2, BrandId = 2, ColorId = 2, DailyPrice = 50, ModelYear = 2020, Description = "2020 Model Araba"
            };

            carManager.Add(car);
            carManager.Add(car2);

            //foreach (var car in carManager.GetAll())
            //{
            //    Console.WriteLine(car.Description);
            //}
        }
Example #21
0
        static void Main(string[] args)
        {
            CarManager   carManager   = new CarManager(new EFCarDal());
            BrandManager brandManager = new BrandManager(new EFBrandDal());
            ColorManager colorManager = new ColorManager(new EFColorDal());

            Console.Write("Hangi marka araba getirilsin? --> ");
            byte brandId = Convert.ToByte(Console.ReadLine());

            foreach (var car in carManager.GetCarsByBrandId(brandId))
            {
                Console.WriteLine($"Araba Rengi: {colorManager.GetById(car.ColorId).ColorName}\n" +
                                  $"Araba Markası: {brandManager.GetById(car.BrandId).BrandName}\n" +
                                  $"Arabanın Yılı: {car.ModelYear}\n" +
                                  $"Arabanın Günlük Ücreti: {car.DailyPrice}\n" +
                                  $"Açıklama: {car.Descriptions}\n");
            }

            Console.Write("Hangi renk araba getirilsin? --> ");
            byte colorId = Convert.ToByte(Console.ReadLine());

            foreach (var car in carManager.GetCarsByColorId(colorId))
            {
                Console.WriteLine($"Araba Rengi: {colorManager.GetById(car.ColorId).ColorName}\n" +
                                  $"Araba Markası: {brandManager.GetById(car.BrandId).BrandName}\n" +
                                  $"Arabanın Yılı: {car.ModelYear}\n" +
                                  $"Arabanın Günlük Ücreti: {car.DailyPrice}\n" +
                                  $"Açıklama: {car.Descriptions}\n");
            }

            Brand brand1 = new Brand()
            {
                Id        = 5,
                BrandName = "w"
            };

            brandManager.Add(brand1);

            Console.WriteLine();

            Car car1 = new Car()
            {
                Id           = 9,
                BrandId      = 2,
                ColorId      = 3,
                DailyPrice   = -10,
                ModelYear    = "2006",
                Descriptions = "Tofaş - Dizel"
            };

            carManager.Add(car1);
        }
        private static void CarTest()
        {
            CarManager carManager = new CarManager(new EfCarDal());

            carManager.Add(new Car {
                BrandId = 1, ColorId = 1, DailyPrice = 2, Description = "Yeni araba bmw", ModelYear = 2005
            });
            //foreach (var car in carManager.GetCarDetails())
            //{
            //    Console.WriteLine(car.Id + " - " + car.BrandName + " - "
            //        + car.ColorName + " - " + car.DailyPrice);
            //}
        }
Example #23
0
        private static void CarCRUD()
        {
            Car car2 = new Car {
                BrandId = 2, ColorId = 4, DailyPrice = 870000, Description = "araç", ModelYear = new DateTime(2020, 1, 1)
            };
            CarManager carManager = new CarManager(new EFCarDal());

            carManager.Add(new Car {
                BrandId = 2, ColorId = 4, DailyPrice = 870000, Description = "Lüks araç", ModelYear = new DateTime(2020, 1, 1)
            });
            carManager.Update(car2);
            carManager.Delete(car2);
        }
Example #24
0
        private static void CarTest()
        {
            CarManager carManager = new CarManager(new EfCarDal());

            carManager.Add(new Car {
                BrandId = 2, ColorId = 2, DailyPrice = 150, Description = "İkinci araba mercedes", ModelYear = 2020
            });
            foreach (var car in carManager.GetCarDetails())
            {
                Console.WriteLine(car.Id + " - " + car.BrandName + " - "
                                  + car.ColorName + " - " + car.DailyPrice);
            }
        }
Example #25
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new EfCarDal());

            carManager.Add(new Car {
                CarId = 1, BrandId = 2, ColorId = 3, DailyPrice = 55000, ModelYear = 2016, Description = "Audi A3"
            });
            carManager.Delete(new Car {
                CarId = 6
            });

            Console.WriteLine(carManager.GetAll());
        }
Example #26
0
 public ActionResult <Car> Post([FromBody] Car value)
 {
     try
     {
         Car    newCar = _manager.Add(value);
         string uri    = Url.RouteUrl(RouteData.Values) + "/" + newCar.Id;
         return(Created(uri, newCar));
     }
     catch (ArgumentException ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Example #27
0
        private static void CarTest()
        {
            CarManager carManager = new CarManager(new EfCarDal());

            var add = carManager.Add(new Car
            {
                ColorId     = 7,
                BrandId     = 7,
                ModelYear   = 2019,
                DailyPrice  = 4800,
                Description = "........."
            });

            Console.WriteLine(add.Message);

            var delete = carManager.Delete(new Car {
                Id = 2
            });

            Console.WriteLine(delete.Message);

            var update = carManager.Update(new Car {
                Id = 3, BrandId = 4, ColorId = 5, ModelYear = 2018, DailyPrice = 1300, Description = "...."
            });

            Console.WriteLine(update.Message);


            foreach (var car in carManager.GetAll().Data)
            {
                Console.WriteLine("Car Id:" + car.Id + "\nBrand Id :" + car.BrandId + "\nColor Id :" + car.ColorId +
                                  "\nCar Daily Price :" + car.DailyPrice + "\nDescription :" + car.Description + "\n**********");
            }


            foreach (var car in carManager.GetCarsByBrandId(5).Data)
            {
                Console.WriteLine(car.DailyPrice);
            }


            foreach (var car in carManager.GetCarsByColorId(3).Data)
            {
                Console.WriteLine("Car Id :" + car.Id + " --> " + "Brand Id:" + car.BrandId);
            }

            foreach (var car in carManager.GetByDailyPrice(1000, 8000).Data)
            {
                Console.WriteLine("Car Id :" + car.Id + " --> " + "Daily Price :" + car.DailyPrice);
            }
        }
Example #28
0
        private static void AddCar()
        {
            CarManager carManager = new CarManager(new EfCarDal());

            carManager.Add(new Car
            {
                CarId      = 7,
                BrandId    = 2,
                ColorId    = 3,
                DailyPrice = 500,
                ModelYear  = 2013
            });
            Console.WriteLine("Car Added");
        }
Example #29
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new EfCarDal());

            carManager.Add(new Car
            {
                ColorId = 1, DailyPrice = 100, Description = "Peugot 308", ModelYear = 2010, Id = 4, BrandId = 3
            });

            foreach (var car in carManager.GetCarsByColorId(1))
            {
                Console.WriteLine(car.Description);
            }
        }
Example #30
0
        public static void AddCar(string carName, decimal dailyPrice, int brandId, int colorId)
        {
            CarManager carManager = new CarManager(new EfCarDal());
            Car        addedCar   = new Car
            {
                CarName    = carName,
                DailyPrice = dailyPrice,
                BrandID    = brandId,
                ColorID    = colorId
            };

            carManager.Add(addedCar);
            Console.WriteLine("Yeni Araba eklendi");
        }