示例#1
0
        public async Task <IEnumerable <Merchant> > GetAllAsync(FindMerchantQuery findMerchantQuery)
        {
            var filters = EventFiltersDefinition <MerchantMongo> .ApplyMerchantIDFilter(findMerchantQuery.MerchantID);

            if (!string.IsNullOrEmpty(findMerchantQuery.Country))
            {
                filters = Builders <MerchantMongo> .Filter.Eq(x => x.Country, findMerchantQuery.Country);
            }

            if (!string.IsNullOrEmpty(findMerchantQuery.Name))
            {
                filters = Builders <MerchantMongo> .Filter.Eq(x => x.Name, findMerchantQuery.Name);
            }

            var options = new FindOptions <MerchantMongo>
            {
                Sort = Builders <MerchantMongo> .Sort.Descending(p => p.DateCreated)
            };

            var merchants = await this.merchantRepository
                            .FindAsync(filters, options)
                            .Result.ToListAsync()
                            .ConfigureAwait(false);

            return(this.typeMapper.Map <IEnumerable <Merchant> >(merchants));
        }
示例#2
0
        public async Task <IEnumerable <Payment> > GetAllAsync(FindPaymentQuery findPaymentQuery)
        {
            var paymentFilter = EventFiltersDefinition <PaymentMongo> .ApplyPaymentIDFilter(findPaymentQuery.PaymentID);

            var merchantFilter = EventFiltersDefinition <PaymentMongo> .ApplyMerchantIDFilter(findPaymentQuery.MerchantID);

            var shopperFilter = EventFiltersDefinition <PaymentMongo> .ApplyShooperIDFilter(findPaymentQuery.ShopperID);

            var options = new FindOptions <PaymentMongo>
            {
                Sort = Builders <PaymentMongo> .Sort.Descending(p => p.DateCreated)
            };

            var payments = await this.paymentEvents
                           .FindAsync(paymentFilter& merchantFilter& shopperFilter, options)
                           .Result.ToListAsync()
                           .ConfigureAwait(false);

            return(this.typeMapper.Map <IEnumerable <Payment> >(payments));
        }