public string Update() { CommissionAmount = (CommissionRate * Amount) / 100; CommissionAmount = Math.Round((decimal)CommissionAmount); VatOnAmount = Amount + CommissionAmount; VatAmount = (CommissionAmount + Amount) * VatRate / 100; VatAmount = Math.Round((decimal)VatAmount); InvoiceAmount = Amount + CommissionAmount + VatAmount; XDocument doc = XDocument.Load(@"Transactions.xml"); var record = from r in doc.Descendants("Transaction") where (int)r.Element("Invoice").Attribute("Id") == InvoiceId select r; foreach (XElement r in record) { r.Element("Invoice").Element("InvoiceNo").Value = InvoiceNo; r.Element("Invoice").Element("InvoiceDate").Value = XmlConvert.ToString(InvoiceDate, XmlDateTimeSerializationMode.RoundtripKind); r.Element("Invoice").Element("CommissionRate").Value = CommissionRate.ToString(); r.Element("Invoice").Element("CommissionAmount").Value = CommissionAmount.ToString(); r.Element("Invoice").Element("VatRate").Value = VatRate.ToString(); r.Element("Invoice").Element("VatAmount").Value = VatAmount.ToString(); r.Element("Invoice").Element("InvoiceAmount").Value = InvoiceAmount.ToString(); r.Element("Invoice").Element("Source").Value = Source; r.Element("Invoice").Element("Destination").Value = Destination; r.Element("Invoice").Element("TruckNo").Value = TruckNo; } doc.Save(@"Transactions.xml"); return("Record Updated"); }
public int GetIdempotentKey() { unchecked { int hashCode = Description?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ DiscountAmount.GetHashCode(); hashCode = (hashCode * 397) ^ GrossUnitPrice.GetHashCode(); hashCode = (hashCode * 397) ^ LineNumber; hashCode = (hashCode * 397) ^ NetUnitPrice.GetHashCode(); hashCode = (hashCode * 397) ^ (ProductId?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Quantity.GetHashCode(); hashCode = (hashCode * 397) ^ VatAmount.GetHashCode(); hashCode = (hashCode * 397) ^ VatPercent.GetHashCode(); return(hashCode); } }