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)); }
public async Task UpdateAsync(Payment payment) { var paymentMongo = this.typeMapper.Map <PaymentMongo>(payment); var options = new FindOneAndReplaceOptions <PaymentMongo> { IsUpsert = true }; var paymentFilter = EventFiltersDefinition <PaymentMongo> .ApplyPaymentIDFilter(paymentMongo.PaymentID); paymentMongo.DateModified = DateTime.Now; await this.paymentEvents.FindOneAndReplaceAsync(paymentFilter, paymentMongo, options).ConfigureAwait(false); }
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)); }
public async Task <IEnumerable <Shopper> > GetAllAsync(FindShopperQuery findShopperQuery) { var filters = EventFiltersDefinition <ShopperMongo> .ApplyShooperIDFilter(findShopperQuery.ShopperID); if (findShopperQuery.Gender != Gender.None) { filters = Builders <ShopperMongo> .Filter.Eq(x => x.Gender, findShopperQuery.Gender); } var options = new FindOptions <ShopperMongo> { Sort = Builders <ShopperMongo> .Sort.Descending(p => p.DateCreated) }; var shoppers = await this.shopperRepository .FindAsync(filters, options) .Result.ToListAsync() .ConfigureAwait(false); return(this.typeMapper.Map <IEnumerable <Shopper> >(shoppers)); }