public IActionResult SaveInvoice([FromBody] InvoiceViewModel[] invoice)
        {
            try
            {
                for (int i = 0; i < invoice.Length; i++)
                {
                    Invoice.Repository.Migrations.Invoice invoiceData = new Invoice.Repository.Migrations.Invoice()
                    {
                        InvoiceDate = DateTime.Now,
                        InvoiceNo   = Convert.ToInt32(invoice[i].InvoiceNo),
                        Net         = Convert.ToInt32(invoice[i].Net),
                        StoreId     = Convert.ToInt32(invoice[i].StoreId),
                        Taxes       = Convert.ToDecimal(invoice[i].Taxes),
                        Total       = Convert.ToDecimal(invoice[i].Total)
                    };

                    foreach (InvoiceDetailViewModel invDetail in invoice[i].invoiceDetails)
                    {
                        InvoiceDetails detail = new InvoiceDetails()
                        {
                            InvoiceId = invoiceData.Id,
                            ItemId    = Convert.ToInt32(invDetail.ItemId),
                            Net       = Convert.ToInt32(invDetail.Net),
                            Price     = Convert.ToInt32(invDetail.Price),
                            Qty       = Convert.ToInt32(invDetail.Qty),
                            Total     = Convert.ToDecimal(invDetail.Total),
                            UnitId    = Convert.ToInt32(invDetail.UnitId),
                            Discount  = Convert.ToInt32(invDetail.Discount)
                        };

                        invoiceData.InvoiceDetails.Add(detail);
                    }

                    invoiceService.InsertInvoice(invoiceData);
                }

                return(Ok(true));
            }
            catch
            {
                return(Ok(false));
            }
        }
        public void InsertInvoice(Invoice.Repository.Migrations.Invoice invoice)
        {
            using (var transaction = _context.Database.BeginTransaction())
            {
                {
                    repository.Insert(invoice);
                    try
                    {
                        foreach (InvoiceDetails detail in invoice.InvoiceDetails)
                        {
                            detail.InvoiceId = invoice.Id;
                            invDetailsService.InsertInvoiceDetail(detail);
                        }

                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();
                    }
                }
                repository.SaveChanges();
            }
        }
 public void UpdateInvoice(Invoice.Repository.Migrations.Invoice invoice)
 {
     throw new NotImplementedException();
 }