Beispiel #1
0
        [ValidateAntiForgeryToken]// [Bind("Id,DateOfIssue,DueDate,InvoicePayingStatus")]
        public async Task <IActionResult> Edit(int id, EditInvoiceViewModel invoiceViewModel)
        {
            if (id != invoiceViewModel.Invoice.Id)
            {
                return(NotFound());
            }
            var invoice = invoiceViewModel.Invoice;

            if (ModelState.IsValid)
            {
                try
                {
                    invoice.SupplierId   = invoiceViewModel.SupplierId;
                    invoice.SubscriberId = invoiceViewModel.SubscriberId;
                    await _invoicesRepository.UpdateInvoiceAsync(invoice);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await _invoicesRepository.InvoiceExistsAsync(invoice.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(invoiceViewModel));
        }