Ejemplo n.º 1
0
        public static void BorrowALibraryElement(OrdinaryUser LoggedOrdinaryUser)
        {
            ushort id;
            byte   type;

            Console.Clear();

            Console.WriteLine("Wypożyczalnia");
            Console.WriteLine("___________________________");

            Console.Write("Podaj typ elementu:\nKsiążka: 1\nFilm: 2\n");
            type = byte.Parse(Console.ReadLine());

            if (type == 1)
            {
                Console.Write("Podaj ID elementu: ");
                id = ushort.Parse(Console.ReadLine());

                if (TextFileHandler.CheckIfBookExistsById(id) && TextFileHandler.CheckIfBookStatusIsAvailable(id))
                {
                    //int availableBorrowingIdTmp = TextFileHandler.GetCurrentBorrowingID(LoggedOrdinaryUser) + 1;

                    //LoggedOrdinaryUser.BorrowLibraryElement(DateTime.Now, id, type, availableBorrowingIdTmp);

                    TextFileHandler.BorrowRequestAddToFile(DateTime.Now, id, type, LoggedOrdinaryUser.UserID);
                    TextFileHandler.ChangeBookStatusToPending(id);

                    Console.WriteLine("Element oczekuje na zatwierdzenie");
                }
                else
                {
                    Console.WriteLine("Podano błędne ID elementu!");
                    Console.ReadKey();
                    //BorrowALibraryElement(LoggedOrdinaryUser);
                }
            }
            else if (type == 2)
            {
                Console.Write("Podaj ID elementu: ");
                id = ushort.Parse(Console.ReadLine());

                if (TextFileHandler.CheckIfMovieExistsById(id) && TextFileHandler.CheckIfMovieStatusIsAvailable(id))
                {
                    //int availableBorrowingIdTmp = TextFileHandler.GetCurrentBorrowingID(LoggedOrdinaryUser) + 1;

                    //LoggedOrdinaryUser.BorrowLibraryElement(DateTime.Now, id, type, availableBorrowingIdTmp);

                    TextFileHandler.BorrowRequestAddToFile(DateTime.Now, id, type, LoggedOrdinaryUser.UserID);
                    TextFileHandler.ChangeMovieStatusToPending(id);

                    Console.WriteLine("Element oczekuje na zatwierdzenie");
                }
                else
                {
                    Console.WriteLine("Podano błędne ID elementu!");
                    Console.ReadKey();
                    //BorrowALibraryElement(LoggedOrdinaryUser);
                }
            }
            else
            {
                Console.WriteLine("Podano zły typ elementu!");
                Console.ReadKey();
                BorrowALibraryElement(LoggedOrdinaryUser);
            }

            Console.ReadKey();
        }