Example #1
0
        public static List <Book> ConvertFileToList()
        {
            List <Book> books = new List <Book>();
            FileHandler file  = new FileHandler();

            string[] fileContent;

            file.FileName = "LIVRO.csv";

            fileContent = FileHandlerController.ReadFile(file);

            if (fileContent != null)
            {
                foreach (var lineContent in fileContent)
                {
                    string[] lineBook = lineContent.Split(';');

                    Book book = new Book
                    {
                        TumbleNumber    = long.Parse(lineBook[0]),
                        ISBN            = lineBook[1],
                        Title           = lineBook[2],
                        Genre           = lineBook[3],
                        PublicationDate = Convert.ToDateTime(lineBook[4]),
                        Author          = lineBook[5]
                    };

                    books.Add(book);
                }
            }

            return(books);
        }
Example #2
0
        private static List <BookLoan> ConvertFileToList()
        {
            List <BookLoan> loanedsBooks = new List <BookLoan>();
            FileHandler     file         = new FileHandler();

            string[] fileContent;

            file.FileName = "EMPRESTIMO.csv";

            fileContent = FileHandlerController.ReadFile(file);

            if (fileContent != null)
            {
                foreach (var lineContent in fileContent)
                {
                    string[] lineLoan = lineContent.Split(';');

                    BookLoan bookLoan = new BookLoan
                    {
                        IdCustomer     = long.Parse(lineLoan[0]),
                        TumbleNumber   = long.Parse(lineLoan[1]),
                        LoanDate       = Convert.ToDateTime(lineLoan[2]),
                        DevolutionDate = Convert.ToDateTime(lineLoan[3]),
                        LoanStatus     = int.Parse(lineLoan[4])
                    };

                    loanedsBooks.Add(bookLoan);
                }
            }

            return(loanedsBooks);
        }
Example #3
0
        public static List <Customer> ConvertFileToList()
        {
            List <Customer> customers = new List <Customer>();
            FileHandler     file      = new FileHandler();

            string[] fileContent;

            file.FileName = "CLIENTE.csv";

            fileContent = FileHandlerController.ReadFile(file);

            if (fileContent != null)
            {
                foreach (var lineContent in fileContent)
                {
                    string[] lineCustomer = lineContent.Split(';');

                    Customer customer = new Customer {
                        IdCustomer    = long.Parse(lineCustomer[0]),
                        Cpf           = lineCustomer[1],
                        Name          = lineCustomer[2],
                        DateOfBorning = Convert.ToDateTime(lineCustomer[3]),
                        Telephone     = lineCustomer[4],
                        PublicPlace   = lineCustomer[5],
                        Neighborhood  = lineCustomer[6],
                        City          = lineCustomer[7],
                        State         = lineCustomer[8],
                        ZipCode       = lineCustomer[9]
                    };

                    customers.Add(customer);
                }
            }

            return(customers);
        }