Example #1
0
        private static bool BookAvailable(long bookTumbleNumber)
        {
            bool available = true;

            FileHandler file = new FileHandler();

            file.FileName = "EMPRESTIMO.csv";

            if (FileHandlerController.CreateDirectoryAndFile(file))
            {
                available = true;
            }
            else
            {
                List <BookLoan> loanedsBooks = ConvertFileToList();
                if (loanedsBooks.Count > 0)
                {
                    for (int i = (loanedsBooks.Count - 1); i >= 0; i--)
                    {
                        if (loanedsBooks[i].TumbleNumber == bookTumbleNumber)
                        {
                            if (loanedsBooks[i].LoanStatus == 1)
                            {
                                available = false;
                                break;
                            }
                        }
                    }
                }
            }

            return(available);
        }
Example #2
0
        private static bool BookExists(string bookISBN)
        {
            bool exists = false;

            FileHandler file = new FileHandler();

            file.FileName = "LIVRO.csv";

            if (FileHandlerController.CreateDirectoryAndFile(file))
            {
                exists = false;
            }
            else
            {
                List <Book> books = ConvertFileToList();
                for (int i = 0; i < books.Count; i++)
                {
                    if (books[i].ISBN.Equals(bookISBN))
                    {
                        exists = true;
                        break;
                    }
                }
            }

            return(exists);
        }
Example #3
0
        private static bool CustomerExists(string customerCpf)
        {
            bool exists = false;

            FileHandler file = new FileHandler();

            file.FileName = "CLIENTE.csv";

            if (FileHandlerController.CreateDirectoryAndFile(file))
            {
                exists = false;
            }
            else
            {
                List <Customer> customers = ConvertFileToList();
                for (int i = 0; i < customers.Count; i++)
                {
                    if (customers[i].Cpf.Equals(customerCpf))
                    {
                        exists = true;
                        break;
                    }
                }
            }

            return(exists);
        }
Example #4
0
        public static bool BookExists(long bookTumbleNumber)
        {
            bool exists = false;

            FileHandler file = new FileHandler();

            file.FileName = "LIVRO.csv";

            if (FileHandlerController.CreateDirectoryAndFile(file))
            {
                exists = false;
            }
            else
            {
                List <Book> books = ConvertFileToList();
                for (int i = 0; i < books.Count; i++)
                {
                    if (books[i].TumbleNumber == bookTumbleNumber)
                    {
                        exists = true;
                        break;
                    }
                }
            }

            return(exists);
        }
Example #5
0
        public static long CustomerExistsAndReturnId(string customerCpf)
        {
            long idCustomer = 0;

            FileHandler file = new FileHandler();

            file.FileName = "CLIENTE.csv";

            if (FileHandlerController.CreateDirectoryAndFile(file))
            {
                idCustomer = 0;
            }
            else
            {
                List <Customer> customers = ConvertFileToList();
                for (int i = 0; i < customers.Count; i++)
                {
                    if (customers[i].Cpf.Equals(customerCpf))
                    {
                        idCustomer = customers[i].IdCustomer;
                        break;
                    }
                }
            }

            return(idCustomer);
        }