public BookEntity GetBook(string bookTitle) { BookEntity book = new BookEntity(); foreach (BookEntity bookItem in _bookTable) { if (bookItem.BookTitle == bookTitle) { return bookItem; } } return null; }
public bool RegisterBook(BookEntity newBookEntity) { int idCounter = 1; foreach (BookEntity book in _bookTable) { if ((book.BookTitle == newBookEntity.BookTitle)&&(book.AuthorName == newBookEntity.AuthorName)) { return false; } idCounter++; } newBookEntity.Id = idCounter; _bookTable.Add(newBookEntity); return true; }
public bool RegisterBook(BookDto NewBook) { BookEntity bookEntity = new BookEntity(); bookEntity.BookTitle = NewBook.BookTitle; bookEntity.AuthorName = NewBook.AuthorName; if (_dblibrary.RegisterBook(bookEntity)) { //Console.ForegroundColor = ConsoleColor.DarkYellow; //Console.WriteLine("LibraryService - Libro creado correctamente\n"); //Console.ForegroundColor = ConsoleColor.White; return true; } else { //Console.ForegroundColor = ConsoleColor.DarkYellow; //Console.WriteLine("LibraryService - El libro no se ha creado en el sistema\n"); //Console.ForegroundColor = ConsoleColor.White; return false; } }