public static Product LoadCompleteProduct(int productId) { SimplicityCommLib.DataSets.Common.ProductsTableAdapters.ProductsTableAdapter prodTA = new SimplicityCommLib.DataSets.Common.ProductsTableAdapters.ProductsTableAdapter(); SimplicityCommLib.DataSets.Common.Products.ProductsRow productDS = DatabaseUtility.Instance.GetProduct(productId); if (productDS != null) { Product product = new Product(); product.ProductDS = productDS; ProductsTableAdapters.ProductDetailTableAdapter detailTA = new ProductsTableAdapters.ProductDetailTableAdapter(); IEnumerator<Products.ProductDetailEntityRow> details = detailTA.GetDetailsByProduct(productId).GetEnumerator(); double totalPrice = 0; while (details.MoveNext()) { if (details.Current.mandatory) { product.mandatoryDetails.Add(details.Current); totalPrice += details.Current.price; } else { product.optionalDetails.Add(details.Current); } } ProductsTableAdapters.ProductVersionTableAdapter versionTA = new ProductsTableAdapters.ProductVersionTableAdapter(); IEnumerator<Products.ProductVersionEntityRow> versions = versionTA.GetVersionByProduct(productId).GetEnumerator(); while (versions.MoveNext()) { product.versions.Add(versions.Current); } return product; } else { return null; } }
public static Products.ProductDetailEntityRow GetProductDetail(int productDetailId) { Products.ProductDetailEntityRow productDetail = null; ProductsTableAdapters.ProductDetailTableAdapter ta = new ProductsTableAdapters.ProductDetailTableAdapter(); IEnumerator<Products.ProductDetailEntityRow> productDetails = ta.GetDetailById(productDetailId).GetEnumerator(); if (productDetails.MoveNext()) { productDetail = productDetails.Current; } return productDetail; }