﻿function addToCart(materialUId, count) {
    $.ajax({
        url: '/Service/ProductWebService.asmx/AddToCart',
        data: '{"materialUId":"' + materialUId + '","count":"' + count + '"}',
        type: 'post',
        dataType: 'json',
        contentType: 'application/json',
        success: function(data) {
           
        }
    });
}
function deleteFromCart(id) {
    $.ajax({
        url: '/Service/ProductWebService.asmx/DeleteFromCart',
        data: '{"id":"' + id + '"}',
        type: 'post',
        dataType: 'json',
        contentType: 'application/json',
        success: function(data) {
        }
    });
}

function getMaterialClassCollecion(parentId, count) {
    $.ajax({
        url: '/Service/ProductWebService.asmx/GetMaterialClassCollecion',
        data: '{"parentId":"' + parentId + '","count":"' + count + '"}',
        type: 'post',
        dataType: 'json',
        contentType: 'application/json',
        success: function(data) {
            $(data.d).each(function() {
                var _pId = this["Id"];
                $("#category-list").append("<div class=\"Engine\" id=\"category" + _pId + "\"><h4>" + this["Name"] + "</h4></div>");
                $.ajax({
                    url: '/Service/ProductWebService.asmx/GetMaterialClassCollecion',
                    data: '{"parentId":"' + _pId + '","count":"6"}',
                    type: 'post',
                    dataType: 'json',
                    contentType: 'application/json',
                    success: function(data2) {
                        $(data2.d).each(function() {
                            var __pId = this["Id"];
                            $("#category" + _pId).append("<dl><dt><a href=\"/Product/ProductList.aspx?mc=" + this["UId"] + "\" target=\"_blank\"> " + this["Name"] + "</a></dt><dd id=\"category" + __pId + "\"></dd></dl>");
                            var pUId = this["UId"];
                            $.ajax({
                                url: '/Service/ProductWebService.asmx/GetSuggestMemberCollection',
                                data: '{"parentUId":"' + this["UId"] + '","count":"3"}',
                                type: 'post',
                                dataType: 'json',
                                contentType: 'application/json',
                                success: function(data3) {
                                    $(data3.d).each(function() {
                                    $("#category" + __pId).append("<a href=\"/Product/ProductList.aspx?mc=" + pUId + "&memberUId=" + this["UID"] + "\" target=\"_blank\">" + this["Name"] + "</a>");

                                    });
                                }
                            });
                        });
                    }
                });
            });
        }
    });
}