private void Search()
        {
            using (StartOperation())
            {
                if (ISBN.IsNullOrEmpty() && SearchString.IsNullOrEmpty())
                {
                    Amounts = new BookAmount[] { };
                    return;
                }

                var query = RepositoryProvider.GetRepository <BookAmount>()
                            .GetAll(ba => ba.Book.Writers)
                            .Where(ba => ba.BranchId == Employee.BranchId);

                if (!ISBN.IsNullOrEmpty())
                {
                    query = query.Where(ba => ba.Book.ISBN.Contains(ISBN));
                }
                else if (!SearchString.IsNullOrEmpty())
                {
                    query = query.Where(ba => ba.Book.Title.Contains(SearchString) ||
                                        ba.Book.Writers.Any(w => w.LastName.Contains(SearchString)));
                }

                Amounts = query.ToList();
            }
        }
示例#2
0
        private void Search()
        {
            using (StartOperation())
            {
                if (ISBN.IsNullOrEmpty() && SearchString.IsNullOrEmpty())
                {
                    Amounts = new BookAmount[] { };
                    return;
                }

                Amounts = BooksLogic.SearchBooks(Employee.BranchId, ISBN, SearchString);
            }
        }
        private void ReloadBooks()
        {
            var query = RepositoryProvider.GetRepository <BookAmount>()
                        .GetAll(ba => ba.Book.Writers)
                        .Where(ba => ba.BranchId == _employee.BranchId)
                        .Where(ba => ba.Amount > 0);

            if (!ISBN.IsNullOrEmpty())
            {
                query = query.Where(ba => ba.Book.ISBN.Contains(ISBN));
            }

            AvailableBooks = query.ToList();
        }