Example #1
0
        public void Promotion_QualificationsToXmlTest()
        {
            var target = new Promotion();
            var q1     = new ProductBvin("abc123");

            target.AddQualification(q1);

            var expected = "<Qualifications>" + Environment.NewLine;

            expected += "  <Qualification>" + Environment.NewLine;
            expected += "    <Id>" + q1.Id + "</Id>" + Environment.NewLine;
            expected += "    <TypeId>" + q1.TypeId + "</TypeId>" + Environment.NewLine;
            expected += "    <ProcessingCost>0</ProcessingCost>" + Environment.NewLine;
            expected += "    <Settings>" + Environment.NewLine;
            expected += "      <Setting>" + Environment.NewLine;
            expected += "        <Key>products</Key>" + Environment.NewLine;
            expected += "        <Value>abc123</Value>" + Environment.NewLine;
            expected += "      </Setting>" + Environment.NewLine;
            expected += "    </Settings>" + Environment.NewLine;
            expected += "  </Qualification>" + Environment.NewLine;

            expected += "</Qualifications>";

            string actual;

            actual = target.QualificationsToXml();
            Assert.AreEqual(expected, actual);
        }
        protected void gvProductBvins_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Promotion   p = GetCurrentPromotion();
            ProductBvin q = (ProductBvin)GetCurrentQualification(p);

            if (q == null)
            {
                return;
            }
            string bvin = (string)e.Keys[0];

            q.RemoveProductBvin(bvin);
            MyPage.MTApp.MarketingServices.Promotions.Update(p);
            LoadProductBvinEditor(q);
        }
        protected void btnAddProductBvins_Click(object sender, ImageClickEventArgs e)
        {
            Promotion   p = GetCurrentPromotion();
            ProductBvin q = (ProductBvin)GetCurrentQualification(p);

            if (q == null)
            {
                return;
            }
            foreach (string bvin in this.ProductPicker1.SelectedProducts)
            {
                q.AddProductBvin(bvin);
            }
            MyPage.MTApp.MarketingServices.Promotions.Update(p);
            LoadProductBvinEditor(q);
        }
Example #4
0
        public void Promotion_QualificationsFromXmlTest()
        {
            var expected = new Promotion();
            var q1       = new ProductBvin("abc123");

            expected.AddQualification(q1);

            var xml = "<Qualifications>" + Environment.NewLine;

            xml += "  <Qualification>" + Environment.NewLine;
            xml += "    <Id>" + q1.Id + "</Id>" + Environment.NewLine;
            xml += "    <TypeId>" + q1.TypeId + "</TypeId>" + Environment.NewLine;
            xml += "    <ProcessingCost>0</ProcessingCost>" + Environment.NewLine;
            xml += "    <Settings>" + Environment.NewLine;
            xml += "      <Setting>" + Environment.NewLine;
            xml += "        <Key>products</Key>" + Environment.NewLine;
            xml += "        <Value>abc123</Value>" + Environment.NewLine;
            xml += "      </Setting>" + Environment.NewLine;
            xml += "    </Settings>" + Environment.NewLine;
            xml += "  </Qualification>" + Environment.NewLine;
            xml += "</Qualifications>";

            var actual = new Promotion();

            actual.QualificationsFromXml(xml);

            Assert.AreEqual(expected.Qualifications.Count, actual.Qualifications.Count,
                            "Qualifications count did not match");
            Assert.AreEqual(q1.GetProductIds()[0], ((ProductBvin)actual.Qualifications[0]).GetProductIds()[0],
                            "Product bvin didn't come through");
            for (var i = 0; i < expected.Qualifications.Count; i++)
            {
                Assert.AreEqual(expected.Qualifications[i].Id, actual.Qualifications[i].Id,
                                "Id didn't match for qualification index " + i);
                Assert.AreEqual(expected.Qualifications[i].ProcessingCost, actual.Qualifications[i].ProcessingCost,
                                "Processing Cost didn't match for qualification index " + i);
                Assert.AreEqual(expected.Qualifications[i].Settings.Count, actual.Qualifications[i].Settings.Count,
                                "Settings Count didn't match for qualification index " + i);
                Assert.AreEqual(expected.Qualifications[i].TypeId, actual.Qualifications[i].TypeId,
                                "TypeId didn't match for qualification index " + i);
            }
        }
        // Product Bvin Editor
        private void LoadProductBvinEditor(ProductBvin q)
        {
            this.ProductPicker1.LoadSearch();

            List <FriendlyBvinDisplay> displayData = new List <FriendlyBvinDisplay>();

            foreach (string bvin in q.CurrentProductIds())
            {
                FriendlyBvinDisplay item = new FriendlyBvinDisplay();
                item.bvin        = bvin;
                item.DisplayName = bvin;

                MerchantTribe.Commerce.Catalog.Product p = MyPage.MTApp.CatalogServices.Products.Find(item.bvin);
                if (p != null)
                {
                    item.DisplayName = "[" + p.Sku + "] " + p.ProductName;
                }
                displayData.Add(item);
            }

            this.gvProductBvins.DataSource = displayData;
            this.gvProductBvins.DataBind();
        }
Example #6
0
        public void QualificationsFromXmlTest()
        {
            Promotion   expected = new Promotion();
            ProductBvin q1       = new ProductBvin("abc123");

            expected.AddQualification(q1);

            string xml = "<Qualifications>" + System.Environment.NewLine;

            xml += "  <Qualification>" + System.Environment.NewLine;
            xml += "    <Id>" + q1.Id.ToString() + "</Id>" + System.Environment.NewLine;
            xml += "    <TypeId>" + q1.TypeId + "</TypeId>" + System.Environment.NewLine;
            xml += "    <ProcessingCost>0</ProcessingCost>" + System.Environment.NewLine;
            xml += "    <Settings>" + System.Environment.NewLine;
            xml += "      <Setting>" + System.Environment.NewLine;
            xml += "        <Key>ProductIds</Key>" + System.Environment.NewLine;
            xml += "        <Value>abc123</Value>" + System.Environment.NewLine;
            xml += "      </Setting>" + System.Environment.NewLine;
            xml += "    </Settings>" + System.Environment.NewLine;
            xml += "  </Qualification>" + System.Environment.NewLine;
            xml += "</Qualifications>";

            Promotion actual = new Promotion();

            actual.QualificationsFromXml(xml);

            Assert.AreEqual(expected.Qualifications.Count, actual.Qualifications.Count, "Qualifications count did not match");
            Assert.AreEqual(q1.CurrentProductIds()[0], ((ProductBvin)actual.Qualifications[0]).CurrentProductIds()[0], "Product bvin didn't come through");
            for (int i = 0; i < expected.Qualifications.Count; i++)
            {
                Assert.AreEqual(expected.Qualifications[i].Id, actual.Qualifications[i].Id, "Id didn't match for qualification index " + i.ToString());
                Assert.AreEqual(expected.Qualifications[i].ProcessingCost, actual.Qualifications[i].ProcessingCost, "Processing Cost didn't match for qualification index " + i.ToString());
                Assert.AreEqual(expected.Qualifications[i].Settings.Count, actual.Qualifications[i].Settings.Count, "Settings Count didn't match for qualification index " + i.ToString());
                Assert.AreEqual(expected.Qualifications[i].TypeId, actual.Qualifications[i].TypeId, "TypeId didn't match for qualification index " + i.ToString());
            }
        }