public async Task <List <InvoiceViewModel> > GetInvoiceByCustomerIdAsync(int id, CancellationToken ct = default(CancellationToken)) { var invoices = await _invoiceRepository.GetByCustomerIdAsync(id, ct); return(InvoiceCoverter.ConvertList(invoices).ToList()); }
public async Task <InvoiceViewModel> GetInvoiceByIdAsync(int id, CancellationToken ct = default(CancellationToken)) { var invoiceViewModel = InvoiceCoverter.Convert(await _invoiceRepository.GetByIdAsync(id, ct)); invoiceViewModel.Customer = await GetCustomerByIdAsync(invoiceViewModel.CustomerId, ct); invoiceViewModel.InvoiceLines = await GetInvoiceLineByInvoiceIdAsync(invoiceViewModel.InvoiceId, ct); invoiceViewModel.CustomerName = $"{invoiceViewModel.Customer.LastName}, {invoiceViewModel.Customer.FirstName}"; return(invoiceViewModel); }
public async Task <List <InvoiceViewModel> > GetAllInvoiceAsync(CancellationToken ct = default(CancellationToken)) { var invoices = InvoiceCoverter.ConvertList(await _invoiceRepository.GetAllAsync(ct)); foreach (var invoice in invoices) { invoice.Customer = await GetCustomerByIdAsync(invoice.CustomerId, ct); invoice.InvoiceLines = await GetInvoiceLineByInvoiceIdAsync(invoice.InvoiceId, ct); invoice.CustomerName = $"{invoice.Customer.LastName}, {invoice.Customer.FirstName}"; } return(invoices.ToList()); }
public async Task <List <InvoiceViewModel> > GetAllInvoiceAsync(CancellationToken ct = default(CancellationToken)) { var invoices = InvoiceCoverter.ConvertList(await _invoiceRepository.GetAllAsync(ct)); return(invoices); }