Пример #1
0
        public async Task <RetrievedBookInfoDto> GetBookAsync(BookMobileGetDto bookDto)
        {
            var book = await _bookOfficeDbSet
                       .Include(b => b.Book)
                       .Where(b => b.Book.Code == bookDto.Code &&
                              b.OfficeId == bookDto.OfficeId &&
                              b.OrganizationId == bookDto.OrganizationId)
                       .Select(MapBookToBookMobileGetDto())
                       .FirstOrDefaultAsync();

            _serviceValidator.ThrowIfBookDoesNotExist(book != null);

            return(book);
        }
Пример #2
0
        private async Task ValidateTakeBookAsync(BookTakeDto bookDto, MobileBookOfficeLogsDto officeBookWithLogs)
        {
            var applicationUser = await _userDbSet.FirstOrDefaultAsync(u => u.Id == bookDto.ApplicationUserId);

            _serviceValidator.ThrowIfUserDoesNotExist(applicationUser);
            _serviceValidator.ThrowIfBookDoesNotExist(officeBookWithLogs != null);
            _serviceValidator.ChecksIfUserHasAlreadyBorrowedSameBook(officeBookWithLogs?.LogsUserIDs, bookDto.ApplicationUserId);
            _serviceValidator.ThrowIfBookIsAlreadyBorrowed(officeBookWithLogs);
        }
Пример #3
0
        private void ValidateTakeBook(BookTakeDTO bookDTO, MobileBookOfficeLogsDTO officeBookWithLogs)
        {
            var applicationUser = _userDbSet
                                  .FirstOrDefault(u => u.Id == bookDTO.ApplicationUserId);

            _serviceValidator.ThrowIfUserDoesNotExist(applicationUser);
            _serviceValidator.ThrowIfBookDoesNotExist(officeBookWithLogs != null);
            _serviceValidator.ChecksIfUserHasAlreadyBorrowedSameBook(officeBookWithLogs.LogsUserIDs, bookDTO.ApplicationUserId);
            _serviceValidator.ThrowIfBookIsAlreadyBorrowed(officeBookWithLogs);
        }