Litle.Sdk.createDiscount.Serialize C# (CSharp) Method

Serialize() public method

public Serialize ( ) : string
return string
        public string Serialize()
        {
            string xml = "";
            xml += "\r\n<discountCode>" + SecurityElement.Escape(discountCode) + "</discountCode>";
            xml += "\r\n<name>" + SecurityElement.Escape(name) + "</name>";
            xml += "\r\n<amount>" + amount + "</amount>";
            xml += "\r\n<startDate>" + XmlUtil.toXsdDate(startDate) + "</startDate>";
            xml += "\r\n<endDate>" + XmlUtil.toXsdDate(endDate) + "</endDate>";
            return xml;
        }

Usage Example

        public void TestCreateDiscount_Full()
        {
            createDiscount cd = new createDiscount();
            cd.discountCode = "1";
            cd.name = "cheaper";
            cd.amount = 200;
            cd.startDate = new DateTime(2013, 9, 5);
            cd.endDate = new DateTime(2013, 9, 6);

            String actual = cd.Serialize();
            String expected = @"
            <discountCode>1</discountCode>
            <name>cheaper</name>
            <amount>200</amount>
            <startDate>2013-09-05</startDate>
            <endDate>2013-09-06</endDate>";
            Assert.AreEqual(expected, actual);
        }
createDiscount