Пример #1
0
        /// <summary>
        /// Adds the book to the database and notifies the subscribers of the Update.
        /// </summary>
        /// <param name="b">The book to be added to the database</param>
        public void Add(Book b)
        {
            bookRepository.Add(b);
            var e = EventArgs.Empty;

            OnUpdated(e);
        }
Пример #2
0
        public void Add(Book bok)
        {
            EventArgs ev = new EventArgs();

            _bookRepository.Add(bok);
            OnChanged(this, ev);
        }
Пример #3
0
        public void AddBook(Book book)
        {
            bookRepository.Add(book);

            if (Updated != null)
            {
                Updated(this, EventArgs.Empty);
            }
        }
Пример #4
0
 /// <summary>
 /// Method to add a book to the database.
 /// </summary>
 /// <param name="book">Book</param>
 public void AddBook(Book book)
 {
     if (null != bookRepository.Find(book.ISBN))
     {
         throw new ArgumentException("Trying to add aready existing book according to ISBN no: " + book.ISBN + ".");
     }
     bookRepository.Add(book);
     Updated.Invoke(this, new EventArgs());
 }
Пример #5
0
 /// <summary>
 /// Adds a book to the repository and raises the Updated-event.
 /// </summary>
 /// <param name="book">The book to be added</param>
 public void Add(Book book)
 {
     if (IsObjectNotNull(book))
     {
         bookRepository.Add(book);
         OnUpdated(this, eventArgs);
     }
     else
     {
         throw new ArgumentNullException("No book selected");
     }
 }
Пример #6
0
 /// <summary>
 /// Adds a book and raises the OnChanged() event.
 /// </summary>
 /// <param name="b">The book to be added</param>
 public void Add(Book b)
 {
     if (b != null)
     {
         bookRepository.Add(b);
         OnChanged(EventArgs.Empty);
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
Пример #7
0
        public void AddBook(string title, int isbn, string description, Author author)
        {
            EventArgs a    = new EventArgs();
            Book      book = new Book();

            book.Title       = title;
            book.ISBN        = isbn;
            book.Description = description;
            book.Author      = author;

            _bookRepository.Add(book);

            OnUpdated(EventArgs.Empty);

            //fixa exception
        }
Пример #8
0
        public void Add(string bookName, Author Author, string isbn, string description, int?publishedyear)
        {
            bool copyAdded = false;

            foreach (var book in _bookRepository.All())
            {
                if (isbn == book.ISBN)
                {
                    book.AddCopy();
                    copyAdded = true;
                    break;
                }
            }

            if (!copyAdded)
            {
                if (bookName == "" || description == "" || (publishedyear ?? 0) == 0)
                {
                    System.Windows.Forms.MessageBox.Show("You need to fill out all of the fields to add a book");
                }
                else if (Author == null)
                {
                    System.Windows.Forms.MessageBox.Show("Please select an author from the list, if the author is not there you have to add the author first.");
                }
                else if (!validISBN(isbn))
                {
                    System.Windows.Forms.MessageBox.Show("Please enter a valid ISBN");
                }
                else
                {
                    _bookRepository.Add(new Book()
                    {
                        Title         = bookName,
                        ISBN          = isbn,
                        desc          = description,
                        author        = Author,
                        publishedYear = (int)publishedyear
                    });
                }
            }
            OnUpdate(new EventArgs());
        }
Пример #9
0
 public void Add(Book b)
 {
     bookRepository.Add(b);
     OnUpdate();
 }
Пример #10
0
 /// <summary>
 /// The add method, used to add a book to the database
 /// </summary>
 /// <param name="item">Book to add</param>
 public void Add(Book item)
 {
     bookRepo.Add(item);
     OnUpdated(EventArgs.Empty);
 }
Пример #11
0
 /// <summary>
 /// Method to add books to db
 /// </summary>
 /// <param name="book"> Takes a book object</param>
 public void Add(Book book)
 {
     bookRepository.Add(book);
     // TODO: Raise the Updated event.
 }
Пример #12
0
 /// <summary>
 /// Adds a book to the database.
 /// </summary>
 /// <param name="b"></param>
 public void Add(Book b)
 {
     bookRepository.Add(b);
 }
Пример #13
0
 // Standard query-methods implemented by the IService interface (CRUD functions). -->
 /// <summary>
 /// Validates and sends a book object to repository for adding to database and then raises the OnUpdated event.
 /// </summary>
 /// <param name="book">Book object to be added to database.</param>
 public void Add(Book book)
 {
     ValidateInputs(book, true);
     BookRepository.Add(book);
     OnUpdated(book, EventArgs.Empty);
 }
Пример #14
0
 public void Add(Book book)
 {
     bookRepository.Add(book);
     OnUpdated();
 }
Пример #15
0
 /// <summary>
 /// Uses the Book repository to add a new Book object to the database and then raises the Updated() event.
 /// </summary>
 /// <param name="b">The Book object to be added to the database.</param>
 public void Add(Book b)
 {
     bookRepository.Add(b);
     OnUpdated(this, EventArgs.Empty);
 }