Пример #1
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);
        }
Пример #2
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);
        }