public int UpdateInvoice(string _invoice) { invObj = new InvoiceClass(); invoiceArray inv = JsonConvert.DeserializeObject <invoiceArray>(_invoice); if (!ValidateInvoiceNo(inv.invoiceNo, inv.invId.ToString())) { invObj.invId = inv.invId; invObj.custId = inv.custId; invObj.custName = inv.custName; invObj.invoiceNo = inv.invoiceNo; invObj.invoiceDate = Convert.ToDateTime(inv.invoiceDate).ToString("yyyy-MM-dd"); invObj.amount = inv.amount; invObj.invUniqueNo = Convert.ToInt32(inv.invUniqueNo); if (invObj.UpdateInvoiceMaster()) { if (invObj.InvoiceDetailsDeleteByInvId()) { for (int i = 0; i < inv.invoiceDetailsArray.Count; i++) { invObj.prodId = inv.invoiceDetailsArray[i].prodId; invObj.prodDescription = inv.invoiceDetailsArray[i].product; invObj.qty = inv.invoiceDetailsArray[i].qty; invObj.prodPrice = inv.invoiceDetailsArray[i].unitPrice; invObj.totalPrice = inv.invoiceDetailsArray[i].totalPrice; invObj.SaveInvoiceDetails(); } } invObj.totalExVat = inv.totExVat; invObj.vatPer = inv.vatPer; invObj.vatAmt = inv.vatAmt; invObj.totalInTax = inv.totInVat; invObj.termsAndConditions = inv.termsAndConditions; invObj.UpdateinvoicePaymentDetails(); return(invObj.invId); } else { return(0); } } else { return(0); } }