AccountDataObject ReadXmlBuildAccountData(string xml_str) { string fname = ""; string lname = ""; string datecreated = ""; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml_str); XmlNodeList parentNode2 = xmlDoc.GetElementsByTagName("account"); foreach (XmlNode childrenNode2 in parentNode2) { datecreated = (childrenNode2.SelectSingleNode("created_at").InnerText); } XmlNodeList parentNode = xmlDoc.GetElementsByTagName("account_holder"); foreach (XmlNode childrenNode in parentNode) { fname = (childrenNode.SelectSingleNode("first_name").InnerText); lname = (childrenNode.SelectSingleNode("last_name").InnerText); } AccountDataObject accountObject = new AccountDataObject(fname, lname, datecreated); return(accountObject); }
/// <summary> /// Gets a player's account by its nickname or ID. /// </summary> /// <param name="playerId"></param> /// <param name="accountNameOrId"></param> /// <returns></returns> public Promise <AccountDataObject> GetAccount(ulong playerId, string accountNameOrId) { return(new Promise <AccountDataObject>((result, reject) => { GetAccounts(playerId) .Then(accounts => { AccountDataObject account = null; if (long.TryParse(accountNameOrId, out var accountId)) { account = accounts.FirstOrDefault(a => a.Id == accountId); } else { account = accounts.FirstOrDefault(a => a.Nickname.StartsWith(accountNameOrId)); } if (account == null) { reject(new Exception($"Unable to find account with a name or id of {accountNameOrId}.")); return; } result(account); }); })); }
ActionResult _ACCOUNTFUINC(string XML) { AccountDataObject AccountOBJ = ReadXmlBuildAccountData(XML); return(View(AccountOBJ)); }