}         // SelectOne

        private DateTime?GetDateFromList(MP_CustomerMarketPlace mp, WhichDateToTake nWhich)
        {
            if (null == Configuration.Instance.GetVendorInfo(mp.Marketplace.Name))
            {
                return(null);
            }

            DateTime?oResult = null;

            IQueryable <DateTime> oListOfPaymentDates = _session
                                                        .Query <MP_ChannelGrabberOrderItem>()
                                                        .Where(oi =>
                                                               (oi.Order.CustomerMarketPlace.Id == mp.Id) && (oi.PaymentDate != null)
                                                               )
                                                        .Select(oi => oi.PaymentDate);

            foreach (DateTime oDate in oListOfPaymentDates)
            {
                oResult = SelectOne(oResult, oDate, nWhich);
            }

            IQueryable <MP_VatReturnRecord> oVatPeriods = _session
                                                          .Query <MP_VatReturnRecord>()
                                                          .Where(r => r.CustomerMarketPlace.Id == mp.Id && (r.IsDeleted == null || !r.IsDeleted.Value));

            foreach (MP_VatReturnRecord oPeriod in oVatPeriods)
            {
                oResult = SelectOne(oResult, oPeriod.DateFrom, nWhich);
                oResult = SelectOne(oResult, oPeriod.DateTo, nWhich);
            }             // for each

            return(oResult);
        } // GetDateFromList
        }         // enum WhichDateToTake

        private static DateTime?SelectOne(DateTime?oResult, DateTime oDate, WhichDateToTake nWhich)
        {
            if (oResult == null)
            {
                return(oDate);
            }

            switch (nWhich)
            {
            case WhichDateToTake.Min:
                return((oDate < oResult) ? oDate : oResult);

            case WhichDateToTake.Max:
                return((oDate > oResult) ? oDate : oResult);

            default:
                throw new ArgumentOutOfRangeException("nWhich");
            }     // switch
        }         // SelectOne