Esempio n. 1
0
        private MvcHtmlString WriteProducts(Gllo.Models.JsonArray products, int len = 0)
        {
            if (products != null)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                decimal specialPrice, price;
                if (len != 0)
                {
                    sb.Append("<div>");
                }
                for (var i = 0; i < products.Count; i++)
                {
                    int id = (int)products[i]["ProductID"];
                    specialPrice = (decimal)products[i]["SpecialPrice"];
                    price        = (decimal)products[i]["Price"];

                    sb.Append("<dl class=\"pi\"><dt><a href=\"/product/")
                    .Append(id)
                    .Append(".html\"><img src=\"")
                    .Append(Gllo.Sys.Config.MediaServer)
                    .Append(products[i]["PictureUrl"])
                    .Append("\" alt=\"")
                    .Append(products[i]["PictureDesc"])
                    .Append("\" /></a></dt><dd><a href=\"/product/")
                    .Append(id)
                    .Append(".html\">")
                    .Append(products[i]["Name"])
                    .Append("</a></dd>");
                    if (specialPrice != 0 && specialPrice < price)
                    {
                        sb.Append("<dd>原价:<del>¥")
                        .Append(price.ToString("0"))
                        .Append("</del></dd><dd>现价:<span>¥")
                        .Append(specialPrice.ToString("0"))
                        .Append("</span></dd>");
                    }
                    else
                    {
                        sb.Append("<dd>价格:<span>¥")
                        .Append(price.ToString("0"))
                        .Append("</span></dd>");
                    }

                    sb.AppendLine("</dl>");

                    if (len != 0 && (i + 1) % len == 0 && i != products.Count - 1)
                    {
                        sb.Append("</div><div>");
                    }
                }
                if (len != 0)
                {
                    sb.Append("</div>");
                }

                return(new MvcHtmlString(sb.ToString()));
            }
            return(null);
        }
Esempio n. 2
0
        public static JsonArray Parse(string input)
        {
            JsonArray json = new JsonArray();

            return(new JavaScriptSerializer().Deserialize <JsonArray>(input));
        }