public float GetBalance(IBankAccount account) { var acc = GetAccountByIdentifier(account.AccountIdentifier) as LRAccount; var responseXML = LibertyReserve.GetBalance(acc); // parse XML response var reader = new StringReader(responseXML); XDocument xdoc = XDocument.Load(reader); var balance = (from b in xdoc.Descendants("Balance") where b.Element("AccountId").Value == account.AccountIdentifier select float.Parse(b.Element("Value").Value)).First(); return(balance); }
public List <ITransaction> GetTransactions(IBankAccount account, DateTime start, DateTime end) { var lracc = GetAccountByIdentifier(account.AccountIdentifier) as LRAccount; TextReader reader = new StringReader(LibertyReserve.GetHistory(lracc, start, end, "any")); XDocument xdoc = XDocument.Load(reader); var receipts = from t in xdoc.Descendants("Receipt") select t; var l = new List <ITransaction> (); foreach (XElement rc in receipts) { var t = new LRTransaction(); t.ValutaDate = t.Date = DateTime.Parse(rc.Element("Date").Value); // childnode Transfer var el = rc.Element("Transfer"); t.FromAccount = new LRAccount() { AccountIdentifier = el.Element("Payer").Value }; t.FromAccount.OwnerName.Add(rc.Element("PayerName").Value); //if (el.Element ("Anonymous").Value == "true") // t.ToAccount = t.FromAccount; t.ToAccount = new LRAccount() { AccountIdentifier = el.Element("Payee").Value }; t.ToAccount.OwnerName.Add(rc.Element("PayeeName").Value); t.Amount = float.Parse(el.Element("Amount").Value); t.Currency = el.Element("CurrencyId").Value; t.Purposes.Add(el.Element("Memo").Value); l.Add(t); } return(l); }