Exemplo n.º 1
0
        public string Output()
        {
            WinFormOutputAuthoredItem output = new WinFormOutputAuthoredItem();
            SetItem bookSetter = new SetItem();

            return(output.ListOutput(BookList.GetBookList(bookSetter).GenerateList()).ToString());
        }
Exemplo n.º 2
0
        public void InitializeList()
        {
            AbstractSerialize serializeObj = new FileHandling();
            BookList          bookListObj  = BookList.GetBookList();

            serializeObj.ReadBookList();
            Book.BookCount = bookListObj.ListOfBooks.Count;
        }
Exemplo n.º 3
0
 public override void WriteBookList()
 {
     using (FileStream fs = new FileStream(FILE_PATH_BOOK, FileMode.OpenOrCreate, FileAccess.Write))
     {
         BinaryFormatter bf          = new BinaryFormatter();
         BookList        BookListObj = BookList.GetBookList();
         bf.Serialize(fs, BookListObj.ListOfBooks);
     }
 }
Exemplo n.º 4
0
 public override void ReadBookList()
 {
     using (FileStream fs = new FileStream(FILE_PATH_BOOK, FileMode.OpenOrCreate, FileAccess.Read))
     {
         BinaryFormatter bf          = new BinaryFormatter();
         BookList        BookListObj = BookList.GetBookList();
         BookListObj.ListOfBooks = (List <Book>)bf.Deserialize(fs);
     }
 }
Exemplo n.º 5
0
 public bool ReturnBook(Book bk)
 {
     try
     {
         BookList bookListObj = BookList.GetBookList();
         bookListObj.ReturnBook(bk);
         AbstractSerialize serializeObj = new FileHandling();
         serializeObj.WriteBookList();
         return(true);
     }
     catch (Exception ex)
     { return(false); }
 }
Exemplo n.º 6
0
        public LocalDataSource()
        {
            var booksSource   = new BookList();
            var existingBooks = booksSource.GetBookList();

            _books = new List <IBook>();

            foreach (var book in existingBooks)
            {
                _books.Add(book);
            }

            _users = new List <IUser>();
        }
Exemplo n.º 7
0
        public bool AddNewBook(string bookName, string bookAuthor)
        {
            AbstractSerialize serializeObj = new FileHandling();
            BookList          bookListObj  = BookList.GetBookList();

            serializeObj.ReadBookList();
            Book.BookCount = bookListObj.ListOfBooks.Count;

            if (bookListObj.AddBook(bookName, bookAuthor))
            {
                serializeObj.WriteBookList();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        public Library()
        {
            InitializeComponent();

            var bookListFromFile    = new BookList();
            var mTakenBookPresenter = new TakenBookPresenter
                                          (new BookRepository(StaticDataSource.DataSource));
            var books      = bookListFromFile.GetBookList();
            var takenBooks = mTakenBookPresenter.GetTakenBooks();

            foreach (var book in takenBooks)
            {
                if (book.TakenByUser == StaticDataSource.CurrUser)
                {
                    var book1 = books.First(item => item.Code == book.Code);
                    bookListBox.Items.Add(book1.Author + book1.Title + " RETURN ON " + book.HasToBeReturned);
                }
            }
        }
Exemplo n.º 9
0
        public Book GetBook(int id)
        {
            BookList bookListObj = BookList.GetBookList();

            return(bookListObj.GetBook(id));
        }