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 <IEnumerable <MerchantViewModel> > GetAllAsync() { var findMerchantQuery = new FindMerchantQuery(Guid.Empty, string.Empty, string.Empty); var merchants = await this.merchantRepository.GetAllAsync(findMerchantQuery); return(this.merchantAdapter.Adapt(merchants, typeMapper)); }
public IOutcome Accept(Merchant newEntity) { var findMerchantQuery = new FindMerchantQuery(newEntity.Name); var task = this.findMerchantQueryHandler.GetAllAsync(findMerchantQuery).GetAwaiter(); IEnumerable <Merchant> merchant = task.GetResult(); if (merchant is null || !merchant.Any()) { return(Outcomes.Success()); } return(Outcomes.Failure <int[]>().WithMessage($"Merchant name is alredy in use!")); }
public IOutcome Accept(Merchant newEntity) { var findMerchantQuery = new FindMerchantQuery(newEntity.ID); var result = this.findMerchantQueryHandler.GetAsync(findMerchantQuery).GetAwaiter(); var merchant = result.GetResult(); if (merchant is null) { return(Outcomes.Success()); } return(Outcomes.Failure <int[]>().WithMessage($"Merchant ID is alredy in use!")); }
public async Task <IEnumerable <Merchant> > GetMerchantsByCountry(string country) { var findMerchantQuery = new FindMerchantQuery(Guid.Empty, country, string.Empty); return(await GetAllAsync(findMerchantQuery)); }
public async Task <Merchant> GetAsync(Guid merchantID) { var findMerchantQuery = new FindMerchantQuery(merchantID); return((await GetAllAsync(findMerchantQuery)).FirstOrDefault <Merchant>()); }
private async Task <bool> FindMerchantByID(Guid merchandID) { var findMerchantQuery = new FindMerchantQuery(merchandID, string.Empty, string.Empty); return(await this.merchantQuery.GetAsync(findMerchantQuery) != null); }