コード例 #1
0
 public void Update(int id, Invoice invoice)
 {
     _db.Entry(invoice).State = EntityState.Modified;
     _db.SaveChanges();
 }
コード例 #2
0
 public void Add(Invoice invoice)
 {
     _db.Invoices.Add(invoice);
     _db.SaveChanges();
 }
コード例 #3
0
 public void Delete(Invoice invoice)
 {
     _db.Invoices.Remove(invoice);
     _db.SaveChanges();
 }
コード例 #4
0
 public HttpResponseMessage PostInvoiceItems([FromBody] InvoicePost data)
 {
     var invoiceItems = data.InvoiceItems.Select(invoiceItemPost => new InvoiceItem()
     {
         ProductId = invoiceItemPost.ProductId, Quantity = invoiceItemPost.Quantity, Price = invoiceItemPost.Price
     }).ToList();
     var invoice = new Invoice()
     {
         VAT = data.VAT,
         Shipping = data.Shipping,
         SubTotal = data.SubTotal,
         Total = data.Total,
         Created =  DateTimeOffset.Now,
         InvoiceItems = invoiceItems
     };
     _invoiceRepository.Add(invoice);
     return Request.CreateResponse(HttpStatusCode.Created, invoice);
 }