private void LoadData(int categoryId) { Exists = false; if (categoryId == -1) { categoryId = AddNew(); // add new record if -1 is used as id. } if (_lang == "") { _lang = Utils.GetCurrentCulture(); } Info = _objCtrl.Get(categoryId, "CATEGORYLANG", _lang); if (Info != null) { Exists = true; _portalId = Info.PortalId; DataRecord = _objCtrl.GetData(categoryId); DataLangRecord = _objCtrl.GetDataLang(categoryId, _lang); if (DataLangRecord == null) // rebuild langauge if we have a missing lang record { Validate(); DataLangRecord = _objCtrl.GetDataLang(categoryId, _lang); } } }
private void LoadData(int groupId) { Exists = false; if (groupId == -1) { AddNew(); // add new record if -1 is used as id. } var objCtrl = new NBrightBuyController(); Info = objCtrl.Get(groupId, "GROUPLANG", _lang); if (Info != null) { Exists = true; DataRecord = objCtrl.GetData(groupId); DataLangRecord = objCtrl.GetDataLang(groupId, _lang); } }
public NBrightInfo GetCurrentCategoryInfo(int portalId, System.Web.HttpRequest request, int entryId = 0) { var defcatid = 0; var qrycatid = Utils.RequestQueryStringParam(request, "catid"); if (Utils.IsNumeric(entryId) && entryId > 0) { defcatid = GetDefaultCatId(entryId); } if (defcatid == 0 && Utils.IsNumeric(qrycatid)) { defcatid = Convert.ToInt32(qrycatid); } var objCtrl = new NBrightBuyController(); return(objCtrl.GetData(defcatid, "CATEGORYLANG")); }
private void LoadData(int categoryId) { Exists = false; if (categoryId == -1) { categoryId = AddNew(); // add new record if -1 is used as id. } if (_lang == "") { _lang = Utils.GetCurrentCulture(); } Info = _objCtrl.Get(categoryId, "CATEGORYLANG", _lang); if (Info != null && (Info.TypeCode == "CATEGORY" || Info.TypeCode == "CATEGORYLANG")) // check typecode to ensure URL param is a category. { Exists = true; _portalId = Info.PortalId; DataRecord = _objCtrl.GetData(categoryId); DataLangRecord = _objCtrl.GetDataLang(categoryId, _lang); if (DataLangRecord == null) // rebuild langauge if we have a missing lang record { //Validate(); // creates infinate loop DataLangRecord = _objCtrl.GetDataLang(categoryId, _lang); } if (DataLangRecord == null) { // missing record, but we cannot validate DataLangRecord = new NBrightInfo(true); DataLangRecord.ItemID = -1; DataLangRecord.ParentItemId = categoryId; DataLangRecord.Lang = _lang; _objCtrl.Update(DataLangRecord); } } else { // invalid category, just try to prevent error message. // This can happen by an invlaid URL. e.g. When data is imported and changed ID. DataLangRecord = new NBrightInfo(); DataRecord = new NBrightInfo(); } }
private void LoadData(int groupId) { Exists = false; if (groupId == -1) AddNew(); // add new record if -1 is used as id. var objCtrl = new NBrightBuyController(); Info = objCtrl.Get(groupId, "GROUPLANG", _lang); if (Info != null) { Exists = true; DataRecord = objCtrl.GetData(groupId); DataLangRecord = objCtrl.GetDataLang(groupId, _lang); } }
private void LoadData(int productId, Boolean hydrateLists = true) { Exists = false; var objCtrl = new NBrightBuyController(); if (productId == -1) productId = AddNew(); // add new record if -1 is used as id. Info = objCtrl.Get(productId, "PRDLANG", _lang); if (Info != null) { _portalId = Info.PortalId; _storeSettings = new StoreSettings(_portalId); Exists = true; if (hydrateLists) { //build model list Models = GetEntityList("models"); Options = GetEntityList("options"); Imgs = GetEntityList("imgs"); Docs = GetEntityList("docs"); OptionValues = new List<NBrightInfo>(); foreach (var o in Options) { var l = GetOptionValuesById(o.GetXmlProperty("genxml/hidden/optionid")); OptionValues.AddRange(l); } } Exists = true; DataRecord = objCtrl.GetData(productId); DataLangRecord = objCtrl.GetDataLang(productId, _lang); if (DataLangRecord == null) // rebuild langauge is we have a missing lang record { Validate(); DataLangRecord = objCtrl.GetDataLang(productId, _lang); } IsOnSale = CheckIsOnSale(); IsInStock = CheckIsInStock(); } else { Exists = false; } }
public static string GetCurrentPageName(int catid) { var newBaseName = PortalSettings.Current.ActiveTab.TabName; var objCtrl = new NBrightBuyController(); var catInfo = objCtrl.GetData(catid, "CATEGORYLANG"); if (catInfo != null) { newBaseName = catInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtseoname"); if (newBaseName == "") newBaseName = catInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtcategoryname"); if (newBaseName == "") newBaseName = PortalSettings.Current.ActiveTab.TabName; } return newBaseName; }
private void LoadData(int categoryId) { Exists = false; if (categoryId == -1) categoryId = AddNew(); // add new record if -1 is used as id. var objCtrl = new NBrightBuyController(); if (_lang == "") _lang = Utils.GetCurrentCulture(); Info = objCtrl.Get(categoryId, "CATEGORYLANG", _lang); if (Info != null) { Exists = true; _portalId = Info.PortalId; DataRecord = objCtrl.GetData(categoryId); DataLangRecord = objCtrl.GetDataLang(categoryId, _lang); if (DataLangRecord == null) // rebuild langauge is we have a missing lang record { Validate(); DataLangRecord = objCtrl.GetDataLang(categoryId, _lang); } } }
public static string RemoveMultiBuyProductPromo(int portalId, int promoid) { var objCtrl = new NBrightBuyController(); var p = objCtrl.GetData(promoid); var propgroupid = p.GetXmlPropertyInt("genxml/dropdownlist/propbuy"); var propapplygroupid = p.GetXmlPropertyInt("genxml/dropdownlist/propapply"); var gCat = CategoryUtils.GetCategoryData(propgroupid, Utils.GetCurrentCulture()); if (gCat.Exists) { var prdList = gCat.GetAllArticles(); foreach (var prd in prdList) { // END Promo RemoveProductPromoData(portalId, prd.ParentItemId, promoid); ProductUtils.RemoveProductDataCache(prd.PortalId, prd.ParentItemId); } } if (propapplygroupid != propgroupid && propapplygroupid > 0) { gCat = CategoryUtils.GetCategoryData(propapplygroupid, Utils.GetCurrentCulture()); if (gCat.Exists) { var prdList2 = gCat.GetAllArticles(); foreach (var prd in prdList2) { // END Promo RemoveProductPromoData(p.PortalId, prd.ParentItemId, p.ItemID); ProductUtils.RemoveProductDataCache(p.PortalId, prd.ParentItemId); } } } return "OK"; }
public override NBrightInfo CalculatePromotion(int portalId, NBrightInfo cartInfo) { // loop through cart items var rtncartInfo = (NBrightInfo)cartInfo.Clone(); try { var cartData = new CartData(cartInfo.PortalId); var cartList = cartData.GetCartItemList(); foreach (var cartItemInfo in cartList) { cartInfo.SetXmlPropertyDouble("genxml/items/genxml[./itemcode = '" + cartItemInfo.GetXmlProperty("genxml/itemcode") + "']/promodiscount", 0); // remove any existing discount if (cartItemInfo.GetXmlProperty("genxml/productxml/genxml/hidden/promotype") == "PROMOMULTIBUY") { var promoid = cartItemInfo.GetXmlPropertyInt("genxml/productxml/genxml/hidden/promoid"); var objCtrl = new NBrightBuyController(); var promoData = objCtrl.GetData(promoid); if (promoData != null) { //NOTE: WE nedd to process disabld promotions so they can be removed from cart var buyqty = promoData.GetXmlPropertyInt("genxml/textbox/buyqty"); var validfrom = promoData.GetXmlProperty("genxml/textbox/validfrom"); var validuntil = promoData.GetXmlProperty("genxml/textbox/validuntil"); var propbuygroupid = promoData.GetXmlProperty("genxml/dropdownlist/propbuy"); var propapplygroupid = promoData.GetXmlProperty("genxml/dropdownlist/propapply"); var amounttype = promoData.GetXmlProperty("genxml/radiobuttonlist/amounttype"); var amount = promoData.GetXmlPropertyDouble("genxml/textbox/amount"); // Applied discount to this single cart item if (!promoData.GetXmlPropertyBool("genxml/checkbox/disabled") && cartItemInfo.GetXmlPropertyInt("genxml/qty") >= buyqty && Utils.IsDate(validfrom) && Utils.IsDate(validuntil)) // check we have correct qty to activate promo { var dteF = Convert.ToDateTime(validfrom).Date; var dteU = Convert.ToDateTime(validuntil).Date; if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU) { // calc discount amount var cartqty = cartItemInfo.GetXmlPropertyDouble("genxml/qty"); var qtycount = cartqty; var unitcost = cartItemInfo.GetXmlPropertyDouble("genxml/basecost"); double discountamt = 0; while (qtycount > buyqty) { if (amounttype == "1") { discountamt += (unitcost - amount); } else { discountamt += ((unitcost/100)*amount); } if (discountamt < 0) discountamt = 0; qtycount = (qtycount - (buyqty + 1)); // +1 so we allow for discount 1 in basket. } cartInfo.SetXmlPropertyDouble("genxml/items/genxml[./itemcode = '" + cartItemInfo.GetXmlProperty("genxml/itemcode") + "']/promodiscount", discountamt); } } } } } return cartInfo; } catch (Exception ex) { var x = ex.ToString(); return rtncartInfo; } }
public override NBrightInfo AfterProductSave(NBrightInfo nbrightInfo) { var promoid = nbrightInfo.GetXmlPropertyInt("genxml/hidden/promoid"); if (promoid > 0) { var prdData = ProductUtils.GetProductData(nbrightInfo.ItemID, nbrightInfo.Lang); var objCtrl = new NBrightBuyController(); var promoData = objCtrl.GetData(promoid); var catgroupid = promoData.GetXmlPropertyInt("genxml/dropdownlist/catgroupid"); var propgroupid = promoData.GetXmlPropertyInt("genxml/dropdownlist/propgroupid"); var propbuygroupid = promoData.GetXmlPropertyInt("genxml/dropdownlist/propbuy"); var propapplygroupid = promoData.GetXmlPropertyInt("genxml/dropdownlist/propapply"); var removepromo = true; foreach (var c in prdData.GetCategories()) { if (c.categoryid == catgroupid) removepromo = false; if (c.categoryid == propgroupid) removepromo = false; if (c.categoryid == propbuygroupid) removepromo = false; if (c.categoryid == propapplygroupid) removepromo = false; } if (removepromo) { PromoUtils.RemoveProductPromoData(nbrightInfo.PortalId, nbrightInfo.ItemID,promoid); ProductUtils.RemoveProductDataCache(nbrightInfo.PortalId, nbrightInfo.ItemID); } } return nbrightInfo; }
private static void FlagProductMultiBuy(int portalid,int productId, string promoname, int promoid,String promoType, DateTime dteF, DateTime dteU) { var cultureList = DnnUtils.GetCultureCodeList(portalid); var objCtrl = new NBrightBuyController(); var prdData = objCtrl.GetData(productId); var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml"); if (nodList != null) { var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid"); if (currentpromoid == 0 || currentpromoid == promoid) { prdData.SetXmlProperty("genxml/hidden/promotype", promoType); prdData.SetXmlProperty("genxml/hidden/promoname", promoname); prdData.SetXmlProperty("genxml/hidden/promoid", promoid.ToString()); prdData.SetXmlProperty("genxml/hidden/promocalcdate", DateTime.Now.ToString("O")); prdData.SetXmlProperty("genxml/hidden/datefrom", dteF.ToString("O")); prdData.SetXmlProperty("genxml/hidden/dateuntil", dteU.ToString("O")); objCtrl.Update(prdData); if (promoType == "PROMOMULTIBUY") { foreach (var lang in cultureList) { var p = objCtrl.GetDataLang(promoid, lang); var prdDataLang = objCtrl.GetDataLang(productId, lang); if (prdDataLang != null) { prdDataLang.SetXmlProperty("genxml/hidden/promodesc", p.GetXmlProperty("genxml/textbox/description")); objCtrl.Update(prdDataLang); } } } } } }
private static void EndProductSalePrice(int portalId,int productId, int promoid) { var objCtrl = new NBrightBuyController(); var prdData = objCtrl.GetData(productId); var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml"); if (nodList != null) { var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid"); if (currentpromoid == promoid) { var lp = 1; foreach (XmlNode nod in nodList) { prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", 0); lp += 1; } objCtrl.Update(prdData); RemoveProductPromoData(portalId, productId, promoid); } } }
private static void CalcProductSalePrice(int portalid, int productId, string amounttype, double amount, string promoname, int promoid, bool overwrite,DateTime dteF, DateTime dteU) { var cultureList = DnnUtils.GetCultureCodeList(portalid); var objCtrl = new NBrightBuyController(); var prdData = objCtrl.GetData(productId); var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml"); if (nodList != null) { var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid"); if (currentpromoid == 0 || currentpromoid == promoid || overwrite) { prdData.SetXmlProperty("genxml/hidden/promotype", "PROMOGROUP"); prdData.SetXmlPropertyDouble("genxml/hidden/promoname", promoname); prdData.SetXmlProperty("genxml/hidden/promoid", promoid.ToString()); prdData.SetXmlProperty("genxml/hidden/promocalcdate", DateTime.Now.ToString("O")); prdData.SetXmlProperty("genxml/hidden/datefrom", dteF.ToString("O")); prdData.SetXmlProperty("genxml/hidden/dateuntil", dteU.ToString("O")); var lp = 1; foreach (XmlNode nod in nodList) { var nbi = new NBrightInfo(); nbi.XMLData = nod.OuterXml; var unitcost = nbi.GetXmlPropertyDouble("genxml/textbox/txtunitcost"); Double newamt = 0; if (amounttype == "1") { newamt = unitcost - amount; } else { newamt = unitcost - ((unitcost/100)*amount); } if (newamt < 0) newamt = 0; var currentprice = prdData.GetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice"); if (!overwrite) { if (currentprice == 0) overwrite = true; if (currentpromoid == promoid) overwrite = true; } if (overwrite) { prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt); } lp += 1; } objCtrl.Update(prdData); foreach (var lang in cultureList) { var p = objCtrl.GetDataLang(promoid, lang); var prdDataLang = objCtrl.GetDataLang(productId, lang); if (prdDataLang != null) { prdDataLang.SetXmlProperty("genxml/hidden/promodesc", p.GetXmlProperty("genxml/textbox/description")); objCtrl.Update(prdDataLang); } } } } }
public static void RemoveProductPromoData(int portalid, int productId, int promoid) { var cultureList = DnnUtils.GetCultureCodeList(portalid); var objCtrl = new NBrightBuyController(); var prdData = objCtrl.GetData(productId); var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid"); if (currentpromoid == promoid) { prdData.RemoveXmlNode("genxml/hidden/promotype"); prdData.RemoveXmlNode("genxml/hidden/promoname"); prdData.RemoveXmlNode("genxml/hidden/promoid"); prdData.RemoveXmlNode("genxml/hidden/promocalcdate"); prdData.RemoveXmlNode("genxml/hidden/datefrom"); prdData.RemoveXmlNode("genxml/hidden/dateuntil"); // remove any sale price amounts that may have been added by group promotion. var l = prdData.XMLDoc.SelectNodes("genxml/models/genxml"); if (l != null) { var lp = 1; foreach (XmlNode nod in l) { prdData.SetXmlProperty("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", "0"); lp += 1; } } objCtrl.Update(prdData); foreach (var lang in cultureList) { var prdDataLang = objCtrl.GetDataLang(productId, lang); if (prdDataLang != null) { prdDataLang.RemoveXmlNode("genxml/hidden/promodesc"); objCtrl.Update(prdDataLang); } } } }
public NBrightInfo GetCurrentCategoryInfo(int portalId, System.Web.HttpRequest request, int entryId = 0) { var defcatid = 0; var qrycatid = Utils.RequestQueryStringParam(request, "catid"); if (Utils.IsNumeric(entryId) && entryId > 0) defcatid = GetDefaultCatId(entryId); if (defcatid == 0 && Utils.IsNumeric(qrycatid)) defcatid = Convert.ToInt32(qrycatid); var objCtrl = new NBrightBuyController(); return objCtrl.GetData(defcatid,"CATEGORYLANG"); }
public static string RemoveGroupProductPromo(int portalId,int promoid) { var objCtrl = new NBrightBuyController(); var p = objCtrl.GetData(promoid); var typeselect = p.GetXmlProperty("genxml/radiobuttonlist/typeselect"); var catgroupid = p.GetXmlProperty("genxml/dropdownlist/catgroupid"); var propgroupid = p.GetXmlProperty("genxml/dropdownlist/propgroupid"); CategoryData gCat; var groupid = catgroupid; if (typeselect != "cat") groupid = propgroupid; gCat = CategoryUtils.GetCategoryData(groupid, Utils.GetCurrentCulture()); if (gCat.Exists) { var prdList = gCat.GetAllArticles(); foreach (var prd in prdList) { // END Promo RemoveProductPromoData(portalId, prd.ParentItemId, p.ItemID); ProductUtils.RemoveProductDataCache(prd.PortalId, prd.ParentItemId); } } return "OK"; }