public async Task <List <InvoiceViewModel> > GetInvoiceByCustomerIdAsync(int id,
                                                                                 CancellationToken ct = default(CancellationToken))
        {
            var invoices = await _invoiceRepository.GetByCustomerIdAsync(id, ct);

            return(InvoiceCoverter.ConvertList(invoices).ToList());
        }
Example #2
0
        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);
        }