protected void btnNewAction_Click(object sender, ImageClickEventArgs e) { Promotion p = GetCurrentPromotion(); if (p == null) { return; } string newid = this.lstNewAction.SelectedValue; PromotionActionBase pa = PromotionActionBase.Factory(newid); p.AddAction(pa); MTApp.MarketingServices.Promotions.Update(p); LoadItem(); }
private IPromotionAction ActionFactory(IEnumerable <XElement> nodes) { if (nodes == null) { return(null); } XElement nodeTypeId = nodes.Where(y => y.Name == "TypeId").FirstOrDefault(); if (nodeTypeId == null) { return(null); } Guid typeId = new Guid(nodeTypeId.Value); IPromotionAction result = PromotionActionBase.Factory(typeId.ToString().ToUpperInvariant()); if (result == null) { return(null); } XElement nodeId = nodes.Where(y => y.Name == "Id").FirstOrDefault(); if (nodeId != null) { long temp = 0; long.TryParse(nodeId.Value, out temp); result.Id = temp; } XElement nodeSettings = nodes.Where(y => y.Name == "Settings").FirstOrDefault(); if (nodeSettings != null) { foreach (XElement setting in nodeSettings.Descendants("Setting")) { string key = setting.Element("Key").Value; string value = setting.Element("Value").Value; result.Settings[key] = value; } } return(result); }