/// <summary> /// These product attributes are promoted from the attribute list in the output to dedicated properties /// </summary> /// <param name="productModel">IN: a product output model, OUT: enriched product output model</param> /// <param name="product">product from database</param> private void DerivePropertiesFromProductAttributes(ref ProductBizTalkModel productModel, ProductDBModel product) { //try //{ // productModel.SpecialPriceStartDate = // DateTime.Parse(_productAttributes.Where(x => x.AttributeCode == "Special_From_Date").Select(x => x.Value).FirstOrDefault()); //} //catch (Exception ex) //{ // TraceError("Could not extract \"Special_From_Date\" for product \"{0}\". Error: {1}", product.ProductID, ex.Message); //} //try //{ // productModel.SpecialPriceEndDate = DateTime.Parse(_productAttributes.Where(x => x.AttributeCode == "Special_To_Date").Select(x => x.Value).FirstOrDefault()); //} //catch (Exception ex) //{ // TraceError("Could not extract \"Special_To_Date\" for product \"{0}\". Error: {1}", product.ProductID, ex.Message); //} try { productModel.Weight = _productAttributes.Where(x => x.AttributeCode == "weight").Select(x => x.Value).FirstOrDefault(); } catch (Exception ex) { TraceError("Could not extract \"weight\" for product \"{0}\". Error: {1}", product.ProductID, ex.Message); } }
/// <summary> /// Serialize a product output model into a suitable DOM /// </summary> /// <param name="productOutputModel">product output model</param> /// <returns>A DOM representation of the product output model</returns> public static XmlDocument SerializeModel(ProductBizTalkModel productOutputModel) { var namespaces = new XmlSerializerNamespaces(); namespaces.Add("", ""); var stringBuilder = new StringBuilder(); var serializer = new XmlSerializer(typeof(ProductBizTalkModel)); var stringWriter = new Utf8StringWriter(stringBuilder); serializer.Serialize(stringWriter, productOutputModel, namespaces); stringWriter.Close(); var repositoryDom = new XmlDocument(); repositoryDom.LoadXml(stringBuilder.ToString()); return(repositoryDom); }