public void RefreshInfo() { bookListView.Items.Clear(); var allBooksRented = _rentRepo.GetAllCurrentlyRented().Where(rnt => rnt.Person.Surname.Contains(srchRenterTextBox.Text)); foreach (var rent in allBooksRented) { var rentedItem = new ListViewItem(rent.Person.Surname); rentedItem.SubItems.Add(rent.Person.Name); rentedItem.SubItems.Add(rent.Book.BookInfo.Title); rentedItem.SubItems.Add(rent.StartOfRent.ToString("dd/MM/yyyy")); if (rent.Person.InstitutionMembers.Any(inst => inst.Person.PersonId == rent.PersonId)) { rentedItem.SubItems.Add(rent.Person.InstitutionMembers .First(memb => memb.Person.PersonId == rent.PersonId).Institution.Name); rentedItem.SubItems.Add(""); } else { rentedItem.SubItems.Add(""); rentedItem.SubItems.Add(rent.Person.Subscribers.First(sub => sub.Person.PersonId == rent.PersonId) .TypeSubscription.Category); } bookListView.Items.Add(rentedItem); } }
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}"); } }
private void AdjustMemberList() { listOfMembers.Items.Clear(); foreach (var person in _personRepo.GetAllPersonsDetails().Where(prsn => prsn.Surname.Contains(memberSearchTextBox.Text) && ((prsn.InstitutionMembers.FirstOrDefault(memb => memb.Person.PersonId == prsn.PersonId) != null || prsn.Subscribers.FirstOrDefault(sub => sub.Person.PersonId == prsn.PersonId) != null))).ToList()) { if (_rentRepo.GetAllCurrentlyRented().Any(bk => bk.PersonId == person.PersonId)) { listOfMembers.Items.Add($"{person.Name} {person.Surname} {person.DateOfBirth.Value.ToString("dd/MM/yyyy")}"); } } btnReturn.Enabled = listOfMembers.Items.Count != 0; }