contract EtherLambosSale is EtherLambosOwnership {

    // @notice The sale contract variables are defined in EtherLambosBase to allow
    //  us to refer to them in EtherLambosOwnership to prevent accidental transfers.
    // `saleMarketplace` refers to the auction for p2p sale of cars.
   

    /// @dev Sets the reference to the sale auction.
    /// @param _address - Address of sale contract.
    function setMarketplaceAddress(address _address) external onlyCEO {
        MarketPlace candidateContract = MarketPlace(_address);

        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
        require(candidateContract.isMarketplace());

        // Set the new contract address
        marketPlace = candidateContract;
    }


    /// @dev Put a lambo up for sale.
    ///  Does some ownership trickery to create auctions in one tx.
    function createLamboSale(
        uint256 _carId,
        uint256 _price
    )
        external
        whenNotPaused
    {
        // Sale contract checks input sizes
        // If lambo is already on any sale, this will throw
        // because it will be owned by the sale contract.
        require(_owns(msg.sender, _carId));
        
        _approve(_carId, marketPlace);
        // Sale throws if inputs are invalid and clears
        // transfer after escrowing the lambo.
        marketPlace.createSale(
            _carId,
            _price,
            msg.sender
        );
    }
    
    
    function bulkCreateLamboSale(
        uint256 _price,
        uint256 _tokenIdStart,
        uint256 _tokenCount
    )
        external
        onlyCOO
    {
        // Sale contract checks input sizes
        // If lambo is already on any sale, this will throw
        // because it will be owned by the sale contract.
        for(uint256 i=0;i<_tokenCount;i++)
            {
            require(_owns(msg.sender, _tokenIdStart+i));
        
            _approve(_tokenIdStart+i, marketPlace);
            // Sale throws if inputs are invalid and clears
            // transfer after escrowing the lambo.
            marketPlace.createSale(
                _tokenIdStart+i,
                _price,
             msg.sender
            );
        }
    }
    /// @dev Transfers the balance of the marketPlace contract
    /// to the EtherLambosCore contract. We use two-step withdrawal to
    /// prevent two transfer calls in the auction bid function.
    function withdrawSaleBalances() external onlyCLevel {
        marketPlace.withdrawBalance();
        
    }
}
////No SiringClockAuction needed for Lambos
////No separate modification for SaleContract needed
/// @title Handles creating sales for sale of lambos.
///  This wrapper of ReverseSale exists only so that users can create
///  sales with only one transaction.
function withdrawSaleBalances() external onlyCLevel {
        marketPlace.withdrawBalance();
        
    }
/// @dev Transfers the balance of the marketPlace contract
/// to the EtherLambosCore contract. We use two-step withdrawal to
/// prevent two transfer calls in the auction bid function.