private bool SetData() { if (_subscriberRepo.GetAllSubscriber().Count == 0) { MessageBox.Show("No subscriber has been added yet", "Subscriber not exists error", MessageBoxButtons.OK, MessageBoxIcon.Error); nameTextBox.Text = ""; surnameTextBox.Text = ""; dateOfBirthPicker.Value = DateTime.Now; typeSubCombo.Text = ""; dateOfRenewalPicker.Value = DateTime.Now; btnDelete.Enabled = false; } if (_subscriberRepo.GetAllSubscriber().Count <= _index || _index < 0) { return(false); } nameTextBox.Text = _subscriberRepo.GetAllSubscriber()[_index].Person.Name; surnameTextBox.Text = _subscriberRepo.GetAllSubscriber()[_index].Person.Surname; dateOfBirthPicker.Value = _subscriberRepo.GetAllSubscriber()[_index].Person.DateOfBirth.Value; typeSubCombo.Text = _subscriberRepo.GetAllSubscriber()[_index].TypeSubscription.Category; dateOfRenewalPicker.Value = _subscriberRepo.GetAllSubscriber()[_index].DateOfRenewal; return(true); }
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 AdjustList() { listOfMembers.Items.Clear(); foreach (var subscriber in _subscriberRepo.GetAllSubscriber().Where(sub => sub.Person.Surname.Contains(memberSearchTextBox.Text))) { listOfMembers.Items.Add($"{subscriber.Person.Name} {subscriber.Person.Surname} {subscriber.Person.DateOfBirth.Value.ToString("dd/MM/yyyy")}" + $" \n Model: {subscriber.TypeSubscription.Category}" + $" \n Last renewal: {subscriber.DateOfRenewal.ToString("dd/MM/yyyy")}"); } btnExtend.Enabled = listOfMembers.Items.Count != 0; }