Пример #1
0
 public List<Loan> GetAllLoans(){
     List<Loan> loanList = new List<Loan>();
     string line;
     
     StreamReader file = new StreamReader("C:\\Loans.txt");
     while ((line = file.ReadLine()) != null)
     {
         string[] lines = line.Split('\t');
         Loan aux = new Loan(lines[0], lines[1], DateTime.Parse(lines[2]), DateTime.Parse(lines[3]));
         loanList.Add(aux);
     }
     file.Close();
     return loanList;
 }
Пример #2
0
        private static void LoanBook(List<Book> bookList, List<Loan> loanList)
        {
            foreach (Book b in bookList.Where(a => a.IsTaken == false))
            {
                Console.WriteLine(b.Code + " - " + b.Title);
            }
            Console.Write("Introduzca el código del libro que desea: ");
            string loanCode = Console.ReadLine();
            Book loanBook = bookList.FirstOrDefault(a => a.Code == loanCode);
            Console.Write("Enter your username: "******"Lo sentimos, el máximo de libros permitidos es 3.");
            }
            else
            {
                if (loanBook != null)
                {
                    Loan loan = new Loan(loanCode, user, DateTime.Now);
                    loanList.Add(loan);
                    loanBook.IsTaken = true;
                    Console.WriteLine("Libro alquilado:"+ loanBook.Title+", a devolver antes del:"+loan.DateReturn);
                }
                else
                {
                    Console.WriteLine("Libro equivocado.");
                }
            }

        }