private void LoadMyAccountCollection(MyAccountItemCollection source, MyAccountItemCollectionViewModel destination) { foreach (var item in source) { destination.Add(new MyAccountItemViewModel(item.Id, item.Name, item.Attributes)); } }
private void FillMyAccountCollection(MyAccountItemCollection myAccountCollection, dynamic myAccountJsonCollection) { if (myAccountJsonCollection == null) { return; } foreach (var accountItemElement in myAccountJsonCollection) { var id = ConvertDynamicValue <string>(accountItemElement.id); myAccountCollection.Add(new MyAccountItem(id, this.GetElementFriendlyName(id), JsonUtils.ExtractAllAttributes((JObject)accountItemElement))); } }
private JArray GenerateMyAccountSection(MyAccountItemCollection myAccountSection) { var result = new JArray(); foreach (var item in myAccountSection) { var obj = new JObject(); foreach (var attr in item.Attributes) { obj.Add(new JProperty(attr.Name, attr.Value)); } result.Add(obj); } return(result); }
private void FillMyAccountCollection(MyAccountItemCollection myAccountCollection, string screen) { var myAccountElement = _navigationPlanXml.Root.Element(XmlNames.lobby_data_ndl) ?.Elements(XmlNames.myAccount) ?.Where(element => element.GetAttributeValue(XmlNames.screen) == screen) .FirstOrDefault(); if (myAccountElement == null) { return; } foreach (var accountItemElement in myAccountElement.Elements(XmlNames.item)) { var id = accountItemElement.GetAttributeValue(XmlNames.id); myAccountCollection.Add(new MyAccountItem(id, this.GetElementFriendlyName(id), accountItemElement.ExtractAllAttributes())); } }
private void UpdateMyAccountSection(string screen, MyAccountItemCollection newItems) { var oldMyAccountSection = lobby_data_ndl.Elements(XmlNames.myAccount).FirstOrDefault(element => element.GetAttributeValue(XmlNames.screen) == screen); var newMyAccountSection = new XElement(XmlNames.myAccount); if (oldMyAccountSection != null) { oldMyAccountSection.CopyAttributesTo(newMyAccountSection); } newMyAccountSection.AddOrUpdateAttributeValue(XmlNames.screen, screen); foreach (var item in newItems) { var itemElement = new XElement(XmlNames.item); foreach (var attr in item.Attributes) { itemElement.Add(new XAttribute(attr.Name, attr.Value)); } newMyAccountSection.Add(itemElement); } if (oldMyAccountSection != null) { oldMyAccountSection.AddBeforeSelf(newMyAccountSection); oldMyAccountSection.Remove(); } else { lobby_data_ndl.Add(newMyAccountSection); } }