public async Task <IActionResult> Edit(int id, [Bind("ID,ContactID,DateCreated,DateIssued,DateDue,DateVAT,NotePublic,NoteInternal,Footer")] IssuedInvoice issuedInvoice)
        {
            if (id != issuedInvoice.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(issuedInvoice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IssuedInvoiceExists(issuedInvoice.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContactID"] = new SelectList(_context.Contacts, "ID", "ID", issuedInvoice.ContactID);
            return(View(issuedInvoice));
        }
예제 #2
0
        private IssuedInvoiceUpdate MergeInvoice(invoice invoice, IssuedInvoice existingInvoice)
        {
            var updatedInvoice = AutoMapper.Mapper.Map <IssuedInvoiceUpdate>(existingInvoice);

            updatedInvoice.DateOfIssue    = invoice.invoiceHeader.date;
            updatedInvoice.VariableSymbol = invoice.invoiceHeader.symVar.ToString();

            updatedInvoice.IssuedInvoiceItems = GetUpdateItems(invoice.invoiceDetail);

            return(updatedInvoice);
        }
        public async Task <IActionResult> Create([Bind("ID,ContactID,DateCreated,DateIssued,DateDue,DateVAT,NotePublic,NoteInternal,Footer")] IssuedInvoice issuedInvoice)
        {
            if (ModelState.IsValid)
            {
                _context.Add(issuedInvoice);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContactID"] = new SelectList(_context.Contacts, "ID", "ID", issuedInvoice.ContactID);
            return(View(issuedInvoice));
        }