﻿
/*******************************************************
*  //get all news info
********************************************************/

function newsItemDM() {

    var newsList = [];
    this.GetNewsInfo = function (callback) {
        $.ajax({
            url: "BlockdotServices.asmx/GetNews",
            data: "{}",
            dataType: "json",
            type: "POST",
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                $(data.d).each(function (index, item) {
                    newsList[index] = new NewsItemList(item.NewsId, item.Title, item.Body, item.PressDate);            
                });
                callback(newsList);
            },
            error: function (a, b, c) {             
            }
        });

    }


    /*******************************************************
    *  //get news info by news id
    ********************************************************/
    this.GetNewsInfoByID = function (newsID,callback) {
       

            var newsItems = new Array();
            $.ajax({
                url: "BlockdotServices.asmx/GetNewsByNewsID",
                data: "{'intNewsID': '" + newsID + "'}",
                dataType: "json",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    $(data.d).each(function (index, item) {
                        newsItems[index] = new NewsItemListByID(item.NewsId, item.Title, item.Body, item.PressDate, item.NewsImages);
                    });
                    callback(newsItems);
                },
                error: function (a, b, c) {
                }
            });        
       
    }

} 
newsItemDM = new newsItemDM();

