private void AdjustBookList() { var subscriberPicked = _subscriberRepo.GetAllSubscriber().FirstOrDefault(sub => sub.Person.Name == _personMatches[0].Value && sub.Person.Surname == _personMatches[1].Value && sub.Person.DateOfBirth.Value == _personDateOfBirth); if (subscriberPicked != null) { if (subscriberPicked.TypeSubscription.BookLimitAtOnce <= _rentRepo.GetAllCurrentlyRented() .Count(rnt => rnt.PersonId == subscriberPicked.Person.PersonId)) { return; } } srchBookLabel.Visible = true; bookSearchTexBox.Visible = true; bookListView.Visible = true; var personMatch = _personRepo.GetPersonByNameSurnameDate(_personMatches[0].Value, _personMatches[1].Value, _personDateOfBirth); bookListView.Items.Clear(); foreach (var book in _typeBookRepo.GetAllBookTypes().Where(typBook => { var typeBookInQuestion = typBook.Title.Contains(bookSearchTexBox.Text) && typBook.PhysicalBooks.Count(bk => bk.State == BookState.Available) != 0; if (!typeBookInQuestion) { return(false); } return(!typBook.PhysicalBooks.Any(bk => bk.Rents.Any(rnt => rnt.PersonId == personMatch.PersonId && !rnt.ReturnDate.HasValue))); })) { bookListView.Items.Add($"{book.Title} by {book.AuthorInfo.AuthorPerson.Name} {book.AuthorInfo.AuthorPerson.Surname}"); } }
public void RefreshInfo() { bookListView.Items.Clear(); var allBooks = _typeBookRepo.GetAllBookTypes().Where(typBk => typBk.Title.Contains(srchBookTextBox.Text)); foreach (var typeBook in allBooks) { var bookItem = new ListViewItem(typeBook.Title); bookItem.SubItems.Add(typeBook.AuthorInfo.AuthorPerson.Name + " " + typeBook.AuthorInfo.AuthorPerson.Surname); bookItem.SubItems.Add(typeBook.Publisher.Name); bookItem.SubItems.Add(typeBook.PhysicalBooks.Count(bk => bk.State == BookState.Available).ToString()); bookItem.SubItems.Add(typeBook.PhysicalBooks.Count(bk => bk.State == BookState.Rented).ToString()); bookListView.Items.Add(bookItem); } }
public bool SetData() { if (_typeBook.GetAllBookTypes().Count == 0) { MessageBox.Show("No books have been added yet", "Book not exists error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnDelete.Enabled = false; titleTextBox.Text = ""; numberTextBox.Text = ""; genreCombo.Text = ""; authorCombo.Text = ""; publisherCombo.Text = ""; publisherCombo.Text = ""; copiesTextBox.Text = ""; } if (_typeBook.GetAllBookTypes().Count <= _index || _index < 0) { return(false); } titleTextBox.Text = _typeBook.GetAllBookTypes()[_index].Title; numberTextBox.Text = _typeBook.GetAllBookTypes()[_index].NumPages; genreCombo.Text = _typeBook.GetAllBookTypes()[_index].Genre.Name; authorCombo.Text = _typeBook.GetAllBookTypes()[_index].AuthorInfo.AuthorPerson.Name + " " + _typeBook.GetAllBookTypes()[_index].AuthorInfo.AuthorPerson.Surname; publisherCombo.Text = _typeBook.GetAllBookTypes()[_index].Publisher.Name; copiesTextBox.Text = _typeBook.GetAllBookTypes()[_index].PhysicalBooks .Count(bk => bk.BookInfo.TypeBookId == _typeBook.GetAllBookTypes()[_index].TypeBookId).ToString(); return(true); }
public bool SetData() { if (_firstIteration) { foreach (var genre in _genreRepo.GetAllGenres()) { genreCombo.Items.Add(genre.Name); } foreach (var publisher in _publisherRepo.GetAllPublisher()) { publisherCombo.Items.Add(publisher.Name); } foreach (var author in _authorRepo.GetAllAuthors()) { authorCombo.Items.Add(author.AuthorPerson.Name + " " + author.AuthorPerson.Surname); } _firstIteration = false; } if (_typeBook.GetAllBookTypes().Count == 0) { MessageBox.Show("No books have been added yet", "Book not exists error", MessageBoxButtons.OK, MessageBoxIcon.Error); titleTextBox.Text = ""; numberTextBox.Text = ""; genreCombo.Text = ""; authorCombo.Text = ""; publisherCombo.Text = ""; publisherCombo.Text = ""; copiesTextBox.Text = ""; btnSave.Enabled = false; } if (_typeBook.GetAllBookTypes().Count <= _index || _index < 0) { return(false); } titleTextBox.Text = _typeBook.GetAllBookTypes()[_index].Title; numberTextBox.Text = _typeBook.GetAllBookTypes()[_index].NumPages; genreCombo.Text = _typeBook.GetAllBookTypes()[_index].Genre.Name; authorCombo.Text = _typeBook.GetAllBookTypes()[_index].AuthorInfo.AuthorPerson.Name + " " + _typeBook.GetAllBookTypes()[_index].AuthorInfo.AuthorPerson.Surname; publisherCombo.Text = _typeBook.GetAllBookTypes()[_index].Publisher.Name; copiesTextBox.Text = _typeBook.GetAllBookTypes()[_index].PhysicalBooks .Count(bk => bk.BookInfo.TypeBookId == _typeBook.GetAllBookTypes()[_index].TypeBookId).ToString(); return(true); }