private void ThrowIfRemainCountIsNegative(IncomingBook incomingBook, Book book, int reservedCount) { if (book.Count - reservedCount - incomingBook.Count < 0) { throw new InvoiceCountException(book.Name); } }
private async Task <Book> RecalculateCount(IncomingBook incomingBook) { var reservedCount = await GetReservedCountOfBook(incomingBook); var book = await _unitOfWork.BookRepository.Get(incomingBook.Book.Id); ThrowIfRemainCountIsNegative(incomingBook, book, reservedCount); return(book); }
private async Task <int> GetReservedCountOfBook(IncomingBook incomingBook) { var filters = new List <Expression <Func <Rent, bool> > >() { x => x.Book.Id == incomingBook.Book.Id }; var rents = await _unitOfWork.RentRepository.GetAllAsync(filters, null, $"{nameof(Rent.Book)}"); var reservedCount = rents.Sum(x => x.Count); return(reservedCount); }
public void RefreshDocuments() { DoRefresh(() => IncomingBook.GetIncomingBook(Criteria as IncomingBookCriteriaGet)); if (_isViewAttached) { var haveDataContext = GetView() as IHaveDataContext; if (haveDataContext != null) { haveDataContext.DataContext = this; } } TriggerEmptyRegisterShow(); }