public async Task <CustomerProfileDTO> GetCustomerProfile(CustomerInquiryFilterDTO customerInquiry) { try { CustomerProfileDTO customerProfileDTO = null; var customerInquiryFilter = new CustomerInquiryFilter { CustomerId = customerInquiry.CustomerId, Email = customerInquiry.Email }; var customerProfile = await _customerRepository.GetCustomersAsync(customerInquiryFilter); if (customerProfile == null) { return(customerProfileDTO); } customerProfileDTO = new CustomerProfileDTO { CustomerId = customerProfile.CustomerId, Name = customerProfile.Name, Email = customerProfile.Email, MobileNumber = customerProfile.Email, RecentTransactions = customerProfile.RecentTransactions.Select(x => new TransactionDTO { TransactionId = x.TransactionId, Amount = x.Amount, Date = x.TransactionDateTime, CurrencyCode = x.CurrencyCode.ToString(), TransactionStatus = x.Status.ToString() }).ToList() }; return(customerProfileDTO); } catch (System.Exception ex) { throw ex; } }
public async Task <IActionResult> GetCustomerProfile(CustomerInquiryFilterDTO customerInquiryFilter) { if (customerInquiryFilter == null) { return(BadRequest("No inquiry criteria")); } if (!ModelState.IsValid) { return(BadRequest("invalid customer id or email address")); } var customerProfile = await _customerInquiryService.GetCustomerProfile(customerInquiryFilter); if (customerProfile == null) { return(NotFound("No records found")); } return(Ok(customerProfile)); }