예제 #1
0
        public IActionResult InvoicesForAccounts(string accountNumber)
        {
            var parsedAccountNumber = new AccountNumberTemplate(accountNumber);

            if (!parsedAccountNumber.IsValid())
            {
                return(BadRequest("Account Number is invalid"));
            }

            var invoices = _invoiceManager.GetInvoicesForAccount(parsedAccountNumber);
            var response = new List <InvoiceBasic>();

            foreach (var invoice in invoices)
            {
                var flattenedInvoices = _responseGenerator.GenerateBasicInvoices(invoice);
                response = response.Concat(flattenedInvoices).ToList();
            }

            return(Ok(response));
        }