Example #1
0
 private static void RentalDeleteMethod(RentalManager rentalManager)
 {
     rentalManager.Delete(new Rental {
         Id = 3
     });
     Console.WriteLine(Messages.RentalDeleted);
 }
        public override void DeleteForm()
        {
            string consoleVal;

            ConsoleTexts.FrameHeaderFooterLine();
            ConsoleTexts.Header(Messages.FormHeaderRentalDelete);
            ConsoleTexts.FrameHeaderFooterLine();

            List <RentalDetailDto> rentals = RentalList();

            string[] headers = { "Rental ID", "Car Name", "Brand Name", "Color Name", "First Name", "Last Name", "Email Address", "Company Name", "Rent Date", "Return Date" };
            //Todo : Liste sütunlarını azalt
            ConsoleTexts.WriteDataList <RentalDetailDto>(Messages.ListHeaderRentalSelect, rentals, headers);
            if (rentals != null)
            {
                consoleVal = ConsoleTexts.ConsoleWriteReadLine(Messages.SelectRentalIdToDelete);
                if (consoleVal != "")
                {
                    Rental rental = _rentalManager.GetById(Convert.ToInt32(consoleVal)).Data;
                    if (ConsoleTexts.ConfirmAction(Messages.DeleteItemAttention))
                    {
                        _rentalManager.Delete(rental);
                    }
                }
            }
        }
Example #3
0
        //------------------------------------------------ Case 10 : DeleteRental--------------------------------------------------
        private static void DeleteRental(RentalManager rentalManager)
        {
            Console.WriteLine("Write Rental ID For Delete");
            int deleteRent = Convert.ToInt32(Console.ReadLine());

            rentalManager.Delete(rentalManager.GetById(deleteRent).Data);
        }
Example #4
0
        private static void RentTest()
        {
            Rental rental = new Rental()
            {
                RentId     = 1,
                CarId      = 1,
                CustomerId = 1,
                RentDate   = DateTime.Now,
                ReturnDate = new DateTime(2021, 4, 1)
            };
            Rental rental1 = new Rental()
            {
                RentId     = 2,
                CarId      = 3,
                CustomerId = 2,
                RentDate   = DateTime.Now,
                ReturnDate = new DateTime(2021, 6, 2)
            };
            RentalManager rentalManager = new RentalManager(new EfRentalDal());
            //rentalManager.Add(rental1);
            var result = rentalManager.GetAll();

            // var selectedresult = rentalManager.GetById(1);
            // selectedresult.Data.CarId = 2;
            //rentalManager.Update(selectedresult.Data);
            rentalManager.Delete(rental);
            if (result.Success == true)
            {
                foreach (var res in result.Data)
                {
                    Console.WriteLine(res.RentDate + "/ " + res.ReturnDate);
                }
            }
        }
Example #5
0
        static void TestToDeleteRental(RentalManager rentalManager)
        {
            var result = rentalManager.Delete(new Rental {
                CarId = 2, CustomerId = 1, RentalId = 1002, RentDate = new DateTime(2021, 01, 21), ReturnDate = new DateTime(2021, 02, 05)
            });

            Console.WriteLine(result.Message);
        }
Example #6
0
        //private static void DeleteTest(UserManager userManager)
        //{
        //    var result = userManager.Delete(new User { ID = 1});
        //    Console.WriteLine(result.Message);
        //}

        private static void DeleteTest(RentalManager rentalManager)
        {
            var result = rentalManager.Delete(new Rental {
                ID = 1
            });

            Console.WriteLine(result.Message);
        }
Example #7
0
        private static void RentalTest(RentalManager rentalManager)
        {
            if (rentalManager.GetAll().Data.Count != 0)
            {
                Console.WriteLine("Bütün kiralanmış arabalar");
                foreach (var rental in rentalManager.GetAll().Data)
                {
                    Console.WriteLine(rental.Id + "  " + rental.CustomerId + "  " + rental.CarId + "  " + rental.RentDate + "  " + rental.RentDate);
                }
            }
            else
            {
                Console.WriteLine("Henüz hiç araba kiralanmamış");
            }

            rentalManager.Add(new Rental {
                CustomerId = 1, CarId = 2, RentDate = new DateTime(2020, 10, 25), ReturnDate = new DateTime(2020, 10, 26)
            });
            rentalManager.Add(new Rental {
                CustomerId = 1, CarId = 2, RentDate = new DateTime(2020, 11, 20), ReturnDate = new DateTime(2015, 11, 21)
            });

            Console.WriteLine("Eklemeden sonra bütün kiralanmış arabalar");
            foreach (var rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine(rental.Id + "  " + rental.CustomerId + "  " + rental.CarId + "  " + rental.RentDate + "  " + rental.RentDate);
            }

            rentalManager.Update(new Rental
            {
                Id         = 2,
                CarId      = 2,
                RentDate   = new DateTime(2021, 01, 01),
                ReturnDate = new DateTime(2020, 12, 02)
            });
            Console.WriteLine("Güncellemeden sonra bütün kiralanmış arabalar");
            foreach (var rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine(rental.Id + "  " + rental.CustomerId + "  " + rental.CarId + "  " + rental.RentDate + "  " + rental.RentDate);
            }


            rentalManager.Delete(new Rental {
                Id = 2
            });
            Console.WriteLine("Silmeden sonra kiralanmış arabalar");
            foreach (var rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine(rental.Id + "  " + rental.CustomerId + "  " + rental.CarId + "  " + rental.RentDate + "  " + rental.RentDate);
            }

            foreach (var rental in rentalManager.GetRentalCarDetails().Data)
            {
                Console.WriteLine(rental.RentalId + "  " + rental.FirstName + "  " + rental.LastName + "  "
                                  + rental.CompanyName + "  " + rental.Email + "  " + rental.BrandName + "  " + rental.ModelYear + "  " + rental.RentDate + "  " + rental.ReturnDate);
            }
        }
Example #8
0
 private void DeleteRental()
 {
     rental.Id         = Int32.Parse(textBox1.Text);
     rental.MovieId    = MovieId();
     rental.CustomerId = CustomerId();
     rental.RentDate   = DateTime.Parse(dateTimePicker1.Text);
     rental.ReturnDate = DateTime.Parse(dateTimePicker2.Text);
     rentalManager.Delete(rental);
 }
Example #9
0
        private static void RentalDelete()
        {
            RentalManager rentalManager = new RentalManager(new EfRentalDal());

            rentalManager.Delete(new Rental
            {
                Id = 1
            });
        }
Example #10
0
        static void Main(string[] args)
        {
            CarManager carManager = new CarManager(new EfCarDal());

            foreach (var car in carManager.GetCarDetails().Data)
            {
                Console.WriteLine(car.ColorName + " rengine sahip " + car.BrandName + " arabanın günlük fiyatı: " + car.DailyPrice);
            }


            UserManager userManager = new UserManager(new EfUserDal());
            //User user = new User();
            //user.FirstName = "Eren";
            //user.LastName = "Ugur";
            //user.Email = "*****@*****.**";
            //user.password = "******";
            //userManager.Add(user);

            //User user2 = new User();
            //user2.FirstName = "Furkan";
            //user2.LastName = "Yıldız";
            //user2.Email = "*****@*****.**";
            //user2.password = "******";
            //userManager.Add(user2);


            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            //Customer musteri = new Customer();
            //musteri.CompanyName = "Doge A.Ş";
            //musteri.UserId = 1; //eren kullanıcısyla müşteriyi eşledik
            //customerManager.Add(musteri);
            //Customer musteri2 = new Customer();
            //musteri2.CompanyName = "Holo A.Ş";
            //musteri2.UserId = 2;
            //customerManager.Add(musteri2);

            RentalManager rentalManager = new RentalManager(new EfRentalDal());
            Rental        rental1       = new Rental();

            rental1.CarId      = 1;
            rental1.CustomerId = 1;
            rental1.RentDate   = DateTime.Now;
            rental1.ReturnDate = DateTime.Now.AddDays(2); // geri verme tarihi 2 gün sonra
            //rentalManager.Add(rental1);
            rentalManager.Delete(rental1);

            Rental rental2 = new Rental();

            rental2.CarId      = 1; // aynı arabayı başka müşteri ile almayı deniyoruz.
            rental2.CustomerId = 2;
            rental2.RentDate   = DateTime.Now;
            rental2.ReturnDate = DateTime.Now.AddDays(2);
            //   rentalManager.Add(rental2);
            // İlk araba kaydı silinene kadar eklemiyor
        }
Example #11
0
        private static void RentalDelete()
        {
            RentalManager rentalManager = new RentalManager(new EfRentalDal());

            var result = rentalManager.Delete(new Rental
            {
                Id = 5
            });

            Console.WriteLine(result.Message);
        }
Example #12
0
        private static void RentalDeleteTest()
        {
            RentalManager rentalManager = new RentalManager(new EfRentalDal());

            RentalTest();
            Console.Write("Silmek için Rental ID'si giriniz:");
            int chooseId = int.Parse(Console.ReadLine());
            var result   = rentalManager.GetById(chooseId).Data;

            rentalManager.Delete(result);
        }
Example #13
0
        private static void DeleteRental(RentalManager rentalManager)
        {
            RentalsList(rentalManager);
            Console.WriteLine("Lütfen silmek istediğiniz kiralamanın 'id' sini giriniz: ");
            int deleteRental = Convert.ToInt32(Console.ReadLine());

            Console.Clear();

            rentalManager.Delete(new Rental {
                RentalId = deleteRental
            });
        }
Example #14
0
        private static void RentDelete()
        {
            RentalManager rentalManager = new RentalManager(new EfRentalDal());

            RentalList();
            Console.Write("Silmek istediğiniz Rent Id'si: ");
            int id = int.Parse(Console.ReadLine());

            rentalManager.Delete(new Rental {
                Id = id
            });
        }
Example #15
0
 public ActionResult Delete(int id)
 {
     if (id > 0)
     {
         bool isDelete = _rentalManager.Delete(id);
         if (isDelete)
         {
             return(RedirectToAction("Index"));
         }
     }
     return(View());
 }
        //-------------------------------Rental Methods------------------------------------

        private static void RentalDeletedTest(RentalManager rentalManager)
        {
            //for (int i = 11; i < 16; i++)
            //{
            //    var result = rentalManager.Delete(new Rental { RentalId = i });
            //}
            var result = rentalManager.Delete(new Rental {
                RentalId = 1008
            });

            Console.WriteLine(result.Message);
        }
Example #17
0
        private static void RentalDelete(RentalManager rentalManager)
        {
            Console.WriteLine("---------- Araç Kiralama İptal Ekranı ----------");
            Console.WriteLine("Araç Kiralama Id:");
            int    id           = Convert.ToInt32(Console.ReadLine());
            Rental deleteRental = new Rental {
                Id = id
            };

            var result = rentalManager.Delete(deleteRental);

            SuccessRental(result);
        }
Example #18
0
        private static void RentalTest()
        {
            DateTime      dateTime         = DateTime.Now;
            string        sqlFormattedDate = dateTime.ToString("2021-11-20");
            RentalManager rentalManager    = new RentalManager(new EfRentalDal());

            Rental rental = new Rental()
            {
                Id = 15, CarId = 2, CustomerId = 5, ReturnDate = sqlFormattedDate
            };

            rentalManager.Delete(rental);
            Console.WriteLine(Messages.RentalDeleted);
        }
        private static void RentalTest(RentalManager rentalManager)
        {
            rentalManager.Add(new Rental {
                CarId = 1, CustomerId = 1, RentDate = DateTime.Now, ReturnDate = DateTime.Now
            });
            foreach (var rent in rentalManager.GetAll().Data)
            {
                Console.WriteLine(rent.CustomerId);
            }

            rentalManager.Update(new Rental {
                Id = 5, CustomerId = 1, RentDate = DateTime.Now, ReturnDate = DateTime.Now
            });
            rentalManager.Delete(new Rental {
                Id = 6
            });
        }
Example #20
0
        static void RentalDelete(RentalManager rentalManager)
        {
            Rental deletedRental = new Rental();

            Console.Write("Silmek istediğiniz kiralamanın idsini giriniz : ");
            deletedRental.Id = int.Parse(Console.ReadLine());
            var result = rentalManager.Delete(deletedRental);

            if (result.Success)
            {
                Console.WriteLine(result.Message);
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Example #21
0
        private static void RentalDelete()
        {
            IRentalService rentalManager = new RentalManager(new EfRentalDal());
            var            result        = rentalManager.Delete(new Rental
            {
                RentalId   = 2,
                CarId      = 3,
                CustomerId = 2,
                RentDate   = new DateTime(2001 / 12 / 13),
                ReturnDate = new DateTime(2001 / 2 / 1)
            });

            if (result.Success == true)
            {
                Console.WriteLine(result.Message);
            }
        }
Example #22
0
        private static void RentalTest()
        {
            RentalManager rentalManager = new RentalManager(new EfRentalDal());
            var           result        = rentalManager.GetAll();

            foreach (var rental in result.Data)
            {
                Console.WriteLine(rental.RentDate);
            }
            rentalManager.Add(new Rental {
                Id = 1, CarId = 1, CustomerId = 1, RentDate = DateTime.Now, ReturnDate = null
            });
            rentalManager.Update(new Rental {
                Id = 1, CarId = 1, CustomerId = 1, RentDate = DateTime.Now, ReturnDate = null
            });
            rentalManager.Delete(new Rental {
                Id = 1
            });
        }
        /*public static void RentalAdd()
         * {
         *  Rental _rental = new Rental();
         *  UserManager userManager = new UserManager(new EfUserDal());
         *  CarManager carManager = new CarManager(new EfCarDal());
         *  RentalManager rentalManager = new RentalManager(new EfRentalDal());
         *  Console.WriteLine("Kullanıcı Şeçiniz (Id olarak giriniz) = ");
         *  foreach (var item in userManager.GetAll().Data)
         *  {
         *      Console.WriteLine("Id = "+item.Id+" First Name = "+item.FirstName);
         *  }
         *  Console.Write("Kullanıcı Şeçiniz (Id olarak giriniz) =  ");
         *  _rental.CustomerId =int.Parse( Console.ReadLine());
         *  Console.Clear();
         *  Console.WriteLine("Araç Şeçiniz = ");
         *  foreach (var item in carManager.GetAll().Data)
         *  {
         *      Console.WriteLine("Araç No =" +item.CarId + " | "
         +"Marka No = " + item.BrandId + "  |  "
         + "Renk No = " + item.ColorId + "  |  "
         + "Model Bilgisi = " + item.CarName + "  |  "
         + "Model Yılı = " + item.ModelYear + "  |  "
         + "Araç Açıklaması = " + item.Description + "  --->  "
         + "Günlük Ücret = " + item.DailyPrice + " TL");
         +  }
         +  Console.Write("Araç Şeçiniz (Id olarak giriniz) = ");
         +  _rental.CarId = int.Parse(Console.ReadLine());
         +  var carControl = rentalManager.GetRentalCarId(_rental.CarId);
         +  if (carControl.Success)
         +  {
         +      Console.Clear();
         +      Console.Write("Kiralama süresinin Başlangıcı (g/a/y) = ");
         +      _rental.RentDate = DateTime.Parse(Console.ReadLine());
         +      Console.Write("Kiralama süresinin Bitişi (g/a/y) = ");
         +      _rental.ReturnDate = DateTime.Parse(Console.ReadLine());
         +      var result = rentalManager.Add(_rental);
         +      if (result.Success)
         +      {
         +          Console.WriteLine(result.Message);
         +      }
         +      else
         +      {
         +          Console.WriteLine(result.Message);
         +      }
         +  }
         +  else
         +  {
         +      Console.WriteLine(carControl.Message);
         +  }
         + }*/

        public static void RentalDetete()
        {
            Rental        _rental       = new Rental();
            RentalManager rentalManager = new RentalManager(new EfRentalDal());

            Console.WriteLine("-------------ARAÇ KİRALAMA İPTAL İŞLEMİ--------------");
            RentalList();
            Console.Write("Kiralama No = ");
            int rentalId = int.Parse(Console.ReadLine());
            var result   = rentalManager.Delete(rentalId);

            if (result.Success == true)
            {
                Console.WriteLine(result.Message);
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }
Example #24
0
        private void RentalMenu_Delete(RentalManager rentalManager)
        {
            Console.WriteLine("\nList of All Rentals");
            rentalManager.WriteAll(rentalManager.GetAll().Data);

            bool IsExist  = false;
            int  searchID = 0;

            while (!IsExist)
            {
                Console.Write("-> Enter the ID of the rental you want to delete: ");
                searchID = Convert.ToInt32(Console.ReadLine());
                IsExist  = rentalManager.IsExistById(searchID).Success;
                if (!IsExist)
                {
                    Console.Write(Messages.ColorNotExist + " Try again. Rental ID: ");
                    searchID = Convert.ToInt32(Console.ReadLine());
                    IsExist  = rentalManager.IsExistById(searchID).Success;
                }
            }

            rentalManager.Delete(rentalManager.GetById(searchID).Data);
        }
Example #25
0
        private static void RentalManagerAll()
        {
            RentalManager rentalManager = new RentalManager(new EfRentalDal());
            var           result        = rentalManager.Add(new Rental
            {
                CustomerId = 15, RentDate = new DateTime(2015, 06, 5), ReturnDate = new DateTime(2015, 06, 5), CarId = 14
            });

            Console.WriteLine(result.Message);

            var result1 = rentalManager.Delete(new Rental {
                RentalId = 41
            });

            Console.WriteLine(result1.Message);
            var result2 = rentalManager.Update(new Rental {
                RentalId = 42, CustomerId = 15, RentDate = new DateTime(15 / 06 / 2021), ReturnDate = new DateTime(15 / 06 / 2021), CarId = 14
            });

            Console.WriteLine(result2.Message);
            var result3 = rentalManager.GetAll();

            if (result3.Success == true)
            {
                foreach (var item in result3.Data)
                {
                    Console.WriteLine("{0}\n{1}\n{2}\n{3}\n", item.CarId, item.CustomerId, item.RentDate, item.ReturnDate);
                }
            }
            var result4 = rentalManager.GetById(49);

            if (result4.Success == true)
            {
                Console.WriteLine(result4.Message);
                Console.WriteLine(result4.Data.CustomerId);
            }
        }
Example #26
0
        private static void RentalCrudTest()
        {
            RentalManager rentalManager = new RentalManager(new EfRentalDal());

            rentalManager.Add(new Rental
            {
                CarId      = 1,
                CustomerId = 1,
                RentDate   = Convert.ToDateTime(6 / 7 / 2020),
                ReturnDate = Convert.ToDateTime(6 / 7 / 2020)
            });
            rentalManager.Update(new Rental
            {
                RentId     = 2,
                CarId      = 1,
                CustomerId = 1,
                RentDate   = Convert.ToDateTime(6 / 7 / 2020),
                ReturnDate = Convert.ToDateTime(6 / 7 / 2020)
            });
            rentalManager.Delete(new Rental
            {
                CarId = 1
            });
        }
Example #27
0
        private static void RunRentalManager()
        {
            RentalManager rentalManager = new RentalManager(new EfRentalDal());
            int           options       = -1;

            while (options != 0)
            {
                Console.WriteLine("[1] List All Rentals\n" +
                                  "[2] Get Rental By ID\n" +
                                  "[3] Get All Rental With Details\n" +
                                  "[4] Add Rental\n" +
                                  "[5] Delete Rental\n" +
                                  "[6] Update Rental\n" +
                                  "[0] Exit Menu" +
                                  "");
                options = Convert.ToInt32(Console.ReadLine());
                switch (options)
                {
                case 1:
                    foreach (var rental in rentalManager.GetAll().Data)
                    {
                        Console.WriteLine("Rental ID: " + rental.RentalID);
                        Console.WriteLine("Customer ID: " + rental.CustomerID);
                        Console.WriteLine("Car ID: " + rental.CarID);
                        Console.WriteLine("Rent Date: " + rental.RentDate);
                        Console.WriteLine("Return Date: " + rental.ReturnDate);
                    }
                    break;

                case 2:
                    Console.WriteLine(rentalManager.GetID(2).Data.CarID);
                    Console.WriteLine(rentalManager.GetID(2).Data.CustomerID);
                    Console.WriteLine(rentalManager.GetID(2).Data.RentDate);
                    Console.WriteLine(rentalManager.GetID(2).Data.ReturnDate);
                    break;

                case 3:
                    var GetRentDetail = rentalManager.GetRentalDetails();
                    foreach (var rent in GetRentDetail.Data)
                    {
                        Console.WriteLine("No: {0}\n" +
                                          "Car: {1}\n" +
                                          "First Name: {2}\n" +
                                          "Last Name: {3}\n" +
                                          "Email: {4}\n" +
                                          "Rent Date: {5}\n" +
                                          "Return Date: {6}\n" +
                                          "Daily Price: {7} $\n" +
                                          "----------------------------",
                                          rent.RentalID, rent.CarName, rent.FirstName, rent.LastName, rent.Email, rent.RentDate, rent.ReturnDate, rent.DailyPrice);
                    }
                    Console.WriteLine(GetRentDetail.Message);
                    break;

                case 4:
                    //rentalManager.Add(new Rental { CompanyName = "Holy Mustance", UserID = 2 });
                    Console.WriteLine("Rent Added.");
                    break;

                case 5:
                    Console.WriteLine("-Enter Rental ID-");
                    int deletedrental = Convert.ToInt32(Console.ReadLine());
                    rentalManager.Delete(new Rental {
                        CustomerID = deletedrental
                    });
                    break;

                case 6:
                    Console.WriteLine("-Enter Rental ID-");
                    int updatedrental = Convert.ToInt32(Console.ReadLine());
                    rentalManager.Update(new Rental
                    {
                        RentalID   = updatedrental,
                        RentDate   = DateTime.Now,
                        ReturnDate = DateTime.Now
                    });
                    break;

                default:
                    break;
                }
            }
        }
Example #28
0
        static void Main(string[] args)
        {
            CarManager      carManager      = new CarManager(new EfCarDal());
            BrandManager    brandManager    = new BrandManager(new EfBrandDal());
            ColorManager    colorManager    = new ColorManager(new EfColorDal());
            UserManager     userManager     = new UserManager(new EfUserDal());
            CustomerManager customerManager = new CustomerManager(new EfCustomerDal());
            RentalManager   rentalManager   = new RentalManager(new EfRentalDal());

            GetCarDetails(carManager);
            GetAll(carManager);

            Console.WriteLine("\n====================================== Rent A Car ======================================");
            Console.WriteLine("1. Araba Ekle\n" + "2. Araba Sil\n" + "3. Araba Güncelle\n" + "4. Araba Listele\n\n" +
                              "5. Kullanıcı Ekle\n" + "6. Kullanıcı Sil\n" + "7. Kullanıcı Güncelle\n" + "8. Kullanıcı Listele\n\n" +
                              "9. Müşteri Ekle\n" + "10. Müşteri Sil\n" + "11. Müşteri Güncelle\n" + "12. Müşteri Listele\n\n" +
                              "13. Araba Kirala\n" + "14. Araba Teslim Al\n" + "15. Araba Kirası Güncelle\n" + "16. Kiralanmış Arabaları Listele\n\n" +
                              "99. Çıkış\n");


            bool exit = true;

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

            while (exit)
            {
                Console.Write("\nBir işlem seçin: ");
                int number = Convert.ToInt32(Console.ReadLine());

                switch (number)
                {
                case 1:
                    GetAll(brandManager);
                    GetAll(colorManager);

                    Console.Write("\nBrand Id: ");
                    int brandIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nColor Id: ");
                    int colorIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nDaily Price: ");
                    decimal dailyPriceForAdd = Convert.ToDecimal(Console.ReadLine());

                    Console.Write("\nDescription : ");
                    string descriptionForAdd = Console.ReadLine();

                    Console.Write("\nModel Year: ");
                    int modelYearForAdd = Convert.ToInt32(Console.ReadLine());

                    Car carForAdd = new Car {
                        BrandId = brandIdForAdd, ColorId = colorIdForAdd, DailyPrice = dailyPriceForAdd, Description = descriptionForAdd, ModelYear = modelYearForAdd
                    };
                    carManager.Add(carForAdd);
                    break;

                case 2:
                    GetAll(carManager);

                    Console.Write("Hangi Id'li arabayı silmek istiyorsunuz? ");
                    int carIdForDelete = Convert.ToInt32(Console.ReadLine());
                    carManager.Delete(carManager.GetById(carIdForDelete).Data);
                    break;

                case 3:
                    GetAll(carManager);

                    Console.Write("\nId: ");
                    int carIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nBrand Id: ");
                    int brandIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nColor Id: ");
                    int colorIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nDaily Price: ");
                    decimal dailyPriceForUpdate = Convert.ToDecimal(Console.ReadLine());

                    Console.Write("\nDescription : ");
                    string descriptionForUpdate = Console.ReadLine();

                    Console.Write("\nModel Year: ");
                    int modelYearForUpdate = Convert.ToInt32(Console.ReadLine());

                    Car carForUpdate = new Car {
                        Id = carIdForUpdate, BrandId = brandIdForUpdate, ColorId = colorIdForUpdate, DailyPrice = dailyPriceForUpdate, Description = descriptionForUpdate, ModelYear = modelYearForUpdate
                    };
                    carManager.Update(carForUpdate);
                    break;

                case 4:
                    GetAll(carManager);
                    break;

                case 5:
                    GetAll(userManager);

                    Console.Write("\nFirst Name: ");
                    string firstNameForAdd = Console.ReadLine();

                    Console.Write("\nLast Name: ");
                    string lastNameForAdd = Console.ReadLine();

                    Console.Write("\nEmail: ");
                    string emailForAdd = Console.ReadLine();

                    Console.Write("\nPassword: "******"Hangi Id'li kullanıcını silmek istiyorsunuz? ");
                    int userIdForDelete = Convert.ToInt32(Console.ReadLine());
                    userManager.Delete(userManager.GetById(userIdForDelete).Data);
                    break;

                case 7:
                    GetAll(userManager);

                    Console.Write("\nId: ");
                    int userIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nFirst Name: ");
                    string firstNameForUpdate = Console.ReadLine();

                    Console.Write("\nLast Name: ");
                    string lastNameForUpdate = Console.ReadLine();

                    Console.Write("\nEmail: ");
                    string emailForUpdate = Console.ReadLine();

                    Console.Write("\nPassword: "******"\nUser Id: ");
                    int userIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCustomer Name: ");
                    string customerNameForAdd = Console.ReadLine();

                    Customer customerForAdd = new Customer {
                        UserId = userIdForAdd, CompanyName = customerNameForAdd
                    };
                    customerManager.Add(customerForAdd);
                    break;

                case 10:
                    GetAll(customerManager);

                    Console.Write("Hangi Id'li müşterini silmek istiyorsunuz? ");
                    int customerIdForDelete = Convert.ToInt32(Console.ReadLine());
                    customerManager.Delete(customerManager.GetById(customerIdForDelete).Data);
                    break;

                case 11:
                    GetAll(customerManager);
                    GetAll(userManager);

                    Console.Write("\nId: ");
                    int customerIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nUser Id: ");
                    int customerUserIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCustomer Name: ");
                    string customerNameForUpdate = Console.ReadLine();

                    Customer customerForUpdate = new Customer {
                        Id = customerIdForUpdate, UserId = customerUserIdForUpdate, CompanyName = customerNameForUpdate
                    };
                    customerManager.Update(customerForUpdate);
                    break;

                case 12:
                    GetAll(customerManager);
                    break;

                case 13:
                    GetAll(carManager);
                    GetAll(customerManager);
                    GetAll(rentalManager);

                    Console.Write("\nCar Id: ");
                    int carIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCustomer Id: ");
                    int customerIdForAdd = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nRent Date: ");
                    DateTime rentDateForAdd = Convert.ToDateTime(Console.ReadLine());

                    Console.Write("\nReturn Date: ");
                    DateTime returnDateForAdd = Convert.ToDateTime(Console.ReadLine());

                    Rental rentalForAdd = new Rental {
                        CarId = carIdForAdd, CustomerId = customerIdForAdd, RentDate = rentDateForAdd, ReturnDate = returnDateForAdd
                    };
                    rentalManager.Add(rentalForAdd);
                    break;

                case 14:
                    GetAll(rentalManager);

                    Console.Write("Hangi Id'li kiralanmış arabanı teslim almak istiyorsunuz? ");
                    int rentalIdForDelete = Convert.ToInt32(Console.ReadLine());
                    rentalManager.Delete(rentalManager.GetById(rentalIdForDelete).Data);
                    break;

                case 15:
                    GetAll(carManager);
                    GetAll(customerManager);
                    GetAll(rentalManager);

                    Console.Write("\nId: ");
                    int rentalIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCar Id: ");
                    int rentalCarIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nCustomer Id: ");
                    int rentalCustomerIdForUpdate = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nRent Date: ");
                    DateTime rentDateForUpdate = Convert.ToDateTime(Console.ReadLine());

                    Console.Write("\nReturn Date: ");
                    DateTime returnDateForUpdate = Convert.ToDateTime(Console.ReadLine());

                    Rental rentalForUpdate = new Rental {
                        Id = rentalIdForUpdate, CarId = rentalCarIdForUpdate, CustomerId = rentalCustomerIdForUpdate, RentDate = rentDateForUpdate, ReturnDate = returnDateForUpdate
                    };
                    rentalManager.Update(rentalForUpdate);
                    break;

                case 16:
                    GetAll(rentalManager);
                    break;

                case 99:
                    exit = false;
                    break;
                }
            }
        }
Example #29
0
        static void Main(string[] args)
        {
            Car car1 = new Car {
                BrandId = 1, ColorId = 5, CarName = "FORD FOCUS", DailyPrice = 120, ModelYear = 2019, Description = "Düz Vites"
            };
            Brand brand1 = new Brand {
                Name = "FORD"
            };
            Color color1 = new Color {
                Name = "Beyaz"
            };

            Car car2 = new Car {
                BrandId = 2, ColorId = 4, CarName = "RENAULT MEGANE", DailyPrice = 150, ModelYear = 2020, Description = "Otomatik Vites"
            };
            Brand brand2 = new Brand {
                Name = "RENAULT"
            };
            Color color2 = new Color {
                Name = "Gri"
            };

            Car car3 = new Car {
                BrandId = 3, ColorId = 3, CarName = "TOYOTA COROLLA", DailyPrice = 100, ModelYear = 2018, Description = "Düz Vites"
            };
            Brand brand3 = new Brand {
                Name = "TOYOTA"
            };
            Color color3 = new Color {
                Name = "Mavi"
            };

            Car car4 = new Car {
                BrandId = 1, ColorId = 4, CarName = "FORD FOCUS", DailyPrice = 140, ModelYear = 2019, Description = "Otomatik Vites"
            };
            Brand brand4 = new Brand {
                Name = "FORD"
            };
            Color color4 = new Color {
                Name = "Gri"
            };

            CarManager    carManager    = new CarManager(new EfCarDal());
            BrandManager  brandManager  = new BrandManager(new EfBrandDal());
            ColorManager  colorManager  = new ColorManager(new EfColorDal());
            RentalManager rentalManager = new RentalManager(new EfRentalDal());

            //carManager.Add(new Car { BrandId = 7, ColorId = 4, CarName = "Skoda Octavia", DailyPrice = 180, ModelYear = 2019, Description = "Duz Vites" });

            //carManager.Add(car1);
            //brandManager.Add(brand1);
            //colorManager.Add(color1);

            //carManager.Add(car2);
            //brandManager.Add(brand2);
            //colorManager.Add(color2);

            //carManager.Add(car3);
            //brandManager.Add(brand3);
            //colorManager.Add(color3);

            //carManager.Add(car4);
            //brandManager.Add(brand4);
            //colorManager.Add(color4);

            //var result1 = carManager.GetAll();

            //foreach (var car in result1.Data)
            //{
            //    Console.WriteLine(car.CarName+" / "+car.Description);
            //}

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

            //var result2 = carManager.GetCarDetail();

            //foreach (var detail in result2.Data)
            //{
            //    Console.WriteLine(detail.CarName + " / " +detail.BrandName + " / " +detail.ColorName + " / " +detail.DailyPrice);
            //}

            var Result = rentalManager.Delete(new Rental {
                CarId = 1, CustomerId = 4, RentDate = new DateTime(2021, 1, 20, 10, 30, 00), ReturnDate = new DateTime(2021, 2, 1, 15, 00, 00)
            });
        }
Example #30
0
        private static void RentalTest()
        {
            Console.WriteLine("--------- RENTAL TEST ---------");
            IRentalService rentalManager = new RentalManager(new EfRentalDal());

            Console.WriteLine("--------- GetAll ---------");
            foreach (var rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine(rental.RentalId + " " + rental.ReturnDate);
            }

            Console.WriteLine("--------- GetById ---------");
            Console.WriteLine(rentalManager.GetById(1).Data.RentalId + " " + rentalManager.GetById(1).Data.ReturnDate);

            Console.WriteLine("--------- Add ---------");
            var resultAdd = rentalManager.Add(new Rental {
                RentalId = 6, CarId = 1, CustomerId = 1, RentDate = DateTime.Now, ReturnDate = null
            });

            Console.WriteLine(resultAdd.Message);
            foreach (var rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine(rental.RentalId + " " + rental.ReturnDate);
            }

            Console.WriteLine("--------- Cars That Can Be Rented ---------");
            CarManager carManager = new CarManager(new EfCarDal());

            foreach (var rental in rentalManager.GetAll().Data)
            {
                if (rental.ReturnDate != null)
                {
                    Console.WriteLine(carManager.GetById(rental.CarId).Data.CarName);
                }
            }

            Console.WriteLine("--------- Rental Process Fail ---------");
            Console.WriteLine(rentalManager.Add(new Rental {
                RentalId = 7, CarId = 1, CustomerId = 1, RentDate = DateTime.Now, ReturnDate = null
            }).Message);

            Console.WriteLine("--------- Update ---------");
            var resultUpdate = rentalManager.Update(new Rental {
                RentalId = 6, CarId = 1, CustomerId = 1, RentDate = DateTime.Now, ReturnDate = DateTime.Now
            });

            Console.WriteLine(resultUpdate.Message);
            foreach (var rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine(rental.RentalId + " " + rental.ReturnDate);
            }

            Console.WriteLine("--------- Delete ---------");
            var resultDelete = rentalManager.Delete(new Rental {
                RentalId = 6
            });

            Console.WriteLine(resultDelete.Message);
            foreach (var rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine(rental.RentalId + " " + rental.ReturnDate);
            }
        }