public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Date,Company,BillTo,Items,Paid")] Invoice invoice) { if (id != invoice.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(invoice); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvoiceExists(invoice.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(invoice)); }
public async Task <IActionResult> Edit(int id, [Bind("InvoiceNumber,Amount,CostCategory,Period")] Invoice invoice) { if (id != invoice.InvoiceNumber) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(invoice); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvoiceExists(invoice.InvoiceNumber)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(invoice)); }
public async Task <IActionResult> PayInvoice(int id) { var invoice = await _context.Invoices.Include(x => x.Items).FirstOrDefaultAsync(m => m.Id == id); if (invoice == null) { return(NotFound()); } if (invoice.Paid) { return(BadRequest()); } invoice.Paid = true; _context.Update(invoice); await _context.SaveChangesAsync(); return(Ok()); }
public async Task <bool> Update(Invoice invoice) { _InvoiceContext.Update(invoice); //Change Tracker : only change the state try { await _InvoiceContext.SaveChangesAsync(); } catch (Exception ex) { } return(true); }
public int Update(int id, InvoiceUpdateApiModel updated) { return(_InvoiceContext.Update(id, updated)); }