public void Update(int id, Invoice invoice) { _db.Entry(invoice).State = EntityState.Modified; _db.SaveChanges(); }
public void Add(Invoice invoice) { _db.Invoices.Add(invoice); _db.SaveChanges(); }
public void Delete(Invoice invoice) { _db.Invoices.Remove(invoice); _db.SaveChanges(); }
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); }