/// <summary> /// Amends order based on how subclass overrides virtual methods /// </summary> public sealed override PublicOrder AmendOrder(PublicOrder order, PublicOrderContext orderContext) { var domainItems = orderContext.ItemData.Where(i => this.HandledCategories.Intersect(i.Categories.Select(c => c.Name)).Count() > 0); foreach (var domainItem in domainItems) { var customData = new List<PublicOrderItemProperty>(); var domainName = GetDomainName(domainItem); var connectedItem = GetConnectedItem(orderContext.ItemData, domainItem, domainName); customData.Add(new PublicOrderItemProperty { Name = "DomainName", Value = domainName }); if (connectedItem != null) { var atomiaService = GetAtomiaService(connectedItem); customData.Add(new PublicOrderItemProperty { Name = "AtomiaService", Value = atomiaService }); var extraProperties = GetAtomiaServiceExtraProperties(domainItem); if (!String.IsNullOrEmpty(extraProperties)) { customData.Add(new PublicOrderItemProperty { Name = "AtomiaServiceExtraProperties", Value = extraProperties }); } } else { customData.Add(new PublicOrderItemProperty { Name = "AtomiaService", Value = DefaultAtomiaService }); } var domainRegContactProvider = new DomainRegContactProvider(orderContext); if (!string.IsNullOrEmpty(domainRegContactProvider.DomainRegContactData)) { customData.Add(new PublicOrderItemProperty { Name = "DomainRegContact", Value = domainRegContactProvider.DomainRegContactData }); } foreach(var extraData in GetExtraCustomData(domainItem)) { customData.Add(extraData); } var orderItem = new PublicOrderItem { ItemId = Guid.Empty, ItemNumber = domainItem.ArticleNumber, Quantity = 1, RenewalPeriodId = domainItem.RenewalPeriodId, CustomData = customData.ToArray() }; Add(order, orderItem); } return order; }
/// <summary> /// Amends order based on how subclass overrides virtual methods /// </summary> public sealed override PublicOrder AmendOrder(PublicOrder order, PublicOrderContext orderContext) { var domainItems = orderContext.ItemData.Where(i => this.HandledCategories.Intersect(i.Categories.Select(c => c.Name)).Count() > 0); foreach (var domainItem in domainItems) { var customData = new List <PublicOrderItemProperty>(); var domainName = GetDomainName(domainItem); var domainRegSpecificAttrs = GetDomainRegistrySpecificAttributes(domainItem); var connectedItem = GetConnectedItem(orderContext.ItemData, domainItem, domainName); customData.Add(new PublicOrderItemProperty { Name = "DomainName", Value = domainName }); if (!string.IsNullOrEmpty(domainRegSpecificAttrs)) { customData.Add(new PublicOrderItemProperty { Name = "DomainRegistrySpecificAttributes", Value = domainRegSpecificAttrs }); } if (connectedItem != null) { var atomiaService = GetAtomiaService(connectedItem); customData.Add(new PublicOrderItemProperty { Name = "AtomiaService", Value = atomiaService }); var extraProperties = GetAtomiaServiceExtraProperties(domainItem); if (!String.IsNullOrEmpty(extraProperties)) { customData.Add(new PublicOrderItemProperty { Name = "AtomiaServiceExtraProperties", Value = extraProperties }); } } else { customData.Add(new PublicOrderItemProperty { Name = "AtomiaService", Value = DefaultAtomiaService }); } var domainRegContactProvider = new DomainRegContactProvider(orderContext); if (!string.IsNullOrEmpty(domainRegContactProvider.DomainRegContactData)) { customData.Add(new PublicOrderItemProperty { Name = "DomainRegContact", Value = domainRegContactProvider.DomainRegContactData }); } foreach (var extraData in GetExtraCustomData(domainItem)) { customData.Add(extraData); } var orderItem = new PublicOrderItem { ItemId = Guid.Empty, ItemNumber = domainItem.ArticleNumber, Quantity = 1, RenewalPeriodId = domainItem.RenewalPeriodId, CustomData = customData.ToArray() }; Add(order, orderItem); } return(order); }
/// <summary> /// Amends order based on how subclass overrides virtual methods /// </summary> public sealed override PublicOrder AmendOrder(PublicOrder order, PublicOrderContext orderContext) { var domainItems = orderContext.ItemData.Where(i => this.HandledCategories.Intersect(i.Categories.Select(c => c.Name)).Count() > 0); var jsemail = new JavaScriptSerializer(); var mailOnOrderSettings = LocalConfigurationHelper.GetMailOnOrderSettings(); foreach (var domainItem in domainItems) { var customData = new List <PublicOrderItemProperty>(); var domainName = GetDomainName(domainItem); var domainRegSpecificAttrs = GetDomainRegistrySpecificAttributes(domainItem); var connectedItem = GetConnectedItem(orderContext.ItemData, domainItem, domainName); customData.Add(new PublicOrderItemProperty { Name = "DomainName", Value = domainName }); if (!string.IsNullOrEmpty(domainRegSpecificAttrs)) { customData.Add(new PublicOrderItemProperty { Name = "DomainRegistrySpecificAttributes", Value = domainRegSpecificAttrs }); var mailOnOrderElement = mailOnOrderSettings.FirstOrDefault(e => e.ProductId == domainItem.ArticleNumber); if (mailOnOrderElement != null) { Dictionary <string, string> emailProps = new Dictionary <string, string>(); Dictionary <string, string> domainSpecific = jsemail.Deserialize <Dictionary <string, string> >(domainRegSpecificAttrs); emailProps.Add("Type", mailOnOrderElement.Email); emailProps.Add("Domain", domainName ?? ""); emailProps.Add("Name", domainSpecific.FirstOrDefault(v => v.Key == "AcceptName").Value ?? ""); emailProps.Add("Time", domainSpecific.FirstOrDefault(v => v.Key == "AcceptDate").Value ?? ""); emailProps.Add("Orgnum", order.CompanyNumber); emailProps.Add("Company", order.Company); emailProps.Add("Version", domainSpecific.FirstOrDefault(v => v.Key == "AcceptVersion").Value ?? ""); emailProps.Add("Ccc", mailOnOrderElement.CccEmail); customData.Add(new PublicOrderItemProperty { Name = "MailOnOrder", Value = jsemail.Serialize(emailProps) }); } } if (connectedItem != null) { var atomiaService = GetAtomiaService(connectedItem); customData.Add(new PublicOrderItemProperty { Name = "AtomiaService", Value = atomiaService }); var extraProperties = GetAtomiaServiceExtraProperties(domainItem); if (!String.IsNullOrEmpty(extraProperties)) { customData.Add(new PublicOrderItemProperty { Name = "AtomiaServiceExtraProperties", Value = extraProperties }); } } else { customData.Add(new PublicOrderItemProperty { Name = "AtomiaService", Value = DefaultAtomiaService }); } var domainRegContactProvider = new DomainRegContactProvider(orderContext); if (!string.IsNullOrEmpty(domainRegContactProvider.DomainRegContactData)) { customData.Add(new PublicOrderItemProperty { Name = "DomainRegContact", Value = domainRegContactProvider.DomainRegContactData }); } foreach (var extraData in GetExtraCustomData(domainItem)) { customData.Add(extraData); } var orderItem = new PublicOrderItem { ItemId = Guid.Empty, ItemNumber = domainItem.ArticleNumber, Quantity = 1, RenewalPeriodId = domainItem.RenewalPeriodId, CustomData = customData.ToArray() }; Add(order, orderItem); } return(order); }