Exemplo n.º 1
0
        public async Task <IActionResult> EditSingleInvoiceItems([FromBody] IEnumerable <Item> items)
        {
            var itemsList     = items.ToList();
            var distinctCount = itemsList.Select(i => i.InvoiceId).Distinct().Count();

            if (distinctCount != 1)
            {
                return(BadRequest("Items of multiple invoices received."));
            }

            var notExistingItems = await _invoicesRepository.GetNotExistingItems(itemsList);

            if (notExistingItems.Any())
            {
                return(NotFound(notExistingItems));
            }

            await _invoicesRepository.UpdateItemsOfSingleInvoiceAsync(itemsList);

            return(Ok());
        }