public async Task <IActionResult> GetCustomerPaymentMethods([FromRoute] GetBuyerPaymentMethods query) { try { IEnumerable <PaymentMethodDto> customerMethods = await _dispatcher.QueryAsync(query); return(Ok(customerMethods)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IEnumerable <PaymentMethodDto> > HandleAsync(GetBuyerPaymentMethods query) { var methods = await _methodsRepo.FindAsync(x => x.CustomerId == query.CustomerId); var customerMethods = new List <PaymentMethodDto>(); methods.ToList().ForEach(m => { customerMethods.Add(new PaymentMethodDto { PaymentTypeId = m.PaymentTypeId, PaymentCardExpiry = m.PaymentCardExpiry, PaymentCardNumber = m.PaymentCardNumber, PaymentCardType = m.PaymentCardType, PaymentMethodId = m.Id }); }); return(customerMethods); }