public bool SaveProductRelation(int storeID, ProductRelation pr) { try { this._sessionManager.OpenSession().Save(pr); this._sessionManager.OpenSession().Flush(); } catch (Exception e) { LogManager.GetLogger(GetType()).Error(e); return false; } return true; }
private void AddCrossSellAdditions(List<ProductRelation> crossSellList) { int i = 1; while (i <= CrossSellAdditionCount) { string productCode = ""; TextBox t = (TextBox)plhCrossSellAdditions.FindControl("txtCrossSellAddition" + i); if (t.Text != "") { try { productCode = t.Text; if (productCode != "") { Domain.Product p = controller.CatalogueViewer.GetECommerceProductByItemCode(controller.Section.Node.Site.Id, controller.Section.Node.Culture, productCode); if (p != null) { ProductRelation rp = new ProductRelation(); rp.ProductID = p.ProductID; if (Product != null) { rp.ParentID = Product.ProductID; } rp.RelationType = new RelationType(); rp.RelationType.RelationTypeid = (short) RelationType; crossSellList.Add(rp); } } } catch { } } i++; } }
private int AddCrossSellExisting(List<ProductRelation> crossSellList) { int i = 1; while (i < plhCrossSell.Controls.Count) { CheckBox cb = plhCrossSell.Controls[i] as CheckBox; if (cb != null) { string cid = cb.Attributes["cid"]; bool chk = cb.Checked; if (!chk) { try { ProductRelation rp = new ProductRelation(); Domain.Product p = controller.CatalogueViewer.GetECommerceProductByItemCode(controller.Section.Node.Site.Id, controller.Section.Node.Culture, cid); if (p != null) { rp.ProductID = p.ProductID; if (Product != null) { rp.ParentID = Product.ProductID; } rp.RelationType = new RelationType(); rp.RelationType.RelationTypeid = (short)RelationType; crossSellList.Add(rp); } } catch { } } } i++; } return i; }
public List<ProductRelation> GetUpdatedUpSellProducts() { List<ProductRelation> upSellList = new List<ProductRelation>(); foreach (RepeaterItem item in rptUpSell.Items) { TextBox txtBox = item.FindControl("txtPartNumber") as TextBox; CheckBox chkBox = item.FindControl("chkRemove") as CheckBox; if (!chkBox.Checked) { ProductRelation rp = new ProductRelation(); rp.ProductID = rp.ProductID = Convert.ToInt64(txtBox.Text); rp.RelationType = new RelationType(); rp.RelationType.RelationTypeid = (short) Util.Enums.RelatedProductType.UpSell; rp.ParentID = product.ProductID; upSellList.Add(rp); } } int i = 1; while (i <= upSellProducts) { long productCode = 0; TextBox t = (TextBox)plhUpSellAdditions.FindControl("txtUpSellAddition" + i); if (t.Text != "") { try { productCode = Convert.ToInt64(t.Text); if (productCode != 0) { ProductRelation rp = new ProductRelation(); rp.ParentID = product.ProductID; rp.ProductID = productCode; rp.RelationType = new RelationType(); rp.RelationType.RelationTypeid = (short) Util.Enums.RelatedProductType.UpSell; upSellList.Add(rp); } } catch { } } i++; } return upSellList; }