public async Task <List <CustomerViewModel> > GetCustomerBySupportRepIdAsync(int id, CancellationToken ct = default(CancellationToken)) { var customers = await _customerRepository.GetBySupportRepIdAsync(id, ct); return(CustomerCoverter.ConvertList(customers).ToList()); }
public async Task <List <CustomerViewModel> > GetAllCustomerAsync( CancellationToken ct = default(CancellationToken)) { var customers = CustomerCoverter.ConvertList(await _customerRepository.GetAllAsync(ct)).ToList(); return(customers); }
public async Task <CustomerViewModel> GetCustomerByIdAsync(int id, CancellationToken ct = default(CancellationToken)) { var customerViewModel = CustomerCoverter.Convert(await _customerRepository.GetByIdAsync(id, ct)); customerViewModel.Invoices = await GetInvoiceByCustomerIdAsync(customerViewModel.CustomerId, ct); customerViewModel.SupportRep = await GetEmployeeByIdAsync(customerViewModel.SupportRepId.GetValueOrDefault(), ct); customerViewModel.SupportRepName = $"{customerViewModel.SupportRep.LastName}, {customerViewModel.SupportRep.FirstName}"; return(customerViewModel); }
public async Task <List <CustomerViewModel> > GetAllCustomerAsync(CancellationToken ct = default(CancellationToken)) { var customers = CustomerCoverter.ConvertList(await _customerRepository.GetAllAsync(ct)).ToList(); foreach (var customer in customers) { customer.Invoices = await GetInvoiceByCustomerIdAsync(customer.CustomerId, ct); customer.SupportRep = await GetEmployeeByIdAsync(customer.SupportRepId.GetValueOrDefault(), ct); customer.SupportRepName = $"{customer.SupportRep.LastName}, {customer.SupportRep.FirstName}"; } return(customers.ToList()); }