Ejemplo n.º 1
0
        private String DeleteData(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
            var itemid   = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");

            if (Utils.IsNumeric(itemid))
            {
                var nbi = objCtrl.Get(Convert.ToInt32(itemid));
                if (nbi != null)
                {
                    var typecode = nbi.TypeCode;

                    // run the promo before delete, so we remove any promo data that may exist.
                    if (typecode == "CATEGORYPROMO")
                    {
                        PromoUtils.RemoveGroupProductPromo(PortalSettings.Current.PortalId, nbi.ItemID);
                    }
                    if (typecode == "MULTIBUYPROMO")
                    {
                        PromoUtils.RemoveMultiBuyProductPromo(PortalSettings.Current.PortalId, nbi.ItemID);
                    }

                    // delete DB record
                    objCtrl.Delete(nbi.ItemID);
                }

                NBrightBuyUtils.RemoveModCache(-2);
            }
            return("");
        }
Ejemplo n.º 2
0
        private String SaveData(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            SetContextLangauge(ajaxInfo);     // Ajax breaks context with DNN, so reset the context language to match the client.

            var itemid = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var lang   = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (lang == "")
            {
                lang = ajaxInfo.GetXmlProperty("genxml/hidden/lang");
            }
            if (lang == "")
            {
                lang = _lang;
            }

            if (Utils.IsNumeric(itemid))
            {
                // get DB record
                var nbi = objCtrl.Get(Convert.ToInt32(itemid));
                if (nbi != null)
                {
                    var typecode = nbi.TypeCode;

                    // get data passed back by ajax
                    var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                    // update record with ajax data
                    nbi.UpdateAjax(strIn);
                    nbi.GUIDKey = nbi.GetXmlProperty("genxml/textbox/code");
                    objCtrl.Update(nbi);

                    // do langauge record
                    var nbi2 = objCtrl.GetDataLang(Convert.ToInt32(itemid), lang);
                    nbi2.UpdateAjax(strIn);
                    objCtrl.Update(nbi2);

                    DataCache.ClearCache();     // clear ALL cache.

                    // run the promo now.
                    if (typecode == "CATEGORYPROMO")
                    {
                        PromoUtils.CalcGroupPromoItem(nbi);
                    }
                    if (typecode == "MULTIBUYPROMO")
                    {
                        PromoUtils.CalcMultiBuyPromoItem(nbi);
                    }
                }
            }
            return("");
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public override string DoWork(int portalId)
 {
     return(PromoUtils.CalcMultiBuyPromo(portalId));
 }
Ejemplo n.º 5
0
 public override string DoWork(int portalId)
 {
     return(PromoUtils.CalcGroupPromo(portalId));
 }
Ejemplo n.º 6
0
        public override NBrightInfo AfterProductSave(NBrightInfo nbrightInfo)
        {
            var promoid = nbrightInfo.GetXmlPropertyInt("genxml/hidden/promoid"); // legacy promo flag

            if (nbrightInfo.GetXmlPropertyBool("genxml/hidden/promoflag") || promoid > 0)
            {
                var prdData = ProductUtils.GetProductData(nbrightInfo.ItemID, nbrightInfo.Lang);
                // loop on models to get all promoid at model level.
                var modelpromoids = new List <int>();
                if (promoid > 0)
                {
                    modelpromoids.Add(promoid);
                }
                var lp = 1;
                foreach (var m in prdData.Models)
                {
                    var modelPromoId = prdData.Info.GetXmlPropertyInt("genxml/promo/salepriceid" + lp);
                    if (modelPromoId > 0 && !modelpromoids.Contains(modelPromoId))
                    {
                        modelpromoids.Add(modelPromoId);
                    }
                    modelPromoId = prdData.Info.GetXmlPropertyInt("genxml/promo/dealercostid" + lp);
                    if (modelPromoId > 0 && !modelpromoids.Contains(modelPromoId))
                    {
                        modelpromoids.Add(modelPromoId);
                    }
                    modelPromoId = prdData.Info.GetXmlPropertyInt("genxml/promo/dealersaleid" + lp);
                    if (modelPromoId > 0 && !modelpromoids.Contains(modelPromoId))
                    {
                        modelpromoids.Add(modelPromoId);
                    }
                    lp += 1;
                }

                // multiple promotions, remove from each model.
                foreach (var mpid in modelpromoids)
                {
                    var objCtrl   = new NBrightBuyController();
                    var promoData = objCtrl.GetData(mpid);

                    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, mpid);
                        ProductUtils.RemoveProductDataCache(nbrightInfo.PortalId, nbrightInfo.ItemID);
                    }
                }
            }

            return(nbrightInfo);
        }