예제 #1
0
        public static void Loan()
        {
            Device        device = new Device();
            List <Device> Listofchoosendevices = new List <Device>();
            Lending       loan = new Lending();



            Setup.Headder();
            Setup.ShowWhoIsLoggedIn();

            Console.WriteLine("Define Lending Period:  Now to dd.mm.yyyy");
            Console.Write("Enter returndate: ");
            DateTime enddate = DateTime.Parse(Console.ReadLine());


            Console.WriteLine("Available PC: \n");
            List <Device> available = LendingReceiptRepository.Instance.ReturnAvailableDevicesForGivenPeriod(DateTime.Now, enddate);

            available.ForEach(Device => Console.WriteLine(Device.ToString()));


            string choice = "";


            do
            {
                Console.WriteLine("\nChoose PC to add to Loan, end selection with x");
                choice = Console.ReadLine();
                if (choice != "x")
                {
                    Listofchoosendevices.Add(DeviceRepository.StaticInstance.GetDevice(choice));
                    Listofchoosendevices.ForEach(Device => Console.WriteLine(Device.ToString()));
                }
            }while (choice != "x");


            Console.WriteLine("You have chosen ");

            Listofchoosendevices.ForEach(Device => Console.WriteLine(Device.ToString()));


            Console.WriteLine("Enter Name and Email on Person borrowing the/theese device/s.");
            string loanerinfo = Console.ReadLine();

            Console.Write("Enter Casenumber: ");
            string casenumber = Console.ReadLine();



            loan.EndDate   = enddate;
            loan.StartDate = DateTime.Now;
            loan.Devices   = Listofchoosendevices;

            LendingReceiptRepository.Instance.CreateLendingReceipt(loanerinfo, casenumber, loan, MainWindow.Initials);

            Console.WriteLine("Following Receipt has been created: ");

            Console.WriteLine(LendingReceiptRepository.Instance.FindReceiptByCasenumber(casenumber).ToString());
            LendingReceiptRepository.Instance.FindReceiptByCasenumber(casenumber).Loan.Devices.ForEach(Device => Console.WriteLine(Device.ToString()));
            LendingReceiptRepository.Instance.FindReceiptByCasenumber(casenumber).Loan.Status = Lending.Udlaan.Udlaant;
            Console.ReadLine();
            LendingReceiptRepository.Instance.SaveData();
            LendingReceiptRepository.Instance.LoadData();
        }