Example #1
0
        private static void ConvertListForWriteFile(Book book)
        {
            List <Book> books = ConvertFileToList();
            FileHandler file  = new FileHandler();

            file.FileName = "LIVRO.csv";
            books.Add(book);

            StringBuilder bookSb = new StringBuilder();

            foreach (var sbBook in books)
            {
                bookSb.Append(sbBook.ToStringForWriteFile());
                bookSb.AppendLine();
            }

            string[] booksForWrite = bookSb.ToString().Split('\n');

            FileHandlerController.WriteInFile(file, booksForWrite);
        }
Example #2
0
        private static void ConvertListForWriteFile(Customer customer)
        {
            List <Customer> customers = ConvertFileToList();
            FileHandler     file      = new FileHandler();

            file.FileName = "CLIENTE.csv";
            customers.Add(customer);

            StringBuilder customerSb = new StringBuilder();

            foreach (var sbCustomer in customers)
            {
                customerSb.Append(sbCustomer.ToStringForWriteFile());
                customerSb.AppendLine();
            }

            string[] customersForWrite = customerSb.ToString().Split('\n');

            FileHandlerController.WriteInFile(file, customersForWrite);
        }
Example #3
0
        private static void ConvertListForWriteFile(BookLoan bookLoan, bool update = false)
        {
            List <BookLoan> loanedsBooks = ConvertFileToList();
            FileHandler     file         = new FileHandler();

            file.FileName = "EMPRESTIMO.csv";

            if (!update)
            {
                loanedsBooks.Add(bookLoan);
            }
            else
            {
                for (int i = (loanedsBooks.Count - 1); i >= 0; i--)
                {
                    if (loanedsBooks[i].TumbleNumber == bookLoan.TumbleNumber)
                    {
                        if (loanedsBooks[i].LoanStatus == 1)
                        {
                            loanedsBooks[i].LoanStatus = 2;
                            break;
                        }
                    }
                }
            }

            StringBuilder bookLoanSb = new StringBuilder();

            foreach (var sbBookLoan in loanedsBooks)
            {
                bookLoanSb.Append(sbBookLoan.ToStringForWriteFile());
                bookLoanSb.AppendLine();
            }

            string[] booksLoanForWrite = bookLoanSb.ToString().Split('\n');

            FileHandlerController.WriteInFile(file, booksLoanForWrite);
        }